@tbela99/css-parser 1.2.0 → 1.3.1

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +29 -11
  3. package/dist/index-umd-web.js +2041 -1967
  4. package/dist/index.cjs +2129 -1964
  5. package/dist/index.d.ts +1936 -77
  6. package/dist/lib/ast/expand.js +4 -65
  7. package/dist/lib/ast/features/calc.js +3 -27
  8. package/dist/lib/ast/features/inlinecssvariables.js +2 -21
  9. package/dist/lib/ast/features/prefix.js +2 -1
  10. package/dist/lib/ast/features/transform.js +4 -3
  11. package/dist/lib/ast/features/type.js +9 -0
  12. package/dist/lib/ast/math/expression.js +26 -149
  13. package/dist/lib/ast/math/math.js +9 -9
  14. package/dist/lib/ast/minify.js +82 -171
  15. package/dist/lib/ast/transform/compute.js +4 -37
  16. package/dist/lib/ast/transform/matrix.js +33 -34
  17. package/dist/lib/ast/transform/minify.js +32 -51
  18. package/dist/lib/ast/transform/perspective.js +1 -1
  19. package/dist/lib/ast/transform/rotate.js +13 -13
  20. package/dist/lib/ast/transform/scale.js +8 -8
  21. package/dist/lib/ast/transform/skew.js +4 -4
  22. package/dist/lib/ast/transform/translate.js +8 -8
  23. package/dist/lib/ast/transform/utils.js +31 -39
  24. package/dist/lib/ast/types.js +459 -5
  25. package/dist/lib/ast/walk.js +18 -0
  26. package/dist/lib/fs/resolve.js +11 -3
  27. package/dist/lib/parser/declaration/map.js +1 -0
  28. package/dist/lib/parser/declaration/set.js +2 -2
  29. package/dist/lib/parser/parse.js +139 -32
  30. package/dist/lib/parser/tokenize.js +41 -93
  31. package/dist/lib/parser/utils/type.js +1 -1
  32. package/dist/lib/renderer/render.js +61 -30
  33. package/dist/lib/renderer/sourcemap/sourcemap.js +34 -0
  34. package/dist/lib/syntax/color/cmyk.js +2 -2
  35. package/dist/lib/syntax/color/color-mix.js +11 -12
  36. package/dist/lib/syntax/color/color.js +14 -7
  37. package/dist/lib/syntax/color/hsl.js +4 -4
  38. package/dist/lib/syntax/color/hwb.js +27 -8
  39. package/dist/lib/syntax/color/lab.js +4 -4
  40. package/dist/lib/syntax/color/lch.js +4 -4
  41. package/dist/lib/syntax/color/oklab.js +4 -4
  42. package/dist/lib/syntax/color/oklch.js +4 -4
  43. package/dist/lib/syntax/color/relativecolor.js +1 -1
  44. package/dist/lib/syntax/color/rgb.js +4 -4
  45. package/dist/lib/syntax/color/utils/components.js +15 -3
  46. package/dist/lib/syntax/color/utils/distance.js +15 -1
  47. package/dist/lib/syntax/syntax.js +18 -17
  48. package/dist/lib/syntax/utils.js +1 -1
  49. package/dist/lib/validation/at-rules/document.js +1 -1
  50. package/dist/lib/validation/at-rules/import.js +4 -4
  51. package/dist/lib/validation/at-rules/keyframes.js +0 -11
  52. package/dist/lib/validation/at-rules/supports.js +6 -6
  53. package/dist/lib/validation/config.js +0 -4
  54. package/dist/lib/validation/config.json.js +33 -30
  55. package/dist/lib/validation/parser/parse.js +0 -8
  56. package/dist/lib/validation/selector.js +0 -9
  57. package/dist/lib/validation/syntax.js +17 -135
  58. package/dist/lib/validation/syntaxes/complex-selector-list.js +0 -11
  59. package/dist/lib/validation/syntaxes/family-name.js +0 -32
  60. package/dist/lib/validation/syntaxes/keyframe-selector.js +0 -11
  61. package/dist/lib/validation/syntaxes/relative-selector-list.js +0 -26
  62. package/dist/lib/validation/syntaxes/url.js +0 -33
  63. package/dist/lib/validation/utils/list.js +0 -8
  64. package/dist/node.js +229 -0
  65. package/dist/web.js +158 -0
  66. package/package.json +14 -11
  67. package/dist/node/index.js +0 -57
  68. package/dist/node/load.js +0 -20
  69. package/dist/web/index.js +0 -66
  70. package/dist/web/load.js +0 -31
