@eslint/css-tree 3.6.7 → 3.6.9

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/dist/data.cjs CHANGED
@@ -143,7 +143,7 @@ module.exports = {
143
143
  "color": "<color-base>|currentColor|<system-color>|<device-cmyk()>|<light-dark()>|<-non-standard-color>",
144
144
  "color()": "color( <colorspace-params> [/ [<alpha-value>|none]]? )",
145
145
  "color-base": "<hex-color>|<color-function>|<named-color>|<color-mix()>|transparent",
146
- "color-function": "<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<color()>",
146
+ "color-function": "<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<alpha()>|<color()>",
147
147
  "color-interpolation-method": "in [<rectangular-color-space>|<polar-color-space> <hue-interpolation-method>?|<custom-color-space>]",
148
148
  "color-mix()": "color-mix( <color-interpolation-method> , [<color>&&<percentage [0,100]>?]#{2} )",
149
149
  "color-stop": "<color-stop-length>|<color-stop-angle>",
@@ -544,6 +544,7 @@ module.exports = {
544
544
  "modern-lch-syntax": "lch( from <color> [<number>|<percentage>|<lch-component>]{3} [/ [<alpha-value>|<lch-component>]]? )",
545
545
  "legacy-oklch-syntax": "oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )",
546
546
  "modern-oklch-syntax": "oklch( from <color> [<number>|<percentage>|<lch-component>]{3} [/ [<alpha-value>|<lch-component>]]? )",
547
+ "alpha()": "alpha( [from <color>] [/ [<alpha-value>|none]]? )",
547
548
  "xyz-space": "xyz|xyz-d50|xyz-d65",
548
549
  "style-condition": "not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]",
549
550
  "-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
@@ -143,7 +143,7 @@ export default {
143
143
  "color": "<color-base>|currentColor|<system-color>|<device-cmyk()>|<light-dark()>|<-non-standard-color>",
144
144
  "color()": "color( <colorspace-params> [/ [<alpha-value>|none]]? )",
145
145
  "color-base": "<hex-color>|<color-function>|<named-color>|<color-mix()>|transparent",
146
- "color-function": "<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<color()>",
146
+ "color-function": "<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<oklab()>|<oklch()>|<alpha()>|<color()>",
147
147
  "color-interpolation-method": "in [<rectangular-color-space>|<polar-color-space> <hue-interpolation-method>?|<custom-color-space>]",
148
148
  "color-mix()": "color-mix( <color-interpolation-method> , [<color>&&<percentage [0,100]>?]#{2} )",
149
149
  "color-stop": "<color-stop-length>|<color-stop-angle>",
@@ -544,6 +544,7 @@ export default {
544
544
  "modern-lch-syntax": "lch( from <color> [<number>|<percentage>|<lch-component>]{3} [/ [<alpha-value>|<lch-component>]]? )",
545
545
  "legacy-oklch-syntax": "oklch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )",
546
546
  "modern-oklch-syntax": "oklch( from <color> [<number>|<percentage>|<lch-component>]{3} [/ [<alpha-value>|<lch-component>]]? )",
547
+ "alpha()": "alpha( [from <color>] [/ [<alpha-value>|none]]? )",
547
548
  "xyz-space": "xyz|xyz-d50|xyz-d65",
548
549
  "style-condition": "not <style-in-parens>|<style-in-parens> [[and <style-in-parens>]*|[or <style-in-parens>]*]",
549
550
  "-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.7";
1
+ module.exports = "3.6.9";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "3.6.7";
1
+ export const version = "3.6.9";
@@ -5,8 +5,8 @@ export default {
5
5
  this.LayerList()
6
6
  );
7
7
  },
8
- block() {
9
- return this.Block(false);
8
+ block(nested = false, { allowNestedRules = false } = {}) {
9
+ return this.Block(nested, { allowNestedRules });
10
10
  }
11
11
  }
12
12
  };
@@ -6,6 +6,7 @@ import {
6
6
  Hash,
7
7
  Colon,
8
8
  Ident,
9
+ Function,
9
10
  AtKeyword,
10
11
  LeftSquareBracket,
11
12
  LeftCurlyBracket,
@@ -58,10 +59,50 @@ function isElementSelectorStart() {
58
59
 
59
60
  const nextTokenType = this.lookupTypeNonSC(1);
60
61
 
62
+ // If next token is not colon, semicolon, or right curly bracket, it's likely a selector
61
63
  if (nextTokenType !== Colon && nextTokenType !== Semicolon && nextTokenType !== RightCurlyBracket) {
62
64
  return true;
63
65
  }
64
66
 
67
+ // If next token is colon, we need to look further ahead to distinguish
68
+ // between property declarations (p: value) and pseudo-class selectors (p:hover)
69
+ if (nextTokenType === Colon) {
70
+ // Look for the token after the colon (skipping whitespace)
71
+ const tokenAfterColon = this.lookupTypeNonSC(2);
72
+
73
+ // If it's an identifier (like 'hover', 'first-of-type') or function (like 'nth-child()', 'not()'),
74
+ // this could be a pseudo-class
75
+ if (tokenAfterColon === Ident || tokenAfterColon === Function) {
76
+ // Look further ahead to see if there's a left curly bracket
77
+ // which would indicate this is a selector with a block
78
+ let offset = 3;
79
+ let tokenType;
80
+
81
+ // Skip whitespace and look for either a left curly bracket or other tokens
82
+ while (offset <= 15) { // Increased limit to handle function pseudo-classes
83
+ tokenType = this.lookupType(offset);
84
+
85
+ if (tokenType === LeftCurlyBracket) {
86
+ // Found opening brace, this is definitely a selector
87
+ return true;
88
+ } else if (tokenType === Semicolon || tokenType === RightCurlyBracket) {
89
+ // Found semicolon or closing brace before opening brace, likely a property
90
+ return false;
91
+ } else if (tokenType === WhiteSpace || tokenType === Comment) {
92
+ // Skip whitespace and comments
93
+ offset++;
94
+ continue;
95
+ } else {
96
+ // Other tokens might indicate more complex selectors, continue looking
97
+ offset++;
98
+ }
99
+ }
100
+ }
101
+
102
+ // If we can't determine conclusively, default to property behavior
103
+ return false;
104
+ }
105
+
65
106
  return false;
66
107
  }
67
108
 
@@ -8,7 +8,9 @@ import {
8
8
  LeftSquareBracket,
9
9
  Colon,
10
10
  Ident,
11
- RightCurlyBracket
11
+ RightCurlyBracket,
12
+ LeftCurlyBracket,
13
+ Comma
12
14
  } from '../../tokenizer/index.js';
13
15
 
14
16
  const AMPERSAND = 0x0026; // U+0026 AMPERSAND (&)
@@ -38,12 +40,17 @@ function isElementSelectorStart() {
38
40
 
39
41
  const nextTokenType = this.lookupTypeNonSC(1);
40
42
 
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
+ // If next token is a left curly bracket, it's definitely a selector (e.g., "div { ... }")
44
+ if (nextTokenType === LeftCurlyBracket) {
43
45
  return true;
44
46
  }
45
47
 
46
- // Special handling for colon case - could be pseudo-class/pseudo-element
48
+ // If next token is semicolon, comma, or closing brace, it's definitely a declaration
49
+ if (nextTokenType === Semicolon || nextTokenType === Comma || nextTokenType === RightCurlyBracket) {
50
+ return false;
51
+ }
52
+
53
+ // Special handling for colon case - could be pseudo-class/pseudo-element or property
47
54
  if (nextTokenType === Colon) {
48
55
  // Look ahead further to see what follows the colon
49
56
  const afterColonType = this.lookupTypeNonSC(2);
@@ -52,12 +59,19 @@ function isElementSelectorStart() {
52
59
  // check what comes after that
53
60
  if (afterColonType === Ident) {
54
61
  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
62
+ // If it's followed by {, it's definitely a selector (e.g., "div:hover { ... }")
63
+ if (afterPseudoType === LeftCurlyBracket) {
64
+ return true;
65
+ }
66
+ // Otherwise, it's a property (e.g., "transition: opacity 1s")
67
+ return false;
58
68
  }
69
+ // If after colon there's not an identifier, it's a property
70
+ return false;
59
71
  }
60
72
 
73
+ // For other token types (dimensions, numbers, strings, etc.), assume it's a declaration
74
+ // This handles cases like multi-value properties
61
75
  return false;
62
76
  }
63
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint/css-tree",
3
- "version": "3.6.7",
3
+ "version": "3.6.9",
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",