Skip to content

Commit 914eaf0

Browse files
committed
Do not conflate the definition of a delcaration and its value
1 parent 06c9f9f commit 914eaf0

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

lib/parse/parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ function consumeDeclaration(tokens, context, nested) {
592592
return error(INVALID_DECLARATION_VALUE_ERROR)
593593
}
594594

595-
value = parseCSSDeclarationValue(value, definition, node)
595+
value = parseCSSDeclarationValue(value, { ...definition, type: 'non-terminal' }, node)
596596
if (isFailure(value)) {
597597
consumeBadDeclaration(tokens, true, nested)
598598
return error(INVALID_DECLARATION_VALUE_ERROR)
@@ -1106,7 +1106,7 @@ function parseCSSDeclaration(name, value, important, context) {
11061106
}
11071107

11081108
value = new Stream(value, source)
1109-
value = parseCSSDeclarationValue(value, definition, node)
1109+
value = parseCSSDeclarationValue(value, { ...definition, type: 'non-terminal' }, node)
11101110
if (isFailure(value)) {
11111111
return value
11121112
}

lib/parse/postprocess.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ function postParseFamilyName(name, node) {
519519
*/
520520
function postParseFirstValid(substitution, node, { parseCSSDeclarationValue }) {
521521
const { context } = node
522-
const { definition } = getDeclaration(node)
522+
const definition = { ...getDeclaration(node).definition, type: 'non-terminal' }
523523
for (let value of substitution.value) {
524524
if (!isFailure(value = parseCSSDeclarationValue(value, definition, context))) {
525525
return value
@@ -1744,7 +1744,7 @@ function postParseViewTransitionName(name, node) {
17441744
* It aborts parsing when the value is invalid for the property.
17451745
*/
17461746
function postParseWholeValue(value, node, parser) {
1747-
const { definition } = getDeclaration(node)
1747+
const definition = { ...getDeclaration(node).definition, type: 'non-terminal' }
17481748
if (isOmitted(value)) {
17491749
return definition.name.startsWith('--') ? value : error(node)
17501750
}

lib/utils/node.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
const type = Symbol('node')
33
const sequences = ['||', '&&', ' ']
44
const combinators = ['|', ...sequences]
5-
const compounds = ['block', 'function', 'rule']
5+
const compounds = ['block', 'declaration', 'function', 'rule']
66

77
/**
88
* @param {object} node
99
* @returns {boolean}
1010
*/
1111
function isBranch(node) {
1212
const { definition: { type } } = node
13-
return type === 'declaration'
14-
|| type === 'non-terminal'
13+
return type === 'non-terminal'
1514
|| isCombination(node)
1615
|| isMultiplied(node)
1716
}

0 commit comments

Comments
 (0)