cssstyle 5.0.0 → 5.1.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-07-14
2
+ // autogenerated - 2025-07-22
3
3
  // https://www.w3.org/Style/CSS/all-properties.en.html
4
4
 
5
5
  module.exports = new Set([
@@ -47,6 +47,7 @@ module.exports = new Set([
47
47
  "clear",
48
48
  "clip",
49
49
  "color",
50
+ "display",
50
51
  "flex",
51
52
  "flex-basis",
52
53
  "flex-grow",
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // autogenerated - 2025-07-14
2
+ // autogenerated - 2025-07-22
3
3
  // https://www.w3.org/Style/CSS/all-properties.en.html
4
4
 
5
5
  var external_dependency_parsers_0 = require("../parsers.js");
@@ -1792,6 +1792,213 @@ color_export_definition = {
1792
1792
  enumerable: true,
1793
1793
  configurable: true
1794
1794
  };
1795
+ var display_export_parse, display_export_isValid, display_export_definition;
1796
+ /* keywords */
1797
+ const display_local_var_displayOutside = ["block", "inline", "run-in"];
1798
+ const display_local_var_displayFlow = ["flow", "flow-root"];
1799
+ const display_local_var_displayInside = ["table", "flex", "grid", "ruby", ...display_local_var_displayFlow];
1800
+ const display_local_var_displayListItem = ["list-item"];
1801
+ const display_local_var_displayInternal = ["table-row-group", "table-header-group", "table-footer-group", "table-row", "table-cell", "table-column-group", "table-column", "table-caption", "ruby-base", "ruby-text", "ruby-base-container", "ruby-text-container"];
1802
+ const display_local_var_displayBox = ["contents", "none"];
1803
+ const display_local_var_displayLegacy = ["inline-block", "inline-table", "inline-flex", "inline-grid"];
1804
+ const display_local_var_keywords = [...display_local_var_displayOutside, ...display_local_var_displayInside, ...display_local_var_displayListItem, ...display_local_var_displayInternal, ...display_local_var_displayBox, ...display_local_var_displayLegacy];
1805
+ display_export_parse = function parse(v) {
1806
+ if (v === "") {
1807
+ return v;
1808
+ }
1809
+ const values = external_dependency_parsers_0.splitValue(v);
1810
+ switch (values.length) {
1811
+ case 1:
1812
+ {
1813
+ let [v1] = values;
1814
+ v1 = external_dependency_parsers_0.parseKeyword(v1, display_local_var_keywords);
1815
+ if (v1) {
1816
+ if (v1 === "flow") {
1817
+ return "block";
1818
+ }
1819
+ return v1;
1820
+ }
1821
+ break;
1822
+ }
1823
+ case 2:
1824
+ {
1825
+ let [v1, v2] = values;
1826
+ v1 = external_dependency_parsers_0.parseKeyword(v1, display_local_var_keywords);
1827
+ v2 = external_dependency_parsers_0.parseKeyword(v2, display_local_var_keywords);
1828
+ if (!v1 || !v2) {
1829
+ return;
1830
+ }
1831
+ let outerValue = "";
1832
+ let innerValue = "";
1833
+ if (v1 === "list-item") {
1834
+ outerValue = v2;
1835
+ innerValue = v1;
1836
+ } else if (v2 === "list-item") {
1837
+ outerValue = v1;
1838
+ innerValue = v2;
1839
+ } else if (display_local_var_displayOutside.includes(v1)) {
1840
+ outerValue = v1;
1841
+ innerValue = v2;
1842
+ } else if (display_local_var_displayOutside.includes(v2)) {
1843
+ outerValue = v2;
1844
+ innerValue = v1;
1845
+ }
1846
+ if (innerValue === "list-item") {
1847
+ switch (outerValue) {
1848
+ case "block":
1849
+ case "flow":
1850
+ {
1851
+ return innerValue;
1852
+ }
1853
+ case "flow-root":
1854
+ case "inline":
1855
+ case "run-in":
1856
+ {
1857
+ return `${outerValue} ${innerValue}`;
1858
+ }
1859
+ default:
1860
+ }
1861
+ } else if (outerValue === "block") {
1862
+ switch (innerValue) {
1863
+ case "flow":
1864
+ {
1865
+ return outerValue;
1866
+ }
1867
+ case "flow-root":
1868
+ case "flex":
1869
+ case "grid":
1870
+ case "table":
1871
+ {
1872
+ return innerValue;
1873
+ }
1874
+ case "ruby":
1875
+ {
1876
+ return `${outerValue} ${innerValue}`;
1877
+ }
1878
+ default:
1879
+ }
1880
+ } else if (outerValue === "inline") {
1881
+ switch (innerValue) {
1882
+ case "flow":
1883
+ {
1884
+ return outerValue;
1885
+ }
1886
+ case "flow-root":
1887
+ {
1888
+ return `${outerValue}-block`;
1889
+ }
1890
+ case "flex":
1891
+ case "grid":
1892
+ case "table":
1893
+ {
1894
+ return `${outerValue}-${innerValue}`;
1895
+ }
1896
+ case "ruby":
1897
+ {
1898
+ return innerValue;
1899
+ }
1900
+ default:
1901
+ }
1902
+ } else if (outerValue === "run-in") {
1903
+ switch (innerValue) {
1904
+ case "flow":
1905
+ {
1906
+ return outerValue;
1907
+ }
1908
+ case "flow-root":
1909
+ case "flex":
1910
+ case "grid":
1911
+ case "table":
1912
+ case "ruby":
1913
+ {
1914
+ return `${outerValue} ${innerValue}`;
1915
+ }
1916
+ default:
1917
+ }
1918
+ }
1919
+ break;
1920
+ }
1921
+ case 3:
1922
+ {
1923
+ let [v1, v2, v3] = values;
1924
+ v1 = external_dependency_parsers_0.parseKeyword(v1, display_local_var_keywords);
1925
+ v2 = external_dependency_parsers_0.parseKeyword(v2, display_local_var_keywords);
1926
+ v3 = external_dependency_parsers_0.parseKeyword(v3, display_local_var_keywords);
1927
+ if (!v1 || !v2 || !v3) {
1928
+ return;
1929
+ }
1930
+ let outerValue = "";
1931
+ let flowValue = "";
1932
+ let listItemValue = "";
1933
+ if (v1 === "list-item") {
1934
+ listItemValue = v1;
1935
+ if (display_local_var_displayFlow.includes(v2)) {
1936
+ flowValue = v2;
1937
+ outerValue = v3;
1938
+ } else if (display_local_var_displayFlow.includes(v3)) {
1939
+ flowValue = v3;
1940
+ outerValue = v2;
1941
+ }
1942
+ } else if (v2 === "list-item") {
1943
+ listItemValue = v2;
1944
+ if (display_local_var_displayFlow.includes(v1)) {
1945
+ flowValue = v1;
1946
+ outerValue = v3;
1947
+ } else if (display_local_var_displayFlow.includes(v3)) {
1948
+ flowValue = v3;
1949
+ outerValue = v1;
1950
+ }
1951
+ } else if (v3 === "list-item") {
1952
+ listItemValue = v3;
1953
+ if (display_local_var_displayFlow.includes(v1)) {
1954
+ flowValue = v1;
1955
+ outerValue = v2;
1956
+ } else if (display_local_var_displayFlow.includes(v2)) {
1957
+ flowValue = v2;
1958
+ outerValue = v1;
1959
+ }
1960
+ }
1961
+ if (outerValue && flowValue && listItemValue) {
1962
+ switch (outerValue) {
1963
+ case "block":
1964
+ {
1965
+ if (flowValue === "flow") {
1966
+ return listItemValue;
1967
+ }
1968
+ return `${flowValue} ${listItemValue}`;
1969
+ }
1970
+ case "inline":
1971
+ case "run-in":
1972
+ {
1973
+ if (flowValue === "flow") {
1974
+ return `${outerValue} ${listItemValue}`;
1975
+ }
1976
+ return `${outerValue} ${flowValue} ${listItemValue}`;
1977
+ }
1978
+ }
1979
+ }
1980
+ break;
1981
+ }
1982
+ default:
1983
+ }
1984
+ };
1985
+ display_export_isValid = function isValid(v) {
1986
+ if (v === "") {
1987
+ return true;
1988
+ }
1989
+ return typeof display_export_parse(v) === "string";
1990
+ };
1991
+ display_export_definition = {
1992
+ set(v) {
1993
+ v = external_dependency_parsers_0.prepareValue(v, this._global);
1994
+ this._setProperty("display", display_export_parse(v));
1995
+ },
1996
+ get() {
1997
+ return this.getPropertyValue("display");
1998
+ },
1999
+ enumerable: true,
2000
+ configurable: true
2001
+ };
1795
2002
  var flexGrow_export_parse, flexGrow_export_isValid, flexGrow_export_definition;
1796
2003
  flexGrow_export_parse = function parse(v) {
1797
2004
  return external_dependency_parsers_0.parseNumber(v, true);
@@ -3306,6 +3513,7 @@ module.exports = {
3306
3513
  clear: clear_export_definition,
3307
3514
  clip: clip_export_definition,
3308
3515
  color: color_export_definition,
3516
+ display: display_export_definition,
3309
3517
  flexGrow: flexGrow_export_definition,
3310
3518
  "flex-grow": flexGrow_export_definition,
3311
3519
  flexShrink: flexShrink_export_definition,
package/lib/parsers.js CHANGED
@@ -7,7 +7,7 @@
7
7
  const { resolve: resolveColor, utils } = require("@asamuzakjp/css-color");
8
8
  const { asciiLowercase } = require("./utils/strings");
9
9
 
10
- const { cssCalc, isColor, isGradient, splitValue } = utils;
10
+ const { cssCalc, isColor, resolveGradient, splitValue } = utils;
11
11
 
12
12
  // CSS global values
13
13
  // @see https://drafts.csswg.org/css-cascade-5/#defaulting-keywords
@@ -398,7 +398,7 @@ exports.parseKeyword = function parseKeyword(val, validKeywords = []) {
398
398
  if (varRegEx.test(val)) {
399
399
  return val;
400
400
  }
401
- val = asciiLowercase(val.toString());
401
+ val = asciiLowercase(val);
402
402
  if (validKeywords.includes(val) || GLOBAL_VALUE.includes(val)) {
403
403
  return val;
404
404
  }
@@ -430,15 +430,17 @@ exports.parseImage = function parseImage(val) {
430
430
  if (val === "") {
431
431
  return "";
432
432
  }
433
- if (gradientRegEx.test(val) && varRegEx.test(val)) {
433
+ if (gradientRegEx.test(val) && exports.hasVarFunc(val)) {
434
434
  return val;
435
435
  }
436
436
  if (keywordRegEx.test(val)) {
437
437
  return exports.parseKeyword(val, ["none"]);
438
438
  }
439
- // FIXME: need to resolve color values within gradients
440
- if (isGradient(val)) {
441
- return val;
439
+ const res = resolveGradient(val, {
440
+ format: "specifiedValue"
441
+ });
442
+ if (res) {
443
+ return res;
442
444
  }
443
445
  return exports.parseUrl(val);
444
446
  };
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+
3
+ const parsers = require("../parsers");
4
+
5
+ /* keywords */
6
+ const displayOutside = ["block", "inline", "run-in"];
7
+ const displayFlow = ["flow", "flow-root"];
8
+ const displayInside = ["table", "flex", "grid", "ruby", ...displayFlow];
9
+ const displayListItem = ["list-item"];
10
+ const displayInternal = [
11
+ "table-row-group",
12
+ "table-header-group",
13
+ "table-footer-group",
14
+ "table-row",
15
+ "table-cell",
16
+ "table-column-group",
17
+ "table-column",
18
+ "table-caption",
19
+ "ruby-base",
20
+ "ruby-text",
21
+ "ruby-base-container",
22
+ "ruby-text-container"
23
+ ];
24
+ const displayBox = ["contents", "none"];
25
+ const displayLegacy = ["inline-block", "inline-table", "inline-flex", "inline-grid"];
26
+ const keywords = [
27
+ ...displayOutside,
28
+ ...displayInside,
29
+ ...displayListItem,
30
+ ...displayInternal,
31
+ ...displayBox,
32
+ ...displayLegacy
33
+ ];
34
+
35
+ module.exports.parse = function parse(v) {
36
+ if (v === "") {
37
+ return v;
38
+ }
39
+ const values = parsers.splitValue(v);
40
+ switch (values.length) {
41
+ case 1: {
42
+ let [v1] = values;
43
+ v1 = parsers.parseKeyword(v1, keywords);
44
+ if (v1) {
45
+ if (v1 === "flow") {
46
+ return "block";
47
+ }
48
+ return v1;
49
+ }
50
+ break;
51
+ }
52
+ case 2: {
53
+ let [v1, v2] = values;
54
+ v1 = parsers.parseKeyword(v1, keywords);
55
+ v2 = parsers.parseKeyword(v2, keywords);
56
+ if (!v1 || !v2) {
57
+ return;
58
+ }
59
+ let outerValue = "";
60
+ let innerValue = "";
61
+ if (v1 === "list-item") {
62
+ outerValue = v2;
63
+ innerValue = v1;
64
+ } else if (v2 === "list-item") {
65
+ outerValue = v1;
66
+ innerValue = v2;
67
+ } else if (displayOutside.includes(v1)) {
68
+ outerValue = v1;
69
+ innerValue = v2;
70
+ } else if (displayOutside.includes(v2)) {
71
+ outerValue = v2;
72
+ innerValue = v1;
73
+ }
74
+ if (innerValue === "list-item") {
75
+ switch (outerValue) {
76
+ case "block":
77
+ case "flow": {
78
+ return innerValue;
79
+ }
80
+ case "flow-root":
81
+ case "inline":
82
+ case "run-in": {
83
+ return `${outerValue} ${innerValue}`;
84
+ }
85
+ default:
86
+ }
87
+ } else if (outerValue === "block") {
88
+ switch (innerValue) {
89
+ case "flow": {
90
+ return outerValue;
91
+ }
92
+ case "flow-root":
93
+ case "flex":
94
+ case "grid":
95
+ case "table": {
96
+ return innerValue;
97
+ }
98
+ case "ruby": {
99
+ return `${outerValue} ${innerValue}`;
100
+ }
101
+ default:
102
+ }
103
+ } else if (outerValue === "inline") {
104
+ switch (innerValue) {
105
+ case "flow": {
106
+ return outerValue;
107
+ }
108
+ case "flow-root": {
109
+ return `${outerValue}-block`;
110
+ }
111
+ case "flex":
112
+ case "grid":
113
+ case "table": {
114
+ return `${outerValue}-${innerValue}`;
115
+ }
116
+ case "ruby": {
117
+ return innerValue;
118
+ }
119
+ default:
120
+ }
121
+ } else if (outerValue === "run-in") {
122
+ switch (innerValue) {
123
+ case "flow": {
124
+ return outerValue;
125
+ }
126
+ case "flow-root":
127
+ case "flex":
128
+ case "grid":
129
+ case "table":
130
+ case "ruby": {
131
+ return `${outerValue} ${innerValue}`;
132
+ }
133
+ default:
134
+ }
135
+ }
136
+ break;
137
+ }
138
+ case 3: {
139
+ let [v1, v2, v3] = values;
140
+ v1 = parsers.parseKeyword(v1, keywords);
141
+ v2 = parsers.parseKeyword(v2, keywords);
142
+ v3 = parsers.parseKeyword(v3, keywords);
143
+ if (!v1 || !v2 || !v3) {
144
+ return;
145
+ }
146
+ let outerValue = "";
147
+ let flowValue = "";
148
+ let listItemValue = "";
149
+ if (v1 === "list-item") {
150
+ listItemValue = v1;
151
+ if (displayFlow.includes(v2)) {
152
+ flowValue = v2;
153
+ outerValue = v3;
154
+ } else if (displayFlow.includes(v3)) {
155
+ flowValue = v3;
156
+ outerValue = v2;
157
+ }
158
+ } else if (v2 === "list-item") {
159
+ listItemValue = v2;
160
+ if (displayFlow.includes(v1)) {
161
+ flowValue = v1;
162
+ outerValue = v3;
163
+ } else if (displayFlow.includes(v3)) {
164
+ flowValue = v3;
165
+ outerValue = v1;
166
+ }
167
+ } else if (v3 === "list-item") {
168
+ listItemValue = v3;
169
+ if (displayFlow.includes(v1)) {
170
+ flowValue = v1;
171
+ outerValue = v2;
172
+ } else if (displayFlow.includes(v2)) {
173
+ flowValue = v2;
174
+ outerValue = v1;
175
+ }
176
+ }
177
+ if (outerValue && flowValue && listItemValue) {
178
+ switch (outerValue) {
179
+ case "block": {
180
+ if (flowValue === "flow") {
181
+ return listItemValue;
182
+ }
183
+ return `${flowValue} ${listItemValue}`;
184
+ }
185
+ case "inline":
186
+ case "run-in": {
187
+ if (flowValue === "flow") {
188
+ return `${outerValue} ${listItemValue}`;
189
+ }
190
+ return `${outerValue} ${flowValue} ${listItemValue}`;
191
+ }
192
+ }
193
+ }
194
+ break;
195
+ }
196
+ default:
197
+ }
198
+ };
199
+
200
+ module.exports.isValid = function isValid(v) {
201
+ if (v === "") {
202
+ return true;
203
+ }
204
+ return typeof module.exports.parse(v) === "string";
205
+ };
206
+
207
+ module.exports.definition = {
208
+ set(v) {
209
+ v = parsers.prepareValue(v, this._global);
210
+ this._setProperty("display", module.exports.parse(v));
211
+ },
212
+ get() {
213
+ return this.getPropertyValue("display");
214
+ },
215
+ enumerable: true,
216
+ configurable: true
217
+ };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "CSSStyleDeclaration",
7
7
  "StyleSheet"
8
8
  ],
9
- "version": "5.0.0",
9
+ "version": "5.1.0",
10
10
  "homepage": "https://github.com/jsdom/cssstyle",
11
11
  "maintainers": [
12
12
  {
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "main": "./lib/CSSStyleDeclaration.js",
39
39
  "dependencies": {
40
- "@asamuzakjp/css-color": "^3.2.0",
40
+ "@asamuzakjp/css-color": "^4.0.3",
41
41
  "rrweb-cssom": "^0.8.0"
42
42
  },
43
43
  "devDependencies": {