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>
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
var implementation = require('./implementation');
|
|
|
|
var lacksProperEnumerationOrder = function () {
|
|
if (!Object.assign) {
|
|
return false;
|
|
}
|
|
/*
|
|
* v8, specifically in node 4.x, has a bug with incorrect property enumeration order
|
|
* note: this does not detect the bug unless there's 20 characters
|
|
*/
|
|
var str = 'abcdefghijklmnopqrst';
|
|
var letters = str.split('');
|
|
var map = {};
|
|
for (var i = 0; i < letters.length; ++i) {
|
|
map[letters[i]] = letters[i];
|
|
}
|
|
var obj = Object.assign({}, map);
|
|
var actual = '';
|
|
for (var k in obj) {
|
|
actual += k;
|
|
}
|
|
return str !== actual;
|
|
};
|
|
|
|
var assignHasPendingExceptions = function () {
|
|
if (!Object.assign || !Object.preventExtensions) {
|
|
return false;
|
|
}
|
|
/*
|
|
* Firefox 37 still has "pending exception" logic in its Object.assign implementation,
|
|
* which is 72% slower than our shim, and Firefox 40's native implementation.
|
|
*/
|
|
var thrower = Object.preventExtensions({ 1: 2 });
|
|
try {
|
|
Object.assign(thrower, 'xy');
|
|
} catch (e) {
|
|
return thrower[1] === 'y';
|
|
}
|
|
return false;
|
|
};
|
|
|
|
module.exports = function getPolyfill() {
|
|
if (!Object.assign) {
|
|
return implementation;
|
|
}
|
|
if (lacksProperEnumerationOrder()) {
|
|
return implementation;
|
|
}
|
|
if (assignHasPendingExceptions()) {
|
|
return implementation;
|
|
}
|
|
return Object.assign;
|
|
};
|