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>
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const { assertString } = require('./validateTypes');
|
|
|
|
const DISABLE_COMMAND = 'stylelint-disable';
|
|
const DISABLE_LINE_COMMAND = 'stylelint-disable-line';
|
|
const DISABLE_NEXT_LINE_COMMAND = 'stylelint-disable-next-line';
|
|
const ENABLE_COMMAND = 'stylelint-enable';
|
|
|
|
const ALL_COMMANDS = new Set([
|
|
DISABLE_COMMAND,
|
|
DISABLE_LINE_COMMAND,
|
|
DISABLE_NEXT_LINE_COMMAND,
|
|
ENABLE_COMMAND,
|
|
]);
|
|
|
|
/** @typedef {import('postcss').Comment} Comment */
|
|
|
|
/**
|
|
* Extract a command from a given comment.
|
|
*
|
|
* @param {Comment} comment
|
|
* @returns {string}
|
|
*/
|
|
function extractStylelintCommand(comment) {
|
|
const [command] = comment.text.split(/\s/, 1);
|
|
|
|
assertString(command);
|
|
|
|
return command;
|
|
}
|
|
|
|
/**
|
|
* Tests if the given comment is a Stylelint command.
|
|
*
|
|
* @param {Comment} comment
|
|
* @returns {boolean}
|
|
*/
|
|
function isStylelintCommand(comment) {
|
|
const command = extractStylelintCommand(comment);
|
|
|
|
return command !== undefined && ALL_COMMANDS.has(command);
|
|
}
|
|
|
|
module.exports = {
|
|
DISABLE_COMMAND,
|
|
DISABLE_LINE_COMMAND,
|
|
DISABLE_NEXT_LINE_COMMAND,
|
|
ENABLE_COMMAND,
|
|
|
|
extractStylelintCommand,
|
|
isStylelintCommand,
|
|
};
|