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

25
node_modules/@wordpress/is-shallow-equal/src/arrays.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/**
* Returns true if the two arrays are shallow equal, or false otherwise.
*
* @param {any[]} a First array to compare.
* @param {any[]} b Second array to compare.
*
* @return {boolean} Whether the two arrays are shallow equal.
*/
export default function isShallowEqualArrays( a, b ) {
if ( a === b ) {
return true;
}
if ( a.length !== b.length ) {
return false;
}
for ( let i = 0, len = a.length; i < len; i++ ) {
if ( a[ i ] !== b[ i ] ) {
return false;
}
}
return true;
}

33
node_modules/@wordpress/is-shallow-equal/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
/**
* Internal dependencies
*/
import isShallowEqualObjects from './objects';
import isShallowEqualArrays from './arrays';
export { default as isShallowEqualObjects } from './objects';
export { default as isShallowEqualArrays } from './arrays';
/**
* @typedef {Record<string, any>} ComparableObject
*/
/**
* Returns true if the two arrays or objects are shallow equal, or false
* otherwise. Also handles primitive values, just in case.
*
* @param {unknown} a First object or array to compare.
* @param {unknown} b Second object or array to compare.
*
* @return {boolean} Whether the two values are shallow equal.
*/
export default function isShallowEqual( a, b ) {
if ( a && b ) {
if ( a.constructor === Object && b.constructor === Object ) {
return isShallowEqualObjects( a, b );
} else if ( Array.isArray( a ) && Array.isArray( b ) ) {
return isShallowEqualArrays( a, b );
}
}
return a === b;
}

View File

@@ -0,0 +1,43 @@
/**
* Returns true if the two objects are shallow equal, or false otherwise.
*
* @param {import('.').ComparableObject} a First object to compare.
* @param {import('.').ComparableObject} b Second object to compare.
*
* @return {boolean} Whether the two objects are shallow equal.
*/
export default function isShallowEqualObjects( a, b ) {
if ( a === b ) {
return true;
}
const aKeys = Object.keys( a );
const bKeys = Object.keys( b );
if ( aKeys.length !== bKeys.length ) {
return false;
}
let i = 0;
while ( i < aKeys.length ) {
const key = aKeys[ i ];
const aValue = a[ key ];
if (
// In iterating only the keys of the first object after verifying
// equal lengths, account for the case that an explicit `undefined`
// value in the first is implicitly undefined in the second.
//
// Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )
( aValue === undefined && ! b.hasOwnProperty( key ) ) ||
aValue !== b[ key ]
) {
return false;
}
i++;
}
return true;
}