@eslint/css-tree 3.6.5 → 3.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/cjs/syntax/node/Block.cjs +25 -2
- package/cjs/syntax/node/DeclarationList.cjs +51 -1
- package/cjs/syntax/node/TypeSelector.cjs +14 -0
- package/data/patch.json +96 -0
- package/dist/csstree.esm.js +10 -10
- package/dist/csstree.js +10 -10
- package/dist/data.cjs +32 -9
- package/dist/data.js +32 -9
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/lib/syntax/node/Block.js +25 -2
- package/lib/syntax/node/DeclarationList.js +58 -2
- package/lib/syntax/node/TypeSelector.js +14 -0
- package/package.json +1 -1
package/dist/data.cjs
CHANGED
|
@@ -233,12 +233,12 @@ module.exports = {
|
|
|
233
233
|
"grayscale()": "grayscale( [<number>|<percentage>]? )",
|
|
234
234
|
"grid-line": "auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]",
|
|
235
235
|
"historical-lig-values": "[historical-ligatures|no-historical-ligatures]",
|
|
236
|
-
"hsl()": "
|
|
237
|
-
"hsla()": "
|
|
236
|
+
"hsl()": "<legacy-hsl-syntax>|<modern-hsl-syntax>",
|
|
237
|
+
"hsla()": "<legacy-hsla-syntax>|<modern-hsla-syntax>",
|
|
238
238
|
"hue": "<number>|<angle>",
|
|
239
239
|
"hue-interpolation-method": "[shorter|longer|increasing|decreasing] hue",
|
|
240
240
|
"hue-rotate()": "hue-rotate( [<angle>|<zero>]? )",
|
|
241
|
-
"hwb()": "hwb
|
|
241
|
+
"hwb()": "<legacy-hwb-syntax>|<modern-hwb-syntax>",
|
|
242
242
|
"hypot()": "hypot( <calc-sum># )",
|
|
243
243
|
"image": "<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>",
|
|
244
244
|
"image()": "image( <image-tags>? [<image-src>? , <color>?]! )",
|
|
@@ -252,10 +252,10 @@ module.exports = {
|
|
|
252
252
|
"keyframe-block": "<keyframe-selector># { <declaration-list> }",
|
|
253
253
|
"keyframe-selector": "from|to|<percentage [0,100]>|<timeline-range-name> <percentage>",
|
|
254
254
|
"keyframes-name": "<custom-ident>|<string>",
|
|
255
|
-
"lab()": "lab
|
|
255
|
+
"lab()": "<legacy-lab-syntax>|<modern-lab-syntax>",
|
|
256
256
|
"layer()": "layer( <layer-name> )",
|
|
257
257
|
"layer-name": "<ident> ['.' <ident>]*",
|
|
258
|
-
"lch()": "lch
|
|
258
|
+
"lch()": "<legacy-lch-syntax>|<modern-lch-syntax>",
|
|
259
259
|
"leader()": "leader( <leader-type> )",
|
|
260
260
|
"leader-type": "dotted|solid|space|<string>",
|
|
261
261
|
"length-percentage": "<length>|<percentage>",
|
|
@@ -310,8 +310,8 @@ module.exports = {
|
|
|
310
310
|
"numeric-fraction-values": "[diagonal-fractions|stacked-fractions]",
|
|
311
311
|
"numeric-spacing-values": "[proportional-nums|tabular-nums]",
|
|
312
312
|
"offset-path": "<ray()>|<url>|<basic-shape>",
|
|
313
|
-
"oklab()": "oklab
|
|
314
|
-
"oklch()": "oklch
|
|
313
|
+
"oklab()": "<legacy-oklab-syntax>|<modern-oklab-syntax>",
|
|
314
|
+
"oklch()": "<legacy-oklch-syntax>|<modern-oklch-syntax>",
|
|
315
315
|
"opacity()": "opacity( [<number>|<percentage>]? )",
|
|
316
316
|
"opacity-value": "<number>|<percentage>",
|
|
317
317
|
"outline-line-style": "none|dotted|dashed|solid|double|groove|ridge|inset|outset",
|
|
@@ -361,8 +361,8 @@ module.exports = {
|
|
|
361
361
|
"repeating-linear-gradient()": "repeating-linear-gradient( [<linear-gradient-syntax>] )",
|
|
362
362
|
"repeating-radial-gradient()": "repeating-radial-gradient( [<radial-gradient-syntax>] )",
|
|
363
363
|
"reversed-counter-name": "reversed( <counter-name> )",
|
|
364
|
-
"rgb()": "
|
|
365
|
-
"rgba()": "
|
|
364
|
+
"rgb()": "<legacy-rgb-syntax>|<modern-rgb-syntax>",
|
|
365
|
+
"rgba()": "<legacy-rgba-syntax>|<modern-rgba-syntax>",
|
|
366
366
|
"rotate()": "rotate( [<angle>|<zero>] )",
|
|
367
367
|
"rotate3d()": "rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )",
|
|
368
368
|
"rotateX()": "rotateX( [<angle>|<zero>] )",
|
|
@@ -521,6 +521,29 @@ module.exports = {
|
|
|
521
521
|
"url-modifier": "<ident>|<function-token> <any-value> )",
|
|
522
522
|
"number-zero-one": "<number [0,1]>",
|
|
523
523
|
"number-one-or-greater": "<number [1,∞]>",
|
|
524
|
+
"rgb-component": "r|g|b|alpha",
|
|
525
|
+
"legacy-rgb-syntax": "rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )|rgb( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )",
|
|
526
|
+
"modern-rgb-syntax": "rgb( from <color> [<number>|<percentage>|<rgb-component>]{3} [/ [<alpha-value>|<rgb-component>]]? )",
|
|
527
|
+
"legacy-rgba-syntax": "rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )|rgba( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )",
|
|
528
|
+
"modern-rgba-syntax": "rgba( from <color> [<number>|<percentage>|<rgb-component>]{3} [/ [<alpha-value>|<rgb-component>]]? )",
|
|
529
|
+
"hsl-component": "h|s|l|alpha",
|
|
530
|
+
"legacy-hsl-syntax": "hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsl( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
531
|
+
"modern-hsl-syntax": "hsl( from <color> [<hue>|<percentage>|<number>|<hsl-component>|none] [<percentage>|<number>|<hsl-component>|none] [<percentage>|<number>|<hsl-component>|none] [/ [<alpha-value>|<hsl-component>|none]]? )",
|
|
532
|
+
"legacy-hsla-syntax": "hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsla( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
533
|
+
"modern-hsla-syntax": "hsla( from <color> [<hue>|<percentage>|<number>|<hsl-component>|none] [<percentage>|<number>|<hsl-component>|none] [<percentage>|<number>|<hsl-component>|none] [/ [<alpha-value>|<hsl-component>|none]]? )",
|
|
534
|
+
"hwb-component": "h|w|b",
|
|
535
|
+
"legacy-hwb-syntax": "hwb( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
536
|
+
"modern-hwb-syntax": "hwb( from <color> [<hue>|<percentage>|<number>|<hwb-component>|none] [<percentage>|<number>|<hwb-component>|none] [<percentage>|<number>|<hwb-component>|none] [/ [<alpha-value>|<hwb-component>|none]]? )",
|
|
537
|
+
"lab-component": "l|a|b|alpha",
|
|
538
|
+
"legacy-lab-syntax": "lab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
539
|
+
"modern-lab-syntax": "lab( from <color> [<number>|<percentage>|<lab-component>]{3} [/ [<alpha-value>|<lab-component>]]? )",
|
|
540
|
+
"legacy-oklab-syntax": "oklab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
541
|
+
"modern-oklab-syntax": "oklab( from <color> [<number>|<percentage>|<lab-component>]{3} [/ [<alpha-value>|<lab-component>]]? )",
|
|
542
|
+
"lch-component": "l|c|h|alpha",
|
|
543
|
+
"legacy-lch-syntax": "lch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )",
|
|
544
|
+
"modern-lch-syntax": "lch( from <color> [<number>|<percentage>|<lch-component>]{3} [/ [<alpha-value>|<lch-component>]]? )",
|
|
545
|
+
"legacy-oklch-syntax": "oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )",
|
|
546
|
+
"modern-oklch-syntax": "oklch( from <color> [<number>|<percentage>|<lch-component>]{3} [/ [<alpha-value>|<lch-component>]]? )",
|
|
524
547
|
"xyz-space": "xyz|xyz-d50|xyz-d65",
|
|
525
548
|
"style-condition": "not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]",
|
|
526
549
|
"-non-standard-display": "-ms-inline-flexbox|-ms-grid|-ms-inline-grid|-webkit-flex|-webkit-inline-flex|-webkit-box|-webkit-inline-box|-moz-inline-stack|-moz-box|-moz-inline-box",
|
package/dist/data.js
CHANGED
|
@@ -233,12 +233,12 @@ export default {
|
|
|
233
233
|
"grayscale()": "grayscale( [<number>|<percentage>]? )",
|
|
234
234
|
"grid-line": "auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]",
|
|
235
235
|
"historical-lig-values": "[historical-ligatures|no-historical-ligatures]",
|
|
236
|
-
"hsl()": "
|
|
237
|
-
"hsla()": "
|
|
236
|
+
"hsl()": "<legacy-hsl-syntax>|<modern-hsl-syntax>",
|
|
237
|
+
"hsla()": "<legacy-hsla-syntax>|<modern-hsla-syntax>",
|
|
238
238
|
"hue": "<number>|<angle>",
|
|
239
239
|
"hue-interpolation-method": "[shorter|longer|increasing|decreasing] hue",
|
|
240
240
|
"hue-rotate()": "hue-rotate( [<angle>|<zero>]? )",
|
|
241
|
-
"hwb()": "hwb
|
|
241
|
+
"hwb()": "<legacy-hwb-syntax>|<modern-hwb-syntax>",
|
|
242
242
|
"hypot()": "hypot( <calc-sum># )",
|
|
243
243
|
"image": "<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>",
|
|
244
244
|
"image()": "image( <image-tags>? [<image-src>? , <color>?]! )",
|
|
@@ -252,10 +252,10 @@ export default {
|
|
|
252
252
|
"keyframe-block": "<keyframe-selector># { <declaration-list> }",
|
|
253
253
|
"keyframe-selector": "from|to|<percentage [0,100]>|<timeline-range-name> <percentage>",
|
|
254
254
|
"keyframes-name": "<custom-ident>|<string>",
|
|
255
|
-
"lab()": "lab
|
|
255
|
+
"lab()": "<legacy-lab-syntax>|<modern-lab-syntax>",
|
|
256
256
|
"layer()": "layer( <layer-name> )",
|
|
257
257
|
"layer-name": "<ident> ['.' <ident>]*",
|
|
258
|
-
"lch()": "lch
|
|
258
|
+
"lch()": "<legacy-lch-syntax>|<modern-lch-syntax>",
|
|
259
259
|
"leader()": "leader( <leader-type> )",
|
|
260
260
|
"leader-type": "dotted|solid|space|<string>",
|
|
261
261
|
"length-percentage": "<length>|<percentage>",
|
|
@@ -310,8 +310,8 @@ export default {
|
|
|
310
310
|
"numeric-fraction-values": "[diagonal-fractions|stacked-fractions]",
|
|
311
311
|
"numeric-spacing-values": "[proportional-nums|tabular-nums]",
|
|
312
312
|
"offset-path": "<ray()>|<url>|<basic-shape>",
|
|
313
|
-
"oklab()": "oklab
|
|
314
|
-
"oklch()": "oklch
|
|
313
|
+
"oklab()": "<legacy-oklab-syntax>|<modern-oklab-syntax>",
|
|
314
|
+
"oklch()": "<legacy-oklch-syntax>|<modern-oklch-syntax>",
|
|
315
315
|
"opacity()": "opacity( [<number>|<percentage>]? )",
|
|
316
316
|
"opacity-value": "<number>|<percentage>",
|
|
317
317
|
"outline-line-style": "none|dotted|dashed|solid|double|groove|ridge|inset|outset",
|
|
@@ -361,8 +361,8 @@ export default {
|
|
|
361
361
|
"repeating-linear-gradient()": "repeating-linear-gradient( [<linear-gradient-syntax>] )",
|
|
362
362
|
"repeating-radial-gradient()": "repeating-radial-gradient( [<radial-gradient-syntax>] )",
|
|
363
363
|
"reversed-counter-name": "reversed( <counter-name> )",
|
|
364
|
-
"rgb()": "
|
|
365
|
-
"rgba()": "
|
|
364
|
+
"rgb()": "<legacy-rgb-syntax>|<modern-rgb-syntax>",
|
|
365
|
+
"rgba()": "<legacy-rgba-syntax>|<modern-rgba-syntax>",
|
|
366
366
|
"rotate()": "rotate( [<angle>|<zero>] )",
|
|
367
367
|
"rotate3d()": "rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )",
|
|
368
368
|
"rotateX()": "rotateX( [<angle>|<zero>] )",
|
|
@@ -521,6 +521,29 @@ export default {
|
|
|
521
521
|
"url-modifier": "<ident>|<function-token> <any-value> )",
|
|
522
522
|
"number-zero-one": "<number [0,1]>",
|
|
523
523
|
"number-one-or-greater": "<number [1,∞]>",
|
|
524
|
+
"rgb-component": "r|g|b|alpha",
|
|
525
|
+
"legacy-rgb-syntax": "rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )|rgb( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )",
|
|
526
|
+
"modern-rgb-syntax": "rgb( from <color> [<number>|<percentage>|<rgb-component>]{3} [/ [<alpha-value>|<rgb-component>]]? )",
|
|
527
|
+
"legacy-rgba-syntax": "rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )|rgba( [<number>|<percentage>|none]{3} [/ [<alpha-value>|none]]? )",
|
|
528
|
+
"modern-rgba-syntax": "rgba( from <color> [<number>|<percentage>|<rgb-component>]{3} [/ [<alpha-value>|<rgb-component>]]? )",
|
|
529
|
+
"hsl-component": "h|s|l|alpha",
|
|
530
|
+
"legacy-hsl-syntax": "hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsl( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
531
|
+
"modern-hsl-syntax": "hsl( from <color> [<hue>|<percentage>|<number>|<hsl-component>|none] [<percentage>|<number>|<hsl-component>|none] [<percentage>|<number>|<hsl-component>|none] [/ [<alpha-value>|<hsl-component>|none]]? )",
|
|
532
|
+
"legacy-hsla-syntax": "hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )|hsla( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
533
|
+
"modern-hsla-syntax": "hsla( from <color> [<hue>|<percentage>|<number>|<hsl-component>|none] [<percentage>|<number>|<hsl-component>|none] [<percentage>|<number>|<hsl-component>|none] [/ [<alpha-value>|<hsl-component>|none]]? )",
|
|
534
|
+
"hwb-component": "h|w|b",
|
|
535
|
+
"legacy-hwb-syntax": "hwb( [<hue>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
536
|
+
"modern-hwb-syntax": "hwb( from <color> [<hue>|<percentage>|<number>|<hwb-component>|none] [<percentage>|<number>|<hwb-component>|none] [<percentage>|<number>|<hwb-component>|none] [/ [<alpha-value>|<hwb-component>|none]]? )",
|
|
537
|
+
"lab-component": "l|a|b|alpha",
|
|
538
|
+
"legacy-lab-syntax": "lab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
539
|
+
"modern-lab-syntax": "lab( from <color> [<number>|<percentage>|<lab-component>]{3} [/ [<alpha-value>|<lab-component>]]? )",
|
|
540
|
+
"legacy-oklab-syntax": "oklab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )",
|
|
541
|
+
"modern-oklab-syntax": "oklab( from <color> [<number>|<percentage>|<lab-component>]{3} [/ [<alpha-value>|<lab-component>]]? )",
|
|
542
|
+
"lch-component": "l|c|h|alpha",
|
|
543
|
+
"legacy-lch-syntax": "lch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )",
|
|
544
|
+
"modern-lch-syntax": "lch( from <color> [<number>|<percentage>|<lch-component>]{3} [/ [<alpha-value>|<lch-component>]]? )",
|
|
545
|
+
"legacy-oklch-syntax": "oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )",
|
|
546
|
+
"modern-oklch-syntax": "oklch( from <color> [<number>|<percentage>|<lch-component>]{3} [/ [<alpha-value>|<lch-component>]]? )",
|
|
524
547
|
"xyz-space": "xyz|xyz-d50|xyz-d65",
|
|
525
548
|
"style-condition": "not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]",
|
|
526
549
|
"-non-standard-display": "-ms-inline-flexbox|-ms-grid|-ms-inline-grid|-webkit-flex|-webkit-inline-flex|-webkit-box|-webkit-inline-box|-moz-inline-stack|-moz-box|-moz-inline-box",
|
package/dist/version.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = "3.6.
|
|
1
|
+
module.exports = "3.6.7";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "3.6.
|
|
1
|
+
export const version = "3.6.7";
|
package/lib/syntax/node/Block.js
CHANGED
|
@@ -66,8 +66,31 @@ function isElementSelectorStart() {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function isSelectorStart() {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
// Check for Delim tokens that might be selector starts
|
|
70
|
+
if (this.tokenType === Delim && selectorStarts.has(this.source.charCodeAt(this.tokenStart))) {
|
|
71
|
+
const code = this.source.charCodeAt(this.tokenStart);
|
|
72
|
+
|
|
73
|
+
// Special case: browser hack prefixes (*, +, &) followed immediately by an ident
|
|
74
|
+
// (no whitespace) are declarations, not selectors. Examples: *zoom: 1; +width: 100px; &prop: value;
|
|
75
|
+
if (code === STAR || code === PLUSSIGN || code === AMPERSAND) {
|
|
76
|
+
const nextToken = this.lookupType(1);
|
|
77
|
+
const nextTokenNonSC = this.lookupTypeNonSC(1);
|
|
78
|
+
|
|
79
|
+
// If next token is Ident and there's no whitespace between, it's a declaration
|
|
80
|
+
if (nextToken === Ident && nextTokenNonSC === Ident) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Hash can be either a Hash token (#id selector) or Delim(#) + Ident (browser hack)
|
|
88
|
+
// When it's a Hash token, it's a selector. When it's Delim, check if followed by Ident without whitespace
|
|
89
|
+
if (this.tokenType === Hash) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return this.tokenType === LeftSquareBracket ||
|
|
71
94
|
this.tokenType === Colon || isElementSelectorStart.call(this);
|
|
72
95
|
}
|
|
73
96
|
|
|
@@ -2,15 +2,71 @@ import {
|
|
|
2
2
|
WhiteSpace,
|
|
3
3
|
Comment,
|
|
4
4
|
Semicolon,
|
|
5
|
-
AtKeyword
|
|
5
|
+
AtKeyword,
|
|
6
|
+
Delim,
|
|
7
|
+
Hash,
|
|
8
|
+
LeftSquareBracket,
|
|
9
|
+
Colon,
|
|
10
|
+
Ident,
|
|
11
|
+
RightCurlyBracket
|
|
6
12
|
} from '../../tokenizer/index.js';
|
|
7
13
|
|
|
8
14
|
const AMPERSAND = 0x0026; // U+0026 AMPERSAND (&)
|
|
15
|
+
const DOT = 0x002E; // U+002E FULL STOP (.)
|
|
16
|
+
const STAR = 0x002A; // U+002A ASTERISK (*);
|
|
17
|
+
const PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
|
18
|
+
const GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
|
|
19
|
+
const TILDE = 0x007E; // U+007E TILDE (~)
|
|
20
|
+
|
|
21
|
+
const selectorStarts = new Set([
|
|
22
|
+
AMPERSAND,
|
|
23
|
+
DOT,
|
|
24
|
+
STAR,
|
|
25
|
+
PLUSSIGN,
|
|
26
|
+
GREATERTHANSIGN,
|
|
27
|
+
TILDE
|
|
28
|
+
]);
|
|
9
29
|
|
|
10
30
|
function consumeRaw() {
|
|
11
31
|
return this.Raw(this.consumeUntilSemicolonIncluded, true);
|
|
12
32
|
}
|
|
13
33
|
|
|
34
|
+
function isElementSelectorStart() {
|
|
35
|
+
if (this.tokenType !== Ident) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const nextTokenType = this.lookupTypeNonSC(1);
|
|
40
|
+
|
|
41
|
+
// Simple case: if next token is not colon, semicolon, or closing brace, it's likely a selector
|
|
42
|
+
if (nextTokenType !== Colon && nextTokenType !== Semicolon && nextTokenType !== RightCurlyBracket) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Special handling for colon case - could be pseudo-class/pseudo-element
|
|
47
|
+
if (nextTokenType === Colon) {
|
|
48
|
+
// Look ahead further to see what follows the colon
|
|
49
|
+
const afterColonType = this.lookupTypeNonSC(2);
|
|
50
|
+
|
|
51
|
+
// If after colon there's an identifier (pseudo-class/pseudo-element name),
|
|
52
|
+
// check what comes after that
|
|
53
|
+
if (afterColonType === Ident) {
|
|
54
|
+
const afterPseudoType = this.lookupTypeNonSC(3);
|
|
55
|
+
// If it's followed by { or other selector tokens, it's a selector
|
|
56
|
+
// If it's followed by ; or } or EOF, it's not a selector (property)
|
|
57
|
+
return afterPseudoType !== Semicolon && afterPseudoType !== RightCurlyBracket && afterPseudoType !== 0; // 0 is EOF
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isSelectorStart() {
|
|
65
|
+
return this.tokenType === Delim && selectorStarts.has(this.source.charCodeAt(this.tokenStart)) ||
|
|
66
|
+
this.tokenType === Hash || this.tokenType === LeftSquareBracket ||
|
|
67
|
+
this.tokenType === Colon || isElementSelectorStart.call(this);
|
|
68
|
+
}
|
|
69
|
+
|
|
14
70
|
export const name = 'DeclarationList';
|
|
15
71
|
export const structure = {
|
|
16
72
|
children: [[
|
|
@@ -37,7 +93,7 @@ export function parse() {
|
|
|
37
93
|
break;
|
|
38
94
|
|
|
39
95
|
default:
|
|
40
|
-
if (
|
|
96
|
+
if (isSelectorStart.call(this)) {
|
|
41
97
|
children.push(this.parseWithFallback(this.Rule, consumeRaw));
|
|
42
98
|
} else {
|
|
43
99
|
children.push(this.parseWithFallback(this.Declaration, consumeRaw));
|
|
@@ -9,6 +9,20 @@ function eatIdentifierOrAsterisk() {
|
|
|
9
9
|
this.error('Identifier or asterisk is expected');
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// Check if asterisk is followed immediately by an ident (no whitespace)
|
|
13
|
+
// This is invalid in selectors (e.g., "*foo" should error, "* foo" or "*:hover" is ok)
|
|
14
|
+
if (this.isDelim(ASTERISK)) {
|
|
15
|
+
const currentTokenEnd = this.tokenStart + 1; // asterisk is 1 char
|
|
16
|
+
this.next();
|
|
17
|
+
|
|
18
|
+
// If next token is an ident and starts immediately after asterisk, it's an error
|
|
19
|
+
if (this.tokenType === Ident && this.tokenStart === currentTokenEnd) {
|
|
20
|
+
this.error('Whitespace is required between universal selector and type selector');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
12
26
|
this.next();
|
|
13
27
|
}
|
|
14
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint/css-tree",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.7",
|
|
4
4
|
"description": "A tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations",
|
|
5
5
|
"author": "Roman Dvornov <rdvornov@gmail.com> (https://github.com/lahmatiy)",
|
|
6
6
|
"license": "MIT",
|