@tbela99/css-parser 0.5.2 → 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.
@@ -1481,7 +1481,7 @@
1481
1481
  return val / 4.5;
1482
1482
  }
1483
1483
  return sign * (Math.pow((abs + α - 1) / α, 1 / 0.45));
1484
- }).concat(a == null || a == 1 ? [] : [a]);
1484
+ }).concat([] );
1485
1485
  }
1486
1486
  function lrec20202rec2020(r, g, b, a) {
1487
1487
  // convert an array of linear-light rec2020 RGB in the range 0.0-1.0
@@ -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);
@@ -7264,7 +7270,8 @@
7264
7270
  for (const t of walkValues(tokens)) {
7265
7271
  if (t.value.typ == exports.EnumToken.LiteralTokenType) {
7266
7272
  if (t.value.val == '&') {
7267
- t.value.val = replace;
7273
+ const rule = splitRule(replace);
7274
+ t.value.val = rule.length > 1 ? ':is(' + replace + ')' : replace;
7268
7275
  }
7269
7276
  else if (t.value.val.length > 1 && t.value.val.charAt(0) == '&') {
7270
7277
  t.value.val = replaceCompoundLiteral(t.value.val, replace);
package/dist/index.cjs CHANGED
@@ -1479,7 +1479,7 @@ function rec20202lrec2020(r, g, b, a) {
1479
1479
  return val / 4.5;
1480
1480
  }
1481
1481
  return sign * (Math.pow((abs + α - 1) / α, 1 / 0.45));
1482
- }).concat(a == null || a == 1 ? [] : [a]);
1482
+ }).concat([] );
1483
1483
  }
1484
1484
  function lrec20202rec2020(r, g, b, a) {
1485
1485
  // convert an array of linear-light rec2020 RGB in the range 0.0-1.0
@@ -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);
@@ -7262,7 +7268,8 @@ function replaceCompound(input, replace) {
7262
7268
  for (const t of walkValues(tokens)) {
7263
7269
  if (t.value.typ == exports.EnumToken.LiteralTokenType) {
7264
7270
  if (t.value.val == '&') {
7265
- t.value.val = replace;
7271
+ const rule = splitRule(replace);
7272
+ t.value.val = rule.length > 1 ? ':is(' + replace + ')' : replace;
7266
7273
  }
7267
7274
  else if (t.value.val.length > 1 && t.value.val.charAt(0) == '&') {
7268
7275
  t.value.val = replaceCompoundLiteral(t.value.val, replace);
@@ -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);
@@ -121,7 +127,8 @@ function replaceCompound(input, replace) {
121
127
  for (const t of walkValues(tokens)) {
122
128
  if (t.value.typ == EnumToken.LiteralTokenType) {
123
129
  if (t.value.val == '&') {
124
- t.value.val = replace;
130
+ const rule = splitRule(replace);
131
+ t.value.val = rule.length > 1 ? ':is(' + replace + ')' : replace;
125
132
  }
126
133
  else if (t.value.val.length > 1 && t.value.val.charAt(0) == '&') {
127
134
  t.value.val = replaceCompoundLiteral(t.value.val, replace);
@@ -28,7 +28,7 @@ function rec20202lrec2020(r, g, b, a) {
28
28
  return val / 4.5;
29
29
  }
30
30
  return sign * (Math.pow((abs + α - 1) / α, 1 / 0.45));
31
- }).concat(a == null || a == 1 ? [] : [a]);
31
+ }).concat([] );
32
32
  }
33
33
  function lrec20202rec2020(r, g, b, a) {
34
34
  // convert an array of linear-light rec2020 RGB in the range 0.0-1.0
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.2",
4
+ "version": "0.5.4",
5
5
  "exports": {
6
6
  ".": "./dist/node/index.js",
7
7
  "./umd": "./dist/index-umd-web.js",