@lezer/css 1.1.6 → 1.1.8

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.1.8 (2024-02-19)
2
+
3
+ ### Bug fixes
4
+
5
+ Follow the standard, allowing digits in unit identifiers.
6
+
7
+ ## 1.1.7 (2024-01-08)
8
+
9
+ ### Bug fixes
10
+
11
+ Correctly parse properties with a space before the colon.
12
+
1
13
  ## 1.1.6 (2024-01-01)
2
14
 
3
15
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -47,7 +47,8 @@ const descendant = new lr.ExternalTokenizer(input => {
47
47
  if (space.includes(input.peek(-1))) {
48
48
  let {next} = input;
49
49
  if (isAlpha(next) || next == underscore || next == hash || next == period ||
50
- next == bracketL || next == colon || next == dash || next == ampersand)
50
+ next == bracketL || next == colon && isAlpha(input.peek(1)) ||
51
+ next == dash || next == ampersand)
51
52
  input.acceptToken(descendantOp);
52
53
  }
53
54
  });
@@ -57,7 +58,7 @@ const unitToken = new lr.ExternalTokenizer(input => {
57
58
  let {next} = input;
58
59
  if (next == percent) { input.advance(); input.acceptToken(Unit); }
59
60
  if (isAlpha(next)) {
60
- do { input.advance(); } while (isAlpha(input.next))
61
+ do { input.advance(); } while (isAlpha(input.next) || isDigit(input.next))
61
62
  input.acceptToken(Unit);
62
63
  }
63
64
  }
package/dist/index.js CHANGED
@@ -43,7 +43,8 @@ const descendant = new ExternalTokenizer(input => {
43
43
  if (space.includes(input.peek(-1))) {
44
44
  let {next} = input;
45
45
  if (isAlpha(next) || next == underscore || next == hash || next == period ||
46
- next == bracketL || next == colon || next == dash || next == ampersand)
46
+ next == bracketL || next == colon && isAlpha(input.peek(1)) ||
47
+ next == dash || next == ampersand)
47
48
  input.acceptToken(descendantOp);
48
49
  }
49
50
  });
@@ -53,7 +54,7 @@ const unitToken = new ExternalTokenizer(input => {
53
54
  let {next} = input;
54
55
  if (next == percent) { input.advance(); input.acceptToken(Unit); }
55
56
  if (isAlpha(next)) {
56
- do { input.advance(); } while (isAlpha(input.next))
57
+ do { input.advance(); } while (isAlpha(input.next) || isDigit(input.next))
57
58
  input.acceptToken(Unit);
58
59
  }
59
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lezer/css",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "lezer-based CSS grammar",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",
package/src/.tern-port ADDED
@@ -0,0 +1 @@
1
+ 43121
@@ -10,12 +10,14 @@ export const
10
10
  RuleSet = 5,
11
11
  UniversalSelector = 6,
12
12
  NestingSelector = 9,
13
+ PseudoClassName = 16,
13
14
  ColorLiteral = 22,
14
15
  NumberLiteral = 23,
15
16
  StringLiteral = 24,
16
17
  BinOp = 26,
17
18
  CallExpression = 27,
18
19
  CallLiteral = 29,
20
+ CallTag = 30,
19
21
  ParenthesizedContent = 31,
20
22
  MatchOp = 44,
21
23
  ChildOp = 46,
@@ -25,13 +27,21 @@ export const
25
27
  Important = 55,
26
28
  ImportStatement = 57,
27
29
  AtKeyword = 58,
30
+ _import = 59,
28
31
  LogicOp = 64,
32
+ UnaryQueryOp = 66,
33
+ selector = 69,
29
34
  MediaStatement = 70,
35
+ media = 71,
30
36
  CharsetStatement = 72,
37
+ charset = 73,
31
38
  NamespaceStatement = 74,
39
+ namespace = 75,
32
40
  KeyframesStatement = 77,
41
+ keyframes = 78,
33
42
  KeyframeList = 80,
34
43
  KeyframeSelector = 81,
35
44
  SupportsStatement = 83,
45
+ supports = 84,
36
46
  AtRule = 85,
37
47
  Styles = 86
package/src/tokens.js CHANGED
@@ -36,7 +36,8 @@ export const descendant = new ExternalTokenizer(input => {
36
36
  if (space.includes(input.peek(-1))) {
37
37
  let {next} = input
38
38
  if (isAlpha(next) || next == underscore || next == hash || next == period ||
39
- next == bracketL || next == colon || next == dash || next == ampersand)
39
+ next == bracketL || next == colon && isAlpha(input.peek(1)) ||
40
+ next == dash || next == ampersand)
40
41
  input.acceptToken(descendantOp)
41
42
  }
42
43
  })
@@ -46,7 +47,7 @@ export const unitToken = new ExternalTokenizer(input => {
46
47
  let {next} = input
47
48
  if (next == percent) { input.advance(); input.acceptToken(Unit) }
48
49
  if (isAlpha(next)) {
49
- do { input.advance() } while (isAlpha(input.next))
50
+ do { input.advance() } while (isAlpha(input.next) || isDigit(input.next))
50
51
  input.acceptToken(Unit)
51
52
  }
52
53
  }
@@ -142,3 +142,19 @@ foo {
142
142
  StyleSheet(RuleSet(TagSelector(TagName),Block(
143
143
  Declaration(VariableName,ValueName),
144
144
  Declaration(PropertyName,CallExpression(Callee,ArgList(VariableName))))))
145
+
146
+ # Space before colon
147
+
148
+ div {
149
+ color : red;
150
+ .x :active {
151
+ color : blue;
152
+ }
153
+ }
154
+
155
+ ==>
156
+
157
+ StyleSheet(RuleSet(TagSelector(TagName),Block(
158
+ Declaration(PropertyName,ValueName),
159
+ RuleSet(DescendantSelector(ClassSelector(ClassName),PseudoClassSelector(PseudoClassName)),Block(
160
+ Declaration(PropertyName,ValueName))))))