@@ -247,35 +247,35 @@ function getDeclarationName(name, context) {
247
247
* @param {object } context
248
248
* @returns {object|null }
249
249
*/
250
- function getDeclarationValueDefinition ( name , context ) {
250
+ function getDeclarationDefinition ( name , context ) {
251
251
name = getDeclarationName ( name , context )
252
252
const { rule : { definition : { name : ruleName , value : { descriptors, properties } } } } = context
253
253
if ( properties ) {
254
254
if ( name . startsWith ( '--' ) ) {
255
255
const definition = properties ?. [ '--*' ]
256
256
if ( definition ) {
257
- return { name, type : 'property ' , value : definition . value }
257
+ return { name, type : 'declaration ' , value : definition . value }
258
258
}
259
259
return null
260
260
}
261
261
const target = compatibility . properties . mappings . get ( name )
262
262
const value = properties [ target ] ?. value ?? properties [ name ] ?. value
263
263
if ( value ) {
264
- return { name, type : 'property ' , value }
264
+ return { name, type : 'declaration ' , value }
265
265
}
266
266
}
267
267
if ( descriptors ) {
268
268
if ( name . startsWith ( '--' ) ) {
269
269
const definition = descriptors ?. [ '--*' ]
270
270
if ( definition ) {
271
- return { name, type : 'descriptor ' , value : definition . value }
271
+ return { name, type : 'declaration ' , value : definition . value }
272
272
}
273
273
return null
274
274
}
275
275
const target = compatibility . descriptors [ ruleName ] ?. mappings ?. get ( name )
276
276
const value = descriptors [ target ] ?. value ?? descriptors [ name ] ?. value ?? descriptors [ '*' ]
277
277
if ( value ) {
278
- return { name, type : 'descriptor ' , value }
278
+ return { name, type : 'declaration ' , value }
279
279
}
280
280
}
281
281
return null
@@ -536,7 +536,7 @@ function consumeDeclaration(tokens, context, nested) {
536
536
if ( ! name ) {
537
537
return null
538
538
}
539
- const definition = getDeclarationValueDefinition ( name . value , context )
539
+ const definition = getDeclarationDefinition ( name . value , context )
540
540
if ( ! definition ) {
541
541
return null
542
542
}
@@ -1064,7 +1064,7 @@ function parseCSSValue(input, definition, context, strategy = 'backtrack') {
1064
1064
const { forgiving, trees } = context
1065
1065
1066
1066
// Try parsing arbitrary substitution containing value
1067
- if ( trees . length === 0 && ( type === 'descriptor' || type === 'property' ) ) {
1067
+ if ( type === 'declaration' && ! context . function ) {
1068
1068
const substitution = parseCSSArbitrarySubstitutionContainingValue ( input , context )
1069
1069
if ( substitution ) {
1070
1070
return substitution
@@ -1103,12 +1103,8 @@ function parseCSSValue(input, definition, context, strategy = 'backtrack') {
1103
1103
case 'aborted' :
1104
1104
return ( forgiving && ! context . function ?. context . forgiving ) ? null : match
1105
1105
// The current list is invalid (match is null or undefined)
1106
- case 'rejected' : {
1107
- if ( type === 'descriptor' || type === 'property' ) {
1108
- return parseCSSValueSubstitution ( input , context )
1109
- }
1110
- return null
1111
- }
1106
+ case 'rejected' :
1107
+ return type === 'declaration' ? parseCSSValueSubstitution ( input , context ) : null
1112
1108
default :
1113
1109
return match
1114
1110
}
@@ -1129,7 +1125,7 @@ function parseCSSDeclaration(name, value, important, context) {
1129
1125
return null
1130
1126
}
1131
1127
1132
- const definition = getDeclarationValueDefinition ( name , context )
1128
+ const definition = getDeclarationDefinition ( name , context )
1133
1129
if ( ! definition ) {
1134
1130
return null
1135
1131
}
@@ -1174,7 +1170,7 @@ function parseCSSStyleSheet(rules) {
1174
1170
const parser = module . exports = {
1175
1171
createContext,
1176
1172
getDeclarationName,
1177
- getDeclarationValueDefinition ,
1173
+ getDeclarationDefinition ,
1178
1174
insertCSSRule,
1179
1175
parseBlockContents,
1180
1176
parseCSSDeclaration,
0 commit comments