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>
90 lines
2.5 KiB
JavaScript
90 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
const mediaParser = require('postcss-media-query-parser').default;
|
|
|
|
const { rangeTypeMediaFeatureNames } = require('../../reference/mediaFeatures.js');
|
|
const atRuleParamIndex = require('../../utils/atRuleParamIndex');
|
|
const isRangeContextMediaFeature = require('../../utils/isRangeContextMediaFeature');
|
|
const isStandardSyntaxMediaFeatureName = require('../../utils/isStandardSyntaxMediaFeatureName');
|
|
const report = require('../../utils/report');
|
|
const ruleMessages = require('../../utils/ruleMessages');
|
|
const validateOptions = require('../../utils/validateOptions');
|
|
|
|
const ruleName = 'media-feature-range-notation';
|
|
|
|
const messages = ruleMessages(ruleName, {
|
|
expected: (primary) => `Expected "${primary}" media feature range notation`,
|
|
});
|
|
|
|
const meta = {
|
|
url: 'https://stylelint.io/user-guide/rules/media-feature-range-notation',
|
|
};
|
|
|
|
/** @type {import('stylelint').Rule} */
|
|
const rule = (primary) => {
|
|
return (root, result) => {
|
|
const validOptions = validateOptions(result, ruleName, {
|
|
actual: primary,
|
|
possible: ['prefix', 'context'],
|
|
});
|
|
|
|
if (!validOptions) {
|
|
return;
|
|
}
|
|
|
|
root.walkAtRules(/^media$/i, (atRule) => {
|
|
mediaParser(atRule.params).walk(/^media-feature$/i, ({ parent, value }) => {
|
|
if (!isStandardSyntaxMediaFeatureName(value)) return;
|
|
|
|
if (!isRangeContextMediaFeature(value) && isInBooleanContext(parent)) return;
|
|
|
|
if (!isRangeContextMediaFeature(value) && !isRangeTypeMediaFeature(value)) return;
|
|
|
|
if (primary === 'prefix' && isPrefixedRangeMediaFeature(value)) return;
|
|
|
|
if (primary === 'context' && isRangeContextMediaFeature(value)) return;
|
|
|
|
const index = atRuleParamIndex(atRule) + parent.sourceIndex;
|
|
const endIndex = index + parent.value.length;
|
|
|
|
report({
|
|
message: messages.expected(primary),
|
|
node: atRule,
|
|
index,
|
|
endIndex,
|
|
result,
|
|
ruleName,
|
|
});
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
/**
|
|
* @param {string} mediaFeature
|
|
*/
|
|
function isPrefixedRangeMediaFeature(mediaFeature) {
|
|
return mediaFeature.startsWith('min-') || mediaFeature.startsWith('max-');
|
|
}
|
|
|
|
/**
|
|
* @param {string} mediaFeature
|
|
*/
|
|
function isRangeTypeMediaFeature(mediaFeature) {
|
|
const unprefixedMediaFeature = mediaFeature.replace(/^(?:min|max)-/, '');
|
|
|
|
return rangeTypeMediaFeatureNames.has(unprefixedMediaFeature);
|
|
}
|
|
|
|
/**
|
|
* @param {import('postcss-media-query-parser').Node} mediaFeatureExpressionNode
|
|
*/
|
|
function isInBooleanContext({ nodes }) {
|
|
return nodes && nodes.length === 1;
|
|
}
|
|
|
|
rule.ruleName = ruleName;
|
|
rule.messages = messages;
|
|
rule.meta = meta;
|
|
module.exports = rule;
|