@@ -21,6 +21,11 @@ const dimensionUnits = new Set([
21
21
  const fontFormat = ['collection', 'embedded-opentype', 'opentype', 'svg', 'truetype', 'woff', 'woff2'];
22
22
  const colorFontTech = ['color-colrv0', 'color-colrv1', 'color-svg', 'color-sbix', 'color-cbdt'];
23
23
  const fontFeaturesTech = ['features-opentype', 'features-aat', 'features-graphite', 'incremental-patch', 'incremental-range', 'incremental-auto', 'variations', 'palettes'];
24
+ /**
25
+ * supported transform functions
26
+ *
27
+ * @internal
28
+ */
24
29
  const transformFunctions = [
25
30
  'translate', 'scale', 'rotate', 'skew', 'perspective',
26
31
  'translateX', 'translateY', 'translateZ',
@@ -34,6 +39,11 @@ const mediaTypes = ['all', 'print', 'screen',
34
39
  /* deprecated */
35
40
  'aural', 'braille', 'embossed', 'handheld', 'projection', 'tty', 'tv', 'speech'];
36
41
  // https://www.w3.org/TR/css-values-4/#math-function
42
+ /**
43
+ * supported math functions
44
+ *
45
+ * @internal
46
+ */
37
47
  const mathFuncs = ['minmax', 'repeat', 'fit-content', 'calc', 'clamp', 'min', 'max', 'round', 'mod', 'rem', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'atan2', 'pow', 'sqrt', 'hypot', 'log', 'exp', 'abs', 'sign'];
38
48
  const wildCardFuncs = ['var', 'env'];
39
49
  const pseudoElements = [':before', ':after', ':first-line', ':first-letter'];
@@ -499,18 +509,18 @@ function isPolarColorspace(token) {
499
509
  }
500
510
  function isHueInterpolationMethod(token) {
501
511
  if (!Array.isArray(token)) {
502
- return token.typ == EnumToken.IdenTokenType && 'hue'.localeCompare(token.val, undefined, { sensitivity: 'base' }) == 0;
512
+ return token.typ == EnumToken.IdenTokenType && 'hue' === token.val?.toLowerCase?.();
503
513
  }
504
514
  if (token.length != 2 || token[0].typ != EnumToken.IdenTokenType || token[1].typ != EnumToken.IdenTokenType) {
505
515
  return false;
506
516
  }
507
- return ['shorter', 'longer', 'increasing', 'decreasing'].includes(token[0].val) && 'hue'.localeCompare(token[1].val, undefined, { sensitivity: 'base' }) == 0;
517
+ return ['shorter', 'longer', 'increasing', 'decreasing'].includes(token[0].val?.toLowerCase?.()) && 'hue' === token[1].val?.toLowerCase?.();
508
518
  }
509
519
  function isIdentColor(token) {
510
520
  return token.typ == EnumToken.ColorTokenType && [ColorType.SYS, ColorType.DPSYS, ColorType.LIT].includes(token.kin) && isIdent(token.val);
511
521
  }
512
522
  function isPercentageToken(token) {
513
- return token.typ == EnumToken.PercentageTokenType || (token.typ == EnumToken.NumberTokenType && token.val == '0');
523
+ return token.typ == EnumToken.PercentageTokenType || (token.typ == EnumToken.NumberTokenType && token.val == 0);
514
524
  }
515
525
  function isColor(token) {
516
526
  if (token.typ == EnumToken.ColorTokenType) {
@@ -621,7 +631,7 @@ function isColor(token) {
621
631
  if (children.length == 3) {
622
632
  if (children[0].length > 4 ||
623
633
  children[0][0].typ != EnumToken.IdenTokenType ||
624
- 'in'.localeCompare(children[0][0].val, undefined, { sensitivity: 'base' }) != 0 ||
634
+ 'in' !== children[0][0].val?.toLowerCase?.() ||
625
635
  !isColorspace(children[0][1]) ||
626
636
  (children[0].length >= 3 && !isHueInterpolationMethod(children[0].slice(2))) ||
627
637
  children[1].length > 2 ||
@@ -633,12 +643,12 @@ function isColor(token) {
633
643
  return false;
634
644
  }
635
645
  if (children[1].length == 2) {
636
- if (!(children[1][1].typ == EnumToken.PercentageTokenType || (children[1][1].typ == EnumToken.NumberTokenType && children[1][1].val == '0'))) {
646
+ if (!(children[1][1].typ == EnumToken.PercentageTokenType || (children[1][1].typ == EnumToken.NumberTokenType && children[1][1].val == 0))) {
637
647
  return false;
638
648
  }
639
649
  }
640
650
  if (children[2].length == 2) {
641
- if (!(children[2][1].typ == EnumToken.PercentageTokenType || (children[2][1].typ == EnumToken.NumberTokenType && children[2][1].val == '0'))) {
651
+ if (!(children[2][1].typ == EnumToken.PercentageTokenType || (children[2][1].typ == EnumToken.NumberTokenType && children[2][1].val == 0))) {
642
652
  return false;
643
653
  }
644
654
  }
@@ -782,15 +792,6 @@ function isIdent(name) {
782
792
  }
783
793
  return true;
784
794
  }
785
- function isNonPrintable(codepoint) {
786
- // null -> backspace
787
- return (codepoint >= 0 && codepoint <= 0x8) ||
788
- // tab
789
- codepoint == 0xb ||
790
- // delete
791
- codepoint == 0x7f ||
792
- (codepoint >= 0xe && codepoint <= 0x1f);
793
- }
794
795
  function isPseudo(name) {
795
796
  return name.charAt(0) == ':' &&
796
797
  ((name.endsWith('(') && isIdent(name.charAt(1) == ':' ? name.slice(2, -1) : name.slice(1, -1))) ||
@@ -897,7 +898,7 @@ function parseDimension(name) {
897
898
  }
898
899
  const dimension = {
899
900
  typ: EnumToken.DimensionTokenType,
900
- val: name.slice(0, index),
901
+ val: +name.slice(0, index),
901
902
  unit: name.slice(index)
902
903
  };
903
904
  if (isAngle(dimension)) {
@@ -957,4 +958,4 @@ function isWhiteSpace(codepoint) {
957
958
  codepoint == 0xa || codepoint == 0xc || codepoint == 0xd;
958
959
  }
959
960
 
960
- export { colorFontTech, fontFeaturesTech, fontFormat, isAngle, isAtKeyword, isColor, isColorspace, isDigit, isDimension, isFlex, isFrequency, isFunction, isHash, isHexColor, isHueInterpolationMethod, isIdent, isIdentCodepoint, isIdentColor, isIdentStart, isLength, isNewLine, isNonPrintable, isNumber, isPercentage, isPercentageToken, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolution, isTime, isWhiteSpace, mathFuncs, mediaTypes, mozExtensions, parseColor, parseDimension, pseudoAliasMap, pseudoElements, transformFunctions, webkitExtensions, wildCardFuncs };
961
+ export { colorFontTech, fontFeaturesTech, fontFormat, isAngle, isAtKeyword, isColor, isColorspace, isDigit, isDimension, isFlex, isFrequency, isFunction, isHash, isHexColor, isHueInterpolationMethod, isIdent, isIdentCodepoint, isIdentColor, isIdentStart, isLength, isNewLine, isNumber, isPercentage, isPercentageToken, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolution, isTime, isWhiteSpace, mathFuncs, mediaTypes, mozExtensions, parseColor, parseDimension, pseudoAliasMap, pseudoElements, transformFunctions, webkitExtensions, wildCardFuncs };
@@ -50,7 +50,7 @@ function length2Px(value) {
50
50
  * @param val
51
51
  */
52
52
  function minifyNumber(val) {
53
- val = String(+val);
53
+ val = String(val);
54
54
  if (val === '0') {
55
55
  return '0';
56
56
  }
@@ -45,7 +45,7 @@ function validateAtRuleDocument(atRule, options, root) {
45
45
  };
46
46
  }
47
47
  // @ts-ignore
48
- if ((t[0].typ != EnumToken.FunctionTokenType && t[0].typ != EnumToken.UrlFunctionTokenType) || !['url', 'url-prefix', 'domain', 'media-document', 'regexp'].some((f) => f.localeCompare(t[0].val, undefined, { sensitivity: 'base' }) == 0)) {
48
+ if ((t[0].typ != EnumToken.FunctionTokenType && t[0].typ != EnumToken.UrlFunctionTokenType) || !['url', 'url-prefix', 'domain', 'media-document', 'regexp'].includes(t[0].val?.toLowerCase?.())) {
49
49
  return {
50
50
  valid: SyntaxValidationResult.Drop,
51
51
  context: [],
@@ -94,8 +94,7 @@ function validateAtRuleImport(atRule, options, root) {
94
94
  if (tokens.length > 0) {
95
95
  // @ts-ignore
96
96
  if (tokens[0].typ == EnumToken.IdenTokenType) {
97
- // @ts-ignore
98
- if ('layer'.localeCompare(tokens[0].val, undefined, { sensitivity: 'base' }) == 0) {
97
+ if ('layer' === tokens[0].val.toLowerCase()) {
99
98
  tokens.shift();
100
99
  // @ts-ignore
101
100
  if (!consumeWhitespace(tokens)) {
@@ -113,7 +112,7 @@ function validateAtRuleImport(atRule, options, root) {
113
112
  // @ts-ignore
114
113
  else if (tokens[0].typ == EnumToken.FunctionTokenType) {
115
114
  // @ts-ignore
116
- if ('layer'.localeCompare(tokens[0].val, undefined, { sensitivity: 'base' }) == 0) {
115
+ if ('layer' === tokens[0].val.toLowerCase()) {
117
116
  const result = validateLayerName(tokens[0].chi);
118
117
  if (result.valid == SyntaxValidationResult.Drop) {
119
118
  return result;
@@ -122,8 +121,9 @@ function validateAtRuleImport(atRule, options, root) {
122
121
  // @ts-ignore
123
122
  consumeWhitespace(tokens);
124
123
  }
124
+ // tokens[0]?.val
125
125
  // @ts-ignore
126
- if ('supports'.localeCompare(tokens[0]?.val, undefined, { sensitivity: 'base' }) == 0) {
126
+ if ('supports' === tokens[0]?.val?.toLowerCase?.()) {
127
127
  const result = validateAtRuleSupportsConditions(atRule, tokens[0].chi);
128
128
  if (result.valid == SyntaxValidationResult.Drop) {
129
129
  return result;
@@ -21,17 +21,6 @@ function validateAtRuleKeyframes(atRule, options, root) {
21
21
  }
22
22
  const tokens = atRule.tokens.filter((t) => t.typ != EnumToken.CommentTokenType).slice();
23
23
  consumeWhitespace(tokens);
24
- // if (tokens.length == 0) {
25
- //
26
- // // @ts-ignore
27
- // return {
28
- // valid: SyntaxValidationResult.Drop,
29
- // context: [],
30
- // node: atRule,
31
- // syntax: '@keyframes',
32
- // error: 'expecting at-rule prelude'
33
- // } as ValidationSyntaxResult;
34
- // }
35
24
  if (tokens.length == 0 || ![EnumToken.StringTokenType, EnumToken.IdenTokenType].includes(tokens[0].typ)) {
36
25
  // @ts-ignore
37
26
  return {
@@ -166,7 +166,7 @@ function validateSupportCondition(atRule, token) {
166
166
  if (token.typ == EnumToken.MediaFeatureNotTokenType) {
167
167
  return validateSupportCondition(atRule, token.val);
168
168
  }
169
- if (token.typ == EnumToken.FunctionTokenType && token.val.localeCompare('selector', undefined, { sensitivity: 'base' }) == 0) {
169
+ if (token.typ == EnumToken.FunctionTokenType && 'selector' === token.val.toLowerCase()) {
170
170
  return {
171
171
  valid: SyntaxValidationResult.Valid,
172
172
  context: [],
@@ -223,7 +223,7 @@ function validateSupportFeature(token) {
223
223
  return validateSupportFeature(token.val);
224
224
  }
225
225
  if (token.typ == EnumToken.FunctionTokenType) {
226
- if (token.val.localeCompare('selector', undefined, { sensitivity: 'base' }) == 0) {
226
+ if ('selector' === token.val.toLowerCase()) {
227
227
  return {
228
228
  valid: SyntaxValidationResult.Valid,
229
229
  context: [],
@@ -232,10 +232,10 @@ function validateSupportFeature(token) {
232
232
  error: ''
233
233
  };
234
234
  }
235
- if (token.val.localeCompare('font-tech', undefined, { sensitivity: 'base' }) == 0) {
235
+ if ('font-tech' === token.val.toLowerCase()) {
236
236
  const chi = token.chi.filter((t) => ![EnumToken.WhitespaceTokenType, EnumToken.CommentTokenType].includes(t.typ));
237
237
  // @ts-ignore
238
- return chi.length == 1 && chi[0].typ == EnumToken.IdenTokenType && colorFontTech.concat(fontFeaturesTech).some((t) => t.localeCompare(chi[0].val, undefined, { sensitivity: 'base' }) == 0) ?
238
+ return chi.length == 1 && chi[0].typ == EnumToken.IdenTokenType && colorFontTech.concat(fontFeaturesTech).includes(chi[0].val.toLowerCase()) ?
239
239
  {
240
240
  valid: SyntaxValidationResult.Valid,
241
241
  context: [],
@@ -251,10 +251,10 @@ function validateSupportFeature(token) {
251
251
  error: 'expected font-tech'
252
252
  };
253
253
  }
254
- if (token.val.localeCompare('font-format', undefined, { sensitivity: 'base' }) == 0) {
254
+ if ('font-format' === token.val.toLowerCase()) {
255
255
  const chi = token.chi.filter((t) => ![EnumToken.WhitespaceTokenType, EnumToken.CommentTokenType].includes(t.typ));
256
256
  // @ts-ignore
257
- return chi.length == 1 && chi[0].typ == EnumToken.IdenTokenType && fontFormat.some((t) => t.localeCompare(chi[0].val, undefined, { sensitivity: 'base' }) == 0) ?
257
+ return chi.length == 1 && chi[0].typ == EnumToken.IdenTokenType && fontFormat.includes(chi[0].val, toLowerCase()) ?
258
258
  {
259
259
  valid: SyntaxValidationResult.Valid,
260
260
  context: [],
@@ -21,10 +21,6 @@ function getSyntax(group, key) {
21
21
  key = matches[1] + matches[3];
22
22
  }
23
23
  }
24
- // if (!(key in obj)) {
25
- //
26
- // return null;
27
- // }
28
24
  }
29
25
  // @ts-ignore
30
26
  obj = obj[key];
@@ -303,10 +303,10 @@ var declarations = {
303
303
  syntax: "normal | <baseline-position> | <content-distribution> | <overflow-position>? <content-position>"
304
304
  },
305
305
  "align-items": {
306
- syntax: "normal | stretch | <baseline-position> | [ <overflow-position>? <self-position> ]"
306
+ syntax: "normal | stretch | <baseline-position> | [ <overflow-position>? <self-position> ] | anchor-center"
307
307
  },
308
308
  "align-self": {
309
- syntax: "auto | normal | stretch | <baseline-position> | <overflow-position>? <self-position>"
309
+ syntax: "auto | normal | stretch | <baseline-position> | <overflow-position>? <self-position> | anchor-center"
310
310
  },
311
311
  "align-tracks": {
312
312
  syntax: "[ normal | <baseline-position> | <content-distribution> | <overflow-position>? <content-position> ]#"
@@ -366,7 +366,7 @@ var declarations = {
366
366
  syntax: "<easing-function>#"
367
367
  },
368
368
  appearance: {
369
- syntax: "none | auto | textfield | menulist-button | <compat-auto>"
369
+ syntax: "none | auto | <compat-auto> | <compat-special>"
370
370
  },
371
371
  "aspect-ratio": {
372
372
  syntax: "auto || <ratio>"
@@ -378,7 +378,7 @@ var declarations = {
378
378
  syntax: "visible | hidden"
379
379
  },
380
380
  background: {
381
- syntax: "[ <bg-layer> , ]* <final-bg-layer>"
381
+ syntax: "<bg-layer>#? , <final-bg-layer>"
382
382
  },
383
383
  "background-attachment": {
384
384
  syntax: "<attachment>#"
@@ -465,10 +465,10 @@ var declarations = {
465
465
  syntax: "<'border-top-color'>"
466
466
  },
467
467
  "border-bottom-left-radius": {
468
- syntax: "<length-percentage>{1,2}"
468
+ syntax: "<length-percentage [0,∞]>{1,2}"
469
469
  },
470
470
  "border-bottom-right-radius": {
471
- syntax: "<length-percentage>{1,2}"
471
+ syntax: "<length-percentage [0,∞]>{1,2}"
472
472
  },
473
473
  "border-bottom-style": {
474
474
  syntax: "<line-style>"
@@ -477,7 +477,7 @@ var declarations = {
477
477
  syntax: "<line-width>"
478
478
  },
479
479
  "border-collapse": {
480
- syntax: "collapse | separate"
480
+ syntax: "separate | collapse"
481
481
  },
482
482
  "border-color": {
483
483
  syntax: "<color>{1,4}"
@@ -492,19 +492,19 @@ var declarations = {
492
492
  syntax: "<'border-image-source'> || <'border-image-slice'> [ / <'border-image-width'> | / <'border-image-width'>? / <'border-image-outset'> ]? || <'border-image-repeat'>"
493
493
  },
494
494
  "border-image-outset": {
495
- syntax: "[ <length> | <number> ]{1,4}"
495
+ syntax: "[ <length [0,∞]> | <number [0,∞]> ]{1,4} "
496
496
  },
497
497
  "border-image-repeat": {
498
498
  syntax: "[ stretch | repeat | round | space ]{1,2}"
499
499
  },
500
500
  "border-image-slice": {
501
- syntax: "<number-percentage>{1,4} && fill?"
501
+ syntax: "[ <number [0,∞]> | <percentage [0,∞]> ]{1,4} && fill?"
502
502
  },
503
503
  "border-image-source": {
504
504
  syntax: "none | <image>"
505
505
  },
506
506
  "border-image-width": {
507
- syntax: "[ <length-percentage> | <number> | auto ]{1,4}"
507
+ syntax: "[ <length-percentage [0,∞]> | <number [0,∞]> | auto ]{1,4}"
508
508
  },
509
509
  "border-inline": {
510
510
  syntax: "<'border-block-start'>"
@@ -555,7 +555,7 @@ var declarations = {
555
555
  syntax: "<line-width>"
556
556
  },
557
557
  "border-radius": {
558
- syntax: "<length-percentage>{1,4} [ / <length-percentage>{1,4} ]?"
558
+ syntax: "<length-percentage [0,∞]>{1,4} [ / <length-percentage [0,∞]>{1,4} ]?"
559
559
  },
560
560
  "border-right": {
561
561
  syntax: "<line-width> || <line-style> || <color>"
@@ -570,7 +570,7 @@ var declarations = {
570
570
  syntax: "<line-width>"
571
571
  },
572
572
  "border-spacing": {
573
- syntax: "<length> <length>?"
573
+ syntax: "<length>{1,2}"
574
574
  },
575
575
  "border-start-end-radius": {
576
576
  syntax: "<'border-top-left-radius'>"
@@ -588,10 +588,10 @@ var declarations = {
588
588
  syntax: "<color>"
589
589
  },
590
590
  "border-top-left-radius": {
591
- syntax: "<length-percentage>{1,2}"
591
+ syntax: "<length-percentage [0,∞]>{1,2}"
592
592
  },
593
593
  "border-top-right-radius": {
594
- syntax: "<length-percentage>{1,2}"
594
+ syntax: "<length-percentage [0,∞]>{1,2}"
595
595
  },
596
596
  "border-top-style": {
597
597
  syntax: "<line-style>"
@@ -603,7 +603,7 @@ var declarations = {
603
603
  syntax: "<line-width>{1,4}"
604
604
  },
605
605
  bottom: {
606
- syntax: "<length> | <percentage> | auto"
606
+ syntax: "auto | <length-percentage> | <anchor()> | <anchor-size()>"
607
607
  },
608
608
  "box-align": {
609
609
  syntax: "start | center | end | baseline | stretch"
@@ -738,7 +738,7 @@ var declarations = {
738
738
  syntax: "normal | [ [ size | inline-size ] || scroll-state ]"
739
739
  },
740
740
  content: {
741
- syntax: "normal | none | [ <content-replacement> | <content-list> ] [/ [ <string> | <counter> ]+ ]?"
741
+ syntax: "normal | none | [ <content-replacement> | <content-list> ] [ / [ <string> | <counter> | <attr()> ]+ ]?"
742
742
  },
743
743
  "content-visibility": {
744
744
  syntax: "visible | auto | hidden"
@@ -1032,16 +1032,16 @@ var declarations = {
1032
1032
  syntax: "normal | <content-distribution> | <overflow-position>? [ <content-position> | left | right ]"
1033
1033
  },
1034
1034
  "justify-items": {
1035
- syntax: "normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ] | legacy | legacy && [ left | right | center ]"
1035
+ syntax: "normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ] | legacy | legacy && [ left | right | center ] | anchor-center"
1036
1036
  },
1037
1037
  "justify-self": {
1038
- syntax: "auto | normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ]"
1038
+ syntax: "auto | normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ] | anchor-center"
1039
1039
  },
1040
1040
  "justify-tracks": {
1041
1041
  syntax: "[ normal | <content-distribution> | <overflow-position>? [ <content-position> | left | right ] ]#"
1042
1042
  },
1043
1043
  left: {
1044
- syntax: "<length> | <percentage> | auto"
1044
+ syntax: "auto | <length-percentage> | <anchor()> | <anchor-size()>"
1045
1045
  },
1046
1046
  "letter-spacing": {
1047
1047
  syntax: "normal | <length> normal | <length-percentage>"
@@ -1086,7 +1086,7 @@ var declarations = {
1086
1086
  syntax: "<'margin-top'>"
1087
1087
  },
1088
1088
  "margin-bottom": {
1089
- syntax: "<length-percentage> | auto"
1089
+ syntax: "<length-percentage> | auto | <anchor-size()>"
1090
1090
  },
1091
1091
  "margin-inline": {
1092
1092
  syntax: "<'margin-top'>{1,2}"
@@ -1098,13 +1098,13 @@ var declarations = {
1098
1098
  syntax: "<'margin-top'>"
1099
1099
  },
1100
1100
  "margin-left": {
1101
- syntax: "<length-percentage> | auto"
1101
+ syntax: "<length-percentage> | auto | <anchor-size()>"
1102
1102
  },
1103
1103
  "margin-right": {
1104
- syntax: "<length-percentage> | auto"
1104
+ syntax: "<length-percentage> | auto | <anchor-size()>"
1105
1105
  },
1106
1106
  "margin-top": {
1107
- syntax: "<length-percentage> | auto"
1107
+ syntax: "<length-percentage> | auto | <anchor-size()>"
1108
1108
  },
1109
1109
  "margin-trim": {
1110
1110
  syntax: "none | in-flow | all"
@@ -1212,7 +1212,7 @@ var declarations = {
1212
1212
  syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
1213
1213
  },
1214
1214
  "mix-blend-mode": {
1215
- syntax: "<blend-mode> | plus-lighter"
1215
+ syntax: "<blend-mode> | plus-darker | plus-lighter"
1216
1216
  },
1217
1217
  "object-fit": {
1218
1218
  syntax: "fill | contain | cover | none | scale-down"
@@ -1410,7 +1410,7 @@ var declarations = {
1410
1410
  syntax: "none | both | horizontal | vertical | block | inline"
1411
1411
  },
1412
1412
  right: {
1413
- syntax: "<length> | <percentage> | auto"
1413
+ syntax: "auto | <length-percentage> | <anchor()> | <anchor-size()>"
1414
1414
  },
1415
1415
  rotate: {
1416
1416
  syntax: "none | <angle> | [ x | y | z | <number>{3} ] && <angle>"
@@ -1710,7 +1710,7 @@ var declarations = {
1710
1710
  syntax: "none | <dashed-ident>#"
1711
1711
  },
1712
1712
  top: {
1713
- syntax: "<length> | <percentage> | auto"
1713
+ syntax: "auto | <length-percentage> | <anchor()> | <anchor-size()>"
1714
1714
  },
1715
1715
  "touch-action": {
1716
1716
  syntax: "auto | none | [ [ pan-x | pan-left | pan-right ] || [ pan-y | pan-up | pan-down ] || pinch-zoom ] | manipulation"
@@ -2389,7 +2389,7 @@ var syntaxes = {
2389
2389
  syntax: "<visual-box> | border-area | text"
2390
2390
  },
2391
2391
  "bg-image": {
2392
- syntax: "none | <image>"
2392
+ syntax: "<image> | none"
2393
2393
  },
2394
2394
  "bg-layer": {
2395
2395
  syntax: "<bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <visual-box> || <visual-box>"
@@ -2398,7 +2398,7 @@ var syntaxes = {
2398
2398
  syntax: "[ [ left | center | right | top | bottom | <length-percentage> ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ] | [ center | [ left | right ] <length-percentage>? ] && [ center | [ top | bottom ] <length-percentage>? ] ]"
2399
2399
  },
2400
2400
  "bg-size": {
2401
- syntax: "[ <length-percentage> | auto ]{1,2} | cover | contain"
2401
+ syntax: "[ <length-percentage [0,∞]> | auto ]{1,2} | cover | contain"
2402
2402
  },
2403
2403
  "blend-mode": {
2404
2404
  syntax: "normal | multiply | screen | overlay | darken | lighten | color-dodge | color-burn | hard-light | soft-light | difference | exclusion | hue | saturation | color | luminosity"
@@ -2488,7 +2488,10 @@ var syntaxes = {
2488
2488
  syntax: "[ common-ligatures | no-common-ligatures ]"
2489
2489
  },
2490
2490
  "compat-auto": {
2491
- syntax: "searchfield | textarea | push-button | slider-horizontal | checkbox | radio | square-button | menulist | listbox | meter | progress-bar | button"
2491
+ syntax: "searchfield | textarea | checkbox | radio | menulist | listbox | meter | progress-bar | button"
2492
+ },
2493
+ "compat-special": {
2494
+ syntax: "textfield | menulist-button"
2492
2495
  },
2493
2496
  "complex-selector": {
2494
2497
  syntax: "<complex-selector-unit> [ <combinator>? <complex-selector-unit> ]*"
@@ -2668,7 +2671,7 @@ var syntaxes = {
2668
2671
  syntax: "[ <filter-function> | <url> ]+"
2669
2672
  },
2670
2673
  "final-bg-layer": {
2671
- syntax: "<'background-color'> || <bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <visual-box> || <visual-box>"
2674
+ syntax: "<bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <visual-box> || <visual-box> || <'background-color'>"
2672
2675
  },
2673
2676
  "fit-content()": {
2674
2677
  syntax: "fit-content( <length-percentage [0,∞]> )"
@@ -175,7 +175,6 @@ function parseSyntax(syntax) {
175
175
  typ: ValidationTokenEnum.Root,
176
176
  chi: []
177
177
  }, 'pos', { ...objectProperties, value: { ind: 0, lin: 1, col: 0 } });
178
- // return minify(doParseSyntax(syntaxes, tokenize(syntaxes), root)) as ValidationRootToken;
179
178
  return minify(doParseSyntax(syntax, tokenize(syntax), root));
180
179
  }
181
180
  function matchParens(syntax, iterator) {
@@ -351,10 +350,6 @@ function matchAtRule(syntax, iterator) {
351
350
  token.typ = ValidationTokenEnum.AtRule;
352
351
  break;
353
352
  }
354
- // if (item.value.typ != ValidationTokenEnum.Whitespace) {
355
- //
356
- // console.error('unexpected token', item.value);
357
- // }
358
353
  item = iterator.next();
359
354
  if (item.done) {
360
355
  break;
@@ -971,9 +966,6 @@ function renderSyntax(token, parent) {
971
966
  return '{' + token.chi.reduce((acc, t) => acc + renderSyntax(t), '') + '}';
972
967
  case ValidationTokenEnum.DeclarationDefinitionToken:
973
968
  return token.nam + ': ' + renderSyntax(token.val);
974
- // case ValidationTokenEnum.ColumnArrayToken:
975
- //
976
- // return (token as ValidationColumnArrayToken).chi.reduce((acc: string, curr: ValidationToken) => acc + (acc.trim().length > 0 ? '||' : '') + renderSyntax(curr), '');
977
969
  default:
978
970
  throw new Error('Unhandled token: ' + JSON.stringify({ token }, null, 1));
979
971
  }
@@ -13,15 +13,6 @@ import './config.js';
13
13
  import { validateSelectorList } from './syntaxes/selector-list.js';
14
14
 
15
15
  function validateSelector(selector, options, root) {
16
- // if (root == null) {
17
- //
18
- // return validateSelectorList(selector, root, options);
19
- // }
20
- // @ts-ignore
21
- // if (root.typ == EnumToken.AtRuleNodeType && root.nam.match(/^(-[a-z]+-)?keyframes$/)) {
22
- //
23
- // return validateKeyframeBlockList(selector, root as AstAtRule, options);
24
- // }
25
16
  let isNested = root.typ == EnumToken.RuleNodeType ? 1 : 0;
26
17
  let currentRoot = root.parent;
27
18
  while (currentRoot != null && isNested == 0) {