cssstyle 4.4.0 → 4.5.0

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.
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // autogenerated - 2025-06-08
2
+ // autogenerated - 2025-06-20
3
3
  // https://www.w3.org/Style/CSS/all-properties.en.html
4
4
 
5
5
  module.exports = new Set([
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // autogenerated - 2025-06-08
2
+ // autogenerated - 2025-06-20
3
3
  // https://www.w3.org/Style/CSS/all-properties.en.html
4
4
 
5
5
  var external_dependency_parsers_0 = require("../parsers.js");
@@ -18,7 +18,7 @@ backgroundImage_export_definition = {
18
18
  v = external_dependency_parsers_0.prepareValue(v, this._global);
19
19
  if (external_dependency_parsers_0.hasVarFunc(v)) {
20
20
  this._setProperty("background", "");
21
- this._setProperty("backgound-image", v);
21
+ this._setProperty("background-image", v);
22
22
  } else {
23
23
  this._setProperty("background-image", backgroundImage_export_parse(v));
24
24
  }
@@ -65,7 +65,7 @@ backgroundPosition_export_definition = {
65
65
  v = external_dependency_parsers_0.prepareValue(v, this._global);
66
66
  if (external_dependency_parsers_0.hasVarFunc(v)) {
67
67
  this._setProperty("background", "");
68
- this._setProperty("backgound-position", v);
68
+ this._setProperty("background-position", v);
69
69
  } else {
70
70
  this._setProperty("background-position", backgroundPosition_export_parse(v));
71
71
  }
@@ -92,7 +92,7 @@ backgroundRepeat_export_definition = {
92
92
  v = external_dependency_parsers_0.prepareValue(v, this._global);
93
93
  if (external_dependency_parsers_0.hasVarFunc(v)) {
94
94
  this._setProperty("background", "");
95
- this._setProperty("backgound-repeat", v);
95
+ this._setProperty("background-repeat", v);
96
96
  } else {
97
97
  this._setProperty("background-repeat", backgroundRepeat_export_parse(v));
98
98
  }
@@ -119,7 +119,7 @@ backgroundAttachment_export_definition = {
119
119
  v = external_dependency_parsers_0.prepareValue(v, this._global);
120
120
  if (external_dependency_parsers_0.hasVarFunc(v)) {
121
121
  this._setProperty("background", "");
122
- this._setProperty("backgound-attachemnt", v);
122
+ this._setProperty("background-attachment", v);
123
123
  } else {
124
124
  this._setProperty("background-attachment", backgroundAttachment_export_parse(v));
125
125
  }
@@ -149,7 +149,7 @@ backgroundColor_export_definition = {
149
149
  v = external_dependency_parsers_0.prepareValue(v, this._global);
150
150
  if (external_dependency_parsers_0.hasVarFunc(v)) {
151
151
  this._setProperty("background", "");
152
- this._setProperty("backgound-color", v);
152
+ this._setProperty("background-color", v);
153
153
  } else {
154
154
  this._setProperty("background-color", backgroundColor_export_parse(v));
155
155
  }
@@ -1427,7 +1427,7 @@ fontFamily_export_parse = function parse(v) {
1427
1427
  if (v === "") {
1428
1428
  return v;
1429
1429
  }
1430
- const keywords = ["serif", "sans-serif", "system-ui", "cursive", "fantasy", "monospace"];
1430
+ const keywords = ["serif", "sans-serif", "cursive", "fantasy", "monospace", "system-ui", "math", "ui-serif", "ui-sans-serif", "ui-monospace", "ui-rounded"];
1431
1431
  const val = external_dependency_parsers_0.splitValue(v, {
1432
1432
  delimiter: ","
1433
1433
  });
@@ -1446,16 +1446,15 @@ fontFamily_export_parse = function parse(v) {
1446
1446
  valid = true;
1447
1447
  continue;
1448
1448
  }
1449
- // This implementation does not strictly follow the specification. The spec
1450
- // does not require the first letter of the font-family to be capitalized.
1451
- // Also, unquoted font-family names are not restricted to ASCII only.
1449
+ // This implementation does not strictly follow the specification.
1450
+ // The spec does not require the first letter of the font-family to be
1451
+ // capitalized, and unquoted font-family names are not restricted to ASCII.
1452
1452
  // However, in the real world, the first letter of the ASCII font-family
1453
- // names are always capitalized, and unquoted font-family names do not
1454
- // contain spaces, e.g. `Times`, and AFAIK, non-ASCII font-family names are
1455
- // always quoted even without spaces, e.g. `"メイリオ"`.
1456
- // Therefore, it is unlikely that this implementation will cause problems.
1453
+ // names are capitalized, and unquoted font-family names do not contain
1454
+ // spaces, e.g. `Times`. And non-ASCII font-family names are quoted even
1455
+ // without spaces, e.g. `"メイリオ"`.
1457
1456
  // @see https://drafts.csswg.org/css-fonts/#font-family-prop
1458
- if (/^\s*(?:[A-Z][A-Za-z\d\s-]+)\s*$/.test(i)) {
1457
+ if (i !== "undefined" && /^(?:[A-Z][A-Za-z\d-]+(?:\s+[A-Z][A-Za-z\d-]+)*|-?[a-z][a-z-]+)$/.test(i)) {
1459
1458
  font.push(i.trim());
1460
1459
  valid = true;
1461
1460
  continue;
@@ -1523,50 +1522,138 @@ font_export_parse = function parse(v) {
1523
1522
  const [fontBlock, ...families] = external_dependency_parsers_0.splitValue(v, {
1524
1523
  delimiter: ","
1525
1524
  });
1526
- let blockA, blockB;
1527
- if (fontBlock.includes("/")) {
1528
- [blockA, blockB] = external_dependency_parsers_0.splitValue(fontBlock, {
1529
- delimiter: "/"
1530
- });
1531
- } else {
1532
- blockA = fontBlock.trim();
1533
- }
1534
- const obj = external_dependency_parsers_0.parseShorthand(blockA, font_local_var_shorthandFor, true);
1535
- if (!obj) {
1536
- return;
1537
- }
1538
- const font = {};
1525
+ const [fontBlockA, fontBlockB] = external_dependency_parsers_0.splitValue(fontBlock, {
1526
+ delimiter: "/"
1527
+ });
1528
+ const font = {
1529
+ "font-style": "normal",
1530
+ "font-variant": "normal",
1531
+ "font-weight": "normal"
1532
+ };
1539
1533
  const fontFamilies = new Set();
1540
- for (const [property, value] of Object.entries(obj)) {
1541
- if (property === "font-family") {
1542
- if (!blockB) {
1543
- fontFamilies.add(value);
1544
- }
1545
- } else {
1546
- font[property] = value;
1534
+ if (fontBlockB) {
1535
+ const [lineB, ...familiesB] = fontBlockB.trim().split(" ");
1536
+ if (!lineB || !{
1537
+ parse: lineHeight_export_parse,
1538
+ isValid: lineHeight_export_isValid,
1539
+ definition: lineHeight_export_definition
1540
+ }.isValid(lineB) || !familiesB.length) {
1541
+ return;
1547
1542
  }
1548
- }
1549
- // blockB, if matched, includes line-height and first font-family
1550
- if (blockB) {
1551
- const [lineheight, family] = external_dependency_parsers_0.splitValue(blockB);
1552
- if ({
1543
+ const lineHeightB = {
1553
1544
  parse: lineHeight_export_parse,
1554
1545
  isValid: lineHeight_export_isValid,
1555
1546
  definition: lineHeight_export_definition
1556
- }.isValid(lineheight)) {
1557
- font["line-height"] = {
1558
- parse: lineHeight_export_parse,
1559
- isValid: lineHeight_export_isValid,
1560
- definition: lineHeight_export_definition
1561
- }.parse(lineheight);
1547
+ }.parse(lineB);
1548
+ const familyB = familiesB.join(" ");
1549
+ if ({
1550
+ parse: fontFamily_export_parse,
1551
+ isValid: fontFamily_export_isValid,
1552
+ definition: fontFamily_export_definition
1553
+ }.isValid(familyB)) {
1554
+ fontFamilies.add({
1555
+ parse: fontFamily_export_parse,
1556
+ isValid: fontFamily_export_isValid,
1557
+ definition: fontFamily_export_definition
1558
+ }.parse(familyB));
1562
1559
  } else {
1563
1560
  return;
1564
1561
  }
1565
- if ({
1562
+ const parts = external_dependency_parsers_0.splitValue(fontBlockA.trim());
1563
+ const properties = ["font-style", "font-variant", "font-weight", "font-size"];
1564
+ for (const part of parts) {
1565
+ if (part === "normal") {
1566
+ continue;
1567
+ } else {
1568
+ for (const property of properties) {
1569
+ switch (property) {
1570
+ case "font-style":
1571
+ case "font-variant":
1572
+ case "font-weight":
1573
+ {
1574
+ const value = font_local_var_shorthandFor.get(property);
1575
+ if (value.isValid(part)) {
1576
+ font[property] = value.parse(part);
1577
+ }
1578
+ break;
1579
+ }
1580
+ case "font-size":
1581
+ {
1582
+ const value = font_local_var_shorthandFor.get(property);
1583
+ if (value.isValid(part)) {
1584
+ font[property] = value.parse(part);
1585
+ }
1586
+ break;
1587
+ }
1588
+ default:
1589
+ }
1590
+ }
1591
+ }
1592
+ }
1593
+ if (Object.hasOwn(font, "font-size")) {
1594
+ font["line-height"] = lineHeightB;
1595
+ } else {
1596
+ return;
1597
+ }
1598
+ } else {
1599
+ // FIXME: Switch to toReversed() when we can drop Node.js 18 support.
1600
+ const revParts = [...external_dependency_parsers_0.splitValue(fontBlockA.trim())].reverse();
1601
+ const revFontFamily = [];
1602
+ const properties = ["font-style", "font-variant", "font-weight", "line-height"];
1603
+ font["font-style"] = "normal";
1604
+ font["font-variant"] = "normal";
1605
+ font["font-weight"] = "normal";
1606
+ font["line-height"] = "normal";
1607
+ let fontSizeA;
1608
+ for (const part of revParts) {
1609
+ if (fontSizeA) {
1610
+ if (part === "normal") {
1611
+ continue;
1612
+ } else {
1613
+ for (const property of properties) {
1614
+ switch (property) {
1615
+ case "font-style":
1616
+ case "font-variant":
1617
+ case "font-weight":
1618
+ case "line-height":
1619
+ {
1620
+ const value = font_local_var_shorthandFor.get(property);
1621
+ if (value.isValid(part)) {
1622
+ font[property] = value.parse(part);
1623
+ }
1624
+ break;
1625
+ }
1626
+ default:
1627
+ }
1628
+ }
1629
+ }
1630
+ } else if ({
1631
+ parse: fontSize_export_parse,
1632
+ isValid: fontSize_export_isValid,
1633
+ definition: fontSize_export_definition
1634
+ }.isValid(part)) {
1635
+ fontSizeA = {
1636
+ parse: fontSize_export_parse,
1637
+ isValid: fontSize_export_isValid,
1638
+ definition: fontSize_export_definition
1639
+ }.parse(part);
1640
+ } else if ({
1641
+ parse: fontFamily_export_parse,
1642
+ isValid: fontFamily_export_isValid,
1643
+ definition: fontFamily_export_definition
1644
+ }.isValid(part)) {
1645
+ revFontFamily.push(part);
1646
+ } else {
1647
+ return;
1648
+ }
1649
+ }
1650
+ const family = revFontFamily.reverse().join(" ");
1651
+ if (fontSizeA && {
1566
1652
  parse: fontFamily_export_parse,
1567
1653
  isValid: fontFamily_export_isValid,
1568
1654
  definition: fontFamily_export_definition
1569
1655
  }.isValid(family)) {
1656
+ font["font-size"] = fontSizeA;
1570
1657
  fontFamilies.add({
1571
1658
  parse: fontFamily_export_parse,
1572
1659
  isValid: fontFamily_export_isValid,
@@ -1597,7 +1684,7 @@ font_export_parse = function parse(v) {
1597
1684
  font_export_definition = {
1598
1685
  set(v) {
1599
1686
  v = external_dependency_parsers_0.prepareValue(v, this._global);
1600
- if (external_dependency_parsers_0.hasVarFunc(v)) {
1687
+ if (v === "" || external_dependency_parsers_0.hasVarFunc(v)) {
1601
1688
  for (const [key] of font_local_var_shorthandFor) {
1602
1689
  this._setProperty(key, "");
1603
1690
  }
@@ -1612,7 +1699,7 @@ font_export_definition = {
1612
1699
  const val = obj[key];
1613
1700
  if (typeof val === "string") {
1614
1701
  this._setProperty(key, val);
1615
- if (val && !str.has(val)) {
1702
+ if (val && val !== "normal" && !str.has(val)) {
1616
1703
  if (key === "line-height") {
1617
1704
  str.add(`/ ${val}`);
1618
1705
  } else {
@@ -1635,7 +1722,7 @@ font_export_definition = {
1635
1722
  if (external_dependency_parsers_0.hasVarFunc(v)) {
1636
1723
  return "";
1637
1724
  }
1638
- if (v && !str.has(v)) {
1725
+ if (v && v !== "normal" && !str.has(v)) {
1639
1726
  if (key === "line-height") {
1640
1727
  str.add(`/ ${v}`);
1641
1728
  } else {
@@ -19,7 +19,7 @@ module.exports.definition = {
19
19
  v = parsers.prepareValue(v, this._global);
20
20
  if (parsers.hasVarFunc(v)) {
21
21
  this._setProperty("background", "");
22
- this._setProperty("backgound-attachemnt", v);
22
+ this._setProperty("background-attachment", v);
23
23
  } else {
24
24
  this._setProperty("background-attachment", module.exports.parse(v));
25
25
  }
@@ -22,7 +22,7 @@ module.exports.definition = {
22
22
  v = parsers.prepareValue(v, this._global);
23
23
  if (parsers.hasVarFunc(v)) {
24
24
  this._setProperty("background", "");
25
- this._setProperty("backgound-color", v);
25
+ this._setProperty("background-color", v);
26
26
  } else {
27
27
  this._setProperty("background-color", module.exports.parse(v));
28
28
  }
@@ -18,7 +18,7 @@ module.exports.definition = {
18
18
  v = parsers.prepareValue(v, this._global);
19
19
  if (parsers.hasVarFunc(v)) {
20
20
  this._setProperty("background", "");
21
- this._setProperty("backgound-image", v);
21
+ this._setProperty("background-image", v);
22
22
  } else {
23
23
  this._setProperty("background-image", module.exports.parse(v));
24
24
  }
@@ -39,7 +39,7 @@ module.exports.definition = {
39
39
  v = parsers.prepareValue(v, this._global);
40
40
  if (parsers.hasVarFunc(v)) {
41
41
  this._setProperty("background", "");
42
- this._setProperty("backgound-position", v);
42
+ this._setProperty("background-position", v);
43
43
  } else {
44
44
  this._setProperty("background-position", module.exports.parse(v));
45
45
  }
@@ -19,7 +19,7 @@ module.exports.definition = {
19
19
  v = parsers.prepareValue(v, this._global);
20
20
  if (parsers.hasVarFunc(v)) {
21
21
  this._setProperty("background", "");
22
- this._setProperty("backgound-repeat", v);
22
+ this._setProperty("background-repeat", v);
23
23
  } else {
24
24
  this._setProperty("background-repeat", module.exports.parse(v));
25
25
  }
@@ -26,38 +26,103 @@ module.exports.parse = function parse(v) {
26
26
  const [fontBlock, ...families] = parsers.splitValue(v, {
27
27
  delimiter: ","
28
28
  });
29
- let blockA, blockB;
30
- if (fontBlock.includes("/")) {
31
- [blockA, blockB] = parsers.splitValue(fontBlock, {
32
- delimiter: "/"
33
- });
34
- } else {
35
- blockA = fontBlock.trim();
36
- }
37
- const obj = parsers.parseShorthand(blockA, shorthandFor, true);
38
- if (!obj) {
39
- return;
40
- }
41
- const font = {};
29
+ const [fontBlockA, fontBlockB] = parsers.splitValue(fontBlock, {
30
+ delimiter: "/"
31
+ });
32
+ const font = {
33
+ "font-style": "normal",
34
+ "font-variant": "normal",
35
+ "font-weight": "normal"
36
+ };
42
37
  const fontFamilies = new Set();
43
- for (const [property, value] of Object.entries(obj)) {
44
- if (property === "font-family") {
45
- if (!blockB) {
46
- fontFamilies.add(value);
47
- }
38
+ if (fontBlockB) {
39
+ const [lineB, ...familiesB] = fontBlockB.trim().split(" ");
40
+ if (!lineB || !lineHeight.isValid(lineB) || !familiesB.length) {
41
+ return;
42
+ }
43
+ const lineHeightB = lineHeight.parse(lineB);
44
+ const familyB = familiesB.join(" ");
45
+ if (fontFamily.isValid(familyB)) {
46
+ fontFamilies.add(fontFamily.parse(familyB));
48
47
  } else {
49
- font[property] = value;
48
+ return;
50
49
  }
51
- }
52
- // blockB, if matched, includes line-height and first font-family
53
- if (blockB) {
54
- const [lineheight, family] = parsers.splitValue(blockB);
55
- if (lineHeight.isValid(lineheight)) {
56
- font["line-height"] = lineHeight.parse(lineheight);
50
+ const parts = parsers.splitValue(fontBlockA.trim());
51
+ const properties = ["font-style", "font-variant", "font-weight", "font-size"];
52
+ for (const part of parts) {
53
+ if (part === "normal") {
54
+ continue;
55
+ } else {
56
+ for (const property of properties) {
57
+ switch (property) {
58
+ case "font-style":
59
+ case "font-variant":
60
+ case "font-weight": {
61
+ const value = shorthandFor.get(property);
62
+ if (value.isValid(part)) {
63
+ font[property] = value.parse(part);
64
+ }
65
+ break;
66
+ }
67
+ case "font-size": {
68
+ const value = shorthandFor.get(property);
69
+ if (value.isValid(part)) {
70
+ font[property] = value.parse(part);
71
+ }
72
+ break;
73
+ }
74
+ default:
75
+ }
76
+ }
77
+ }
78
+ }
79
+ if (Object.hasOwn(font, "font-size")) {
80
+ font["line-height"] = lineHeightB;
57
81
  } else {
58
82
  return;
59
83
  }
60
- if (fontFamily.isValid(family)) {
84
+ } else {
85
+ // FIXME: Switch to toReversed() when we can drop Node.js 18 support.
86
+ const revParts = [...parsers.splitValue(fontBlockA.trim())].reverse();
87
+ const revFontFamily = [];
88
+ const properties = ["font-style", "font-variant", "font-weight", "line-height"];
89
+ font["font-style"] = "normal";
90
+ font["font-variant"] = "normal";
91
+ font["font-weight"] = "normal";
92
+ font["line-height"] = "normal";
93
+ let fontSizeA;
94
+ for (const part of revParts) {
95
+ if (fontSizeA) {
96
+ if (part === "normal") {
97
+ continue;
98
+ } else {
99
+ for (const property of properties) {
100
+ switch (property) {
101
+ case "font-style":
102
+ case "font-variant":
103
+ case "font-weight":
104
+ case "line-height": {
105
+ const value = shorthandFor.get(property);
106
+ if (value.isValid(part)) {
107
+ font[property] = value.parse(part);
108
+ }
109
+ break;
110
+ }
111
+ default:
112
+ }
113
+ }
114
+ }
115
+ } else if (fontSize.isValid(part)) {
116
+ fontSizeA = fontSize.parse(part);
117
+ } else if (fontFamily.isValid(part)) {
118
+ revFontFamily.push(part);
119
+ } else {
120
+ return;
121
+ }
122
+ }
123
+ const family = revFontFamily.reverse().join(" ");
124
+ if (fontSizeA && fontFamily.isValid(family)) {
125
+ font["font-size"] = fontSizeA;
61
126
  fontFamilies.add(fontFamily.parse(family));
62
127
  } else {
63
128
  return;
@@ -77,7 +142,7 @@ module.exports.parse = function parse(v) {
77
142
  module.exports.definition = {
78
143
  set(v) {
79
144
  v = parsers.prepareValue(v, this._global);
80
- if (parsers.hasVarFunc(v)) {
145
+ if (v === "" || parsers.hasVarFunc(v)) {
81
146
  for (const [key] of shorthandFor) {
82
147
  this._setProperty(key, "");
83
148
  }
@@ -92,7 +157,7 @@ module.exports.definition = {
92
157
  const val = obj[key];
93
158
  if (typeof val === "string") {
94
159
  this._setProperty(key, val);
95
- if (val && !str.has(val)) {
160
+ if (val && val !== "normal" && !str.has(val)) {
96
161
  if (key === "line-height") {
97
162
  str.add(`/ ${val}`);
98
163
  } else {
@@ -115,7 +180,7 @@ module.exports.definition = {
115
180
  if (parsers.hasVarFunc(v)) {
116
181
  return "";
117
182
  }
118
- if (v && !str.has(v)) {
183
+ if (v && v !== "normal" && !str.has(v)) {
119
184
  if (key === "line-height") {
120
185
  str.add(`/ ${v}`);
121
186
  } else {
@@ -6,7 +6,19 @@ module.exports.parse = function parse(v) {
6
6
  if (v === "") {
7
7
  return v;
8
8
  }
9
- const keywords = ["serif", "sans-serif", "system-ui", "cursive", "fantasy", "monospace"];
9
+ const keywords = [
10
+ "serif",
11
+ "sans-serif",
12
+ "cursive",
13
+ "fantasy",
14
+ "monospace",
15
+ "system-ui",
16
+ "math",
17
+ "ui-serif",
18
+ "ui-sans-serif",
19
+ "ui-monospace",
20
+ "ui-rounded"
21
+ ];
10
22
  const val = parsers.splitValue(v, {
11
23
  delimiter: ","
12
24
  });
@@ -25,16 +37,18 @@ module.exports.parse = function parse(v) {
25
37
  valid = true;
26
38
  continue;
27
39
  }
28
- // This implementation does not strictly follow the specification. The spec
29
- // does not require the first letter of the font-family to be capitalized.
30
- // Also, unquoted font-family names are not restricted to ASCII only.
40
+ // This implementation does not strictly follow the specification.
41
+ // The spec does not require the first letter of the font-family to be
42
+ // capitalized, and unquoted font-family names are not restricted to ASCII.
31
43
  // However, in the real world, the first letter of the ASCII font-family
32
- // names are always capitalized, and unquoted font-family names do not
33
- // contain spaces, e.g. `Times`, and AFAIK, non-ASCII font-family names are
34
- // always quoted even without spaces, e.g. `"メイリオ"`.
35
- // Therefore, it is unlikely that this implementation will cause problems.
44
+ // names are capitalized, and unquoted font-family names do not contain
45
+ // spaces, e.g. `Times`. And non-ASCII font-family names are quoted even
46
+ // without spaces, e.g. `"メイリオ"`.
36
47
  // @see https://drafts.csswg.org/css-fonts/#font-family-prop
37
- if (/^\s*(?:[A-Z][A-Za-z\d\s-]+)\s*$/.test(i)) {
48
+ if (
49
+ i !== "undefined" &&
50
+ /^(?:[A-Z][A-Za-z\d-]+(?:\s+[A-Z][A-Za-z\d-]+)*|-?[a-z][a-z-]+)$/.test(i)
51
+ ) {
38
52
  font.push(i.trim());
39
53
  valid = true;
40
54
  continue;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "CSSStyleDeclaration",
7
7
  "StyleSheet"
8
8
  ],
9
- "version": "4.4.0",
9
+ "version": "4.5.0",
10
10
  "homepage": "https://github.com/jsdom/cssstyle",
11
11
  "maintainers": [
12
12
  {