|
1 | 1 |
|
2 | 2 | const { angle, filter, keyword, list, map, number, omitted, string } = require('../values/value.js') |
3 | | -const { findFunction, findSibling, getDeclaration, getDeclarationName, getFunctionName, getRuleName, isDeclaredBy, isProducedBy } = require('../utils/context.js') |
| 3 | +const { findFunction, findSibling, getDeclaration, getDeclarationName, getFunctionName, getRule, getRuleName, isDeclaredBy, isProducedBy } = require('../utils/context.js') |
4 | 4 | const { addTypes, dimensionTypes, getCalculationType, matchNumericType } = require('./types.js') |
5 | 5 | const { isCalculation, isColon, isFailure, isList, isOmitted, isWhitespace } = require('../utils/value.js') |
6 | 6 | const { isHexadecimal, isIdentifierCharacter, isWhitespace: isWhitespaceCharacter } = require('./tokenize.js') |
@@ -1527,25 +1527,29 @@ function postParseSteps(steps, node) { |
1527 | 1527 | } |
1528 | 1528 |
|
1529 | 1529 | /** |
1530 | | - * @param {object} feature |
| 1530 | + * @param {object} name |
1531 | 1531 | * @param {object} node |
1532 | 1532 | * @param {object} parser |
1533 | 1533 | * @returns {SyntaxError|object} |
1534 | | - * @see {@link https://drafts.csswg.org/css-conditional-5/#typedef-style-feature} |
| 1534 | + * @see {@link https://drafts.csswg.org/css-conditional-5/#typedef-style-feature-name} |
1535 | 1535 | * |
1536 | | - * It aborts parsing when the feature is an unknown property or a declaration |
1537 | | - * whose value is either `revert` or `revert-layer`. |
| 1536 | + * It aborts parsing when the name is not a valid style property. |
1538 | 1537 | */ |
1539 | | -function postParseStyleFeature(feature, node, { createContext, getDeclarationDefinition }) { |
1540 | | - const { types, value } = feature |
1541 | | - if ( |
1542 | | - types[0] === '<ident-token>' |
1543 | | - ? getDeclarationDefinition(createContext('@style'), value) |
1544 | | - : !value.value?.startsWith?.('revert') |
1545 | | - ) { |
1546 | | - return feature |
1547 | | - } |
1548 | | - return error(node) |
| 1538 | +function postParseStyleFeatureName(name, node, parser) { |
| 1539 | + return parser.getDeclarationDefinition(getRule(node), name.value) ? name : error(node) |
| 1540 | +} |
| 1541 | + |
| 1542 | +/** |
| 1543 | + * @param {object} declaration |
| 1544 | + * @param {object} node |
| 1545 | + * @param {object} parser |
| 1546 | + * @returns {SyntaxError|object} |
| 1547 | + * @see {@link https://drafts.csswg.org/css-conditional-5/#typedef-style-feature-name} |
| 1548 | + * |
| 1549 | + * It aborts parsing when the declaration value is `revert` or `revert-layer`. |
| 1550 | + */ |
| 1551 | +function postParseStyleFeaturePlain(declaration, node) { |
| 1552 | + return declaration.value.value?.startsWith?.('revert') ? error(node) : declaration |
1549 | 1553 | } |
1550 | 1554 |
|
1551 | 1555 | /** |
@@ -1841,7 +1845,8 @@ module.exports = { |
1841 | 1845 | '<signed-integer>': postParseSignedInteger, |
1842 | 1846 | '<signless-integer>': postParseSignlessInteger, |
1843 | 1847 | '<steps()>': postParseSteps, |
1844 | | - '<style-feature>': postParseStyleFeature, |
| 1848 | + '<style-feature-plain>': postParseStyleFeaturePlain, |
| 1849 | + '<style-feature-name>': postParseStyleFeatureName, |
1845 | 1850 | '<symbols()>': postParseSymbols, |
1846 | 1851 | '<syntax-string>': postParseSyntaxString, |
1847 | 1852 | '<syntax>': postParseSyntax, |
|
0 commit comments