Skip to content

Commit 095e244

Browse files
committed
Do not abort parsing for unregistered <ns-prefix> in <attribute-selector>
1 parent a0eda56 commit 095e244

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

lib/parse/postprocess.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as pseudos from '../values/pseudos.js'
66
import { add as addTypes, dimensionTypes, getCalculationType, matchNumericType } from './types.js'
77
import { angle, filter, keyword, list, map, number, omitted, string } from '../values/value.js'
88
import { auto, notAll } from '../values/defaults.js'
9-
import { findFunction, findSibling, getDeclaration, getDeclarationName, getFunctionName, getRule, getRuleName, isDeclaredBy, isProducedBy } from '../utils/context.js'
9+
import { findFunction, findSibling, getBlock, getDeclaration, getDeclarationName, getFunctionName, getProduction, getRule, getRuleName, isDeclaredBy, isProducedBy } from '../utils/context.js'
1010
import { getDeclarationDefinition, parseDeclarationValue, parseGrammar } from './parser.js'
1111
import { isBlock, isCalculation, isComputationallyIndependent, isFailure, isFunction, isList, isOmitted, isWhitespace } from '../utils/value.js'
1212
import { isHexadecimal, isIdentifierCharacter, isWhitespace as isWhitespaceCharacter, toLowerCase } from '../utils/string.js'
@@ -1275,6 +1275,10 @@ function postParseNSPrefix(prefix, node) {
12751275
if (isOmitted(name) || node.context.globals.get('namespaces').has(name.value)) {
12761276
return prefix
12771277
}
1278+
const block = getBlock(node)
1279+
if (block && getProduction(block)?.definition.name === '<attribute-selector>') {
1280+
return
1281+
}
12781282
return error(node)
12791283
}
12801284

lib/utils/context.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ export function findSibling({ context, parent }, accept, abort, climb) {
115115
return null
116116
}
117117

118+
/**
119+
* @param {object} node
120+
* @returns {object|undefined}
121+
*/
122+
export function getBlock(node) {
123+
return findContext(node, node => node.definition.type === 'block')
124+
}
125+
118126
/**
119127
* @param {object} node
120128
* @returns {object|undefined}

test/value.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,6 +2425,9 @@ describe('<attr-matcher>', () => {
24252425
test('representation', () => {
24262426
assert.representation('<attr-matcher>', '=', list([omitted, delimiter('=')], '', ['<attr-matcher>']))
24272427
})
2428+
test('valid', () => {
2429+
assert.valid('<attribute-selector>', '[attr|=value]')
2430+
})
24282431
})
24292432
describe('<attr-name>', () => {
24302433
test('invalid', () => {

0 commit comments

Comments
 (0)