fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

45
node_modules/@wordpress/dom-ready/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
/**
* @typedef {() => void} Callback
*
* TODO: Remove this typedef and inline `() => void` type.
*
* This typedef is used so that a descriptive type is provided in our
* automatically generated documentation.
*
* An in-line type `() => void` would be preferable, but the generated
* documentation is `null` in that case.
*
* @see https://github.com/WordPress/gutenberg/issues/18045
*/
/**
* Specify a function to execute when the DOM is fully loaded.
*
* @param {Callback} callback A function to execute after the DOM is ready.
*
* @example
* ```js
* import domReady from '@wordpress/dom-ready';
*
* domReady( function() {
* //do something after DOM loads.
* } );
* ```
*
* @return {void}
*/
export default function domReady( callback ) {
if ( typeof document === 'undefined' ) {
return;
}
if (
document.readyState === 'complete' || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly.
document.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.
) {
return void callback();
}
// DOMContentLoaded has not fired yet, delay callback until then.
document.addEventListener( 'DOMContentLoaded', callback );
}

View File

@@ -0,0 +1,49 @@
/**
* Internal dependencies
*/
import domReady from '../';
describe( 'domReady', () => {
beforeAll( () => {
Object.defineProperty( document, 'readyState', {
value: 'loading',
writable: true,
} );
} );
describe( 'when document readystate is complete', () => {
it( 'should call the callback.', () => {
const callback = jest.fn( () => {} );
document.readyState = 'complete';
domReady( callback );
expect( callback ).toHaveBeenCalled();
} );
} );
describe( 'when document readystate is interactive', () => {
it( 'should call the callback.', () => {
const callback = jest.fn( () => {} );
document.readyState = 'interactive';
domReady( callback );
expect( callback ).toHaveBeenCalled();
} );
} );
describe( 'when document readystate is still loading', () => {
it( 'should add the callback as an event listener to the DOMContentLoaded event.', () => {
const addEventListener = jest.fn( () => {} );
document.readyState = 'loading';
Object.defineProperty( document, 'addEventListener', {
value: addEventListener,
} );
const callback = jest.fn( () => {} );
domReady( callback );
expect( callback ).not.toHaveBeenCalled();
expect( addEventListener ).toHaveBeenCalledWith(
'DOMContentLoaded',
callback
);
} );
} );
} );