@tbela99/css-parser 0.5.3 → 0.5.4

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.
@@ -7201,11 +7201,17 @@
7201
7201
  const rule = ast.chi[i];
7202
7202
  if (!rule.sel.includes('&')) {
7203
7203
  const selRule = splitRule(rule.sel);
7204
- selRule.forEach(arr => combinators.includes(arr[0].charAt(0)) ? arr.unshift(ast.sel) : arr.unshift(ast.sel, ' '));
7205
- rule.sel = selRule.reduce((acc, curr) => {
7206
- acc.push(curr.join(''));
7207
- return acc;
7208
- }, []).join(',');
7204
+ if (selRule.length > 1) {
7205
+ const r = ':is(' + selRule.map(a => a.join('')).join(',') + ')';
7206
+ rule.sel = splitRule(ast.sel).reduce((a, b) => a.concat([b.join('') + r]), []).join(',');
7207
+ }
7208
+ else {
7209
+ selRule.forEach(arr => combinators.includes(arr[0].charAt(0)) ? arr.unshift(ast.sel) : arr.unshift(ast.sel, ' '));
7210
+ rule.sel = selRule.reduce((acc, curr) => {
7211
+ acc.push(curr.join(''));
7212
+ return acc;
7213
+ }, []).join(',');
7214
+ }
7209
7215
  }
7210
7216
  else {
7211
7217
  rule.sel = replaceCompound(rule.sel, ast.sel);
package/dist/index.cjs CHANGED
@@ -7199,11 +7199,17 @@ function expandRule(node) {
7199
7199
  const rule = ast.chi[i];
7200
7200
  if (!rule.sel.includes('&')) {
7201
7201
  const selRule = splitRule(rule.sel);
7202
- selRule.forEach(arr => combinators.includes(arr[0].charAt(0)) ? arr.unshift(ast.sel) : arr.unshift(ast.sel, ' '));
7203
- rule.sel = selRule.reduce((acc, curr) => {
7204
- acc.push(curr.join(''));
7205
- return acc;
7206
- }, []).join(',');
7202
+ if (selRule.length > 1) {
7203
+ const r = ':is(' + selRule.map(a => a.join('')).join(',') + ')';
7204
+ rule.sel = splitRule(ast.sel).reduce((a, b) => a.concat([b.join('') + r]), []).join(',');
7205
+ }
7206
+ else {
7207
+ selRule.forEach(arr => combinators.includes(arr[0].charAt(0)) ? arr.unshift(ast.sel) : arr.unshift(ast.sel, ' '));
7208
+ rule.sel = selRule.reduce((acc, curr) => {
7209
+ acc.push(curr.join(''));
7210
+ return acc;
7211
+ }, []).join(',');
7212
+ }
7207
7213
  }
7208
7214
  else {
7209
7215
  rule.sel = replaceCompound(rule.sel, ast.sel);
@@ -58,11 +58,17 @@ function expandRule(node) {
58
58
  const rule = ast.chi[i];
59
59
  if (!rule.sel.includes('&')) {
60
60
  const selRule = splitRule(rule.sel);
61
- selRule.forEach(arr => combinators.includes(arr[0].charAt(0)) ? arr.unshift(ast.sel) : arr.unshift(ast.sel, ' '));
62
- rule.sel = selRule.reduce((acc, curr) => {
63
- acc.push(curr.join(''));
64
- return acc;
65
- }, []).join(',');
61
+ if (selRule.length > 1) {
62
+ const r = ':is(' + selRule.map(a => a.join('')).join(',') + ')';
63
+ rule.sel = splitRule(ast.sel).reduce((a, b) => a.concat([b.join('') + r]), []).join(',');
64
+ }
65
+ else {
66
+ selRule.forEach(arr => combinators.includes(arr[0].charAt(0)) ? arr.unshift(ast.sel) : arr.unshift(ast.sel, ' '));
67
+ rule.sel = selRule.reduce((acc, curr) => {
68
+ acc.push(curr.join(''));
69
+ return acc;
70
+ }, []).join(',');
71
+ }
66
72
  }
67
73
  else {
68
74
  rule.sel = replaceCompound(rule.sel, ast.sel);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tbela99/css-parser",
3
3
  "description": "CSS parser for node and the browser",
4
- "version": "0.5.3",
4
+ "version": "0.5.4",
5
5
  "exports": {
6
6
  ".": "./dist/node/index.js",
7
7
  "./umd": "./dist/index-umd-web.js",
package/syntax.md DELETED
@@ -1,62 +0,0 @@
1
-
2
- - postfix (+|?|*)
3
-
4
- - Expression
5
- - Statement
6
- - Literals
7
- - Unary Expression
8
- - Binary Expressions
9
- - Parentheses
10
-
11
- Grammar
12
-
13
- ```text
14
- expression → literal
15
- | unary
16
- | binary
17
- | grouping ;
18
-
19
- literal → NUMBER | STRING | "true" | "false" | "nil" ;
20
- grouping → "(" expression ")" ;
21
- unary → ( "-" | "!" ) expression ;
22
- binary → expression operator expression ;
23
- operator → "==" | "!=" | "<" | "<=" | ">" | ">=" | "+" | "-" | "*" | "/" ;
24
- ```
25
-
26
- Syntax tree
27
-
28
- ```text
29
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Value_definition_syntax#question_mark
30
-
31
- syntax: "keyword | <'property'> | <function>"
32
- syntax: "<angle> | [ [ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards"
33
- syntax: "none | [ [<dashed-ident> || <try-tactic>] | inset-area( <'inset-area'> ) ]#"
34
- syntax: "snapInterval( <percentage>, <percentage> ) | snapList( <percentage># )"
35
- syntax: "[ center | [ [ left | right | x-start | x-end ]? <length-percentage>? ]! ]#"
36
- syntax: "<outline-radius>{1,4} [ / <outline-radius>{1,4} ]?
37
- syntax: "[ [ <url> [ <x> <y> ]? , ]* [ auto | default | none | context-menu | help | pointer | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop | not-allowed | e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | all-scroll | zoom-in | zoom-out | grab | grabbing ] ]"
38
- syntax: "[ [ <'font-style'> || <font-variant-css21> || <'font-weight'> || <'font-stretch'> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'> ] | caption | icon | menu | message-box | small-caption | status-bar"
39
- syntax: "false | true"
40
- ```
41
-
42
- ||: at least one option must appear in any order each component appears at most once. example border property <'border-width'> || <'border-style'> || <'border-color'>
43
-
44
- |: exclusive options. at least one must be present
45
-
46
- &&: tokens appear in any order
47
-
48
- juxtaposition: space separated and exact order
49
-
50
- *: postfix. the entity appears 0 or many times
51
-
52
- +: postfix. apppears at least once.
53
-
54
- {a,b}: postfix. appears at least A, at most B.
55
-
56
- #: postfix, repeated one or more times, separated by comma ','
57
-
58
- !: postfix. the group is required and must produce at least one value.
59
-
60
-
61
- | -> []
62
- | -> []