cssstyle 5.3.7 → 6.0.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.
Files changed (93) hide show
  1. package/lib/CSSStyleDeclaration.js +359 -395
  2. package/lib/generated/.gitkeep +0 -0
  3. package/lib/generated/propertyDefinitions.js +3685 -1498
  4. package/lib/generated/propertyDescriptors.js +1705 -0
  5. package/lib/index.js +9 -0
  6. package/lib/normalize.js +127 -253
  7. package/lib/parsers.js +152 -164
  8. package/lib/properties/background.js +201 -202
  9. package/lib/properties/backgroundAttachment.js +35 -33
  10. package/lib/properties/backgroundClip.js +35 -33
  11. package/lib/properties/backgroundColor.js +26 -24
  12. package/lib/properties/backgroundImage.js +36 -34
  13. package/lib/properties/backgroundOrigin.js +35 -33
  14. package/lib/properties/backgroundPosition.js +57 -57
  15. package/lib/properties/backgroundRepeat.js +40 -37
  16. package/lib/properties/backgroundSize.js +38 -34
  17. package/lib/properties/border.js +41 -34
  18. package/lib/properties/{webkitBorderEndColor.js → borderBlockEndColor.js} +26 -22
  19. package/lib/properties/{webkitBorderAfterColor.js → borderBlockStartColor.js} +26 -22
  20. package/lib/properties/borderBottom.js +40 -36
  21. package/lib/properties/borderBottomColor.js +25 -21
  22. package/lib/properties/borderBottomStyle.js +25 -21
  23. package/lib/properties/borderBottomWidth.js +28 -24
  24. package/lib/properties/borderCollapse.js +25 -21
  25. package/lib/properties/borderColor.js +36 -33
  26. package/lib/properties/{webkitBorderStartColor.js → borderInlineEndColor.js} +26 -22
  27. package/lib/properties/borderInlineStartColor.js +49 -0
  28. package/lib/properties/borderLeft.js +40 -36
  29. package/lib/properties/borderLeftColor.js +25 -21
  30. package/lib/properties/borderLeftStyle.js +25 -21
  31. package/lib/properties/borderLeftWidth.js +28 -24
  32. package/lib/properties/borderRight.js +40 -36
  33. package/lib/properties/borderRightColor.js +25 -21
  34. package/lib/properties/borderRightStyle.js +25 -21
  35. package/lib/properties/borderRightWidth.js +28 -24
  36. package/lib/properties/borderSpacing.js +33 -29
  37. package/lib/properties/borderStyle.js +36 -33
  38. package/lib/properties/borderTop.js +40 -36
  39. package/lib/properties/borderTopColor.js +25 -21
  40. package/lib/properties/borderTopStyle.js +25 -21
  41. package/lib/properties/borderTopWidth.js +28 -24
  42. package/lib/properties/borderWidth.js +36 -33
  43. package/lib/properties/bottom.js +27 -23
  44. package/lib/properties/clear.js +25 -21
  45. package/lib/properties/clip.js +37 -31
  46. package/lib/properties/color.js +25 -21
  47. package/lib/properties/display.js +36 -30
  48. package/lib/properties/flex.js +53 -45
  49. package/lib/properties/flexBasis.js +28 -26
  50. package/lib/properties/flexGrow.js +28 -26
  51. package/lib/properties/flexShrink.js +28 -26
  52. package/lib/properties/float.js +25 -21
  53. package/lib/properties/floodColor.js +25 -21
  54. package/lib/properties/font.js +89 -118
  55. package/lib/properties/fontFamily.js +38 -33
  56. package/lib/properties/fontSize.js +29 -27
  57. package/lib/properties/fontStyle.js +38 -34
  58. package/lib/properties/fontVariant.js +35 -33
  59. package/lib/properties/fontWeight.js +33 -31
  60. package/lib/properties/height.js +28 -24
  61. package/lib/properties/left.js +27 -23
  62. package/lib/properties/lightingColor.js +25 -21
  63. package/lib/properties/lineHeight.js +28 -26
  64. package/lib/properties/margin.js +40 -34
  65. package/lib/properties/marginBottom.js +30 -27
  66. package/lib/properties/marginLeft.js +30 -27
  67. package/lib/properties/marginRight.js +30 -27
  68. package/lib/properties/marginTop.js +30 -27
  69. package/lib/properties/opacity.js +27 -23
  70. package/lib/properties/outlineColor.js +25 -21
  71. package/lib/properties/padding.js +40 -34
  72. package/lib/properties/paddingBottom.js +31 -28
  73. package/lib/properties/paddingLeft.js +31 -28
  74. package/lib/properties/paddingRight.js +31 -28
  75. package/lib/properties/paddingTop.js +31 -28
  76. package/lib/properties/right.js +27 -23
  77. package/lib/properties/stopColor.js +25 -21
  78. package/lib/properties/{webkitBorderBeforeColor.js → textEmphasisColor.js} +26 -22
  79. package/lib/properties/top.js +27 -23
  80. package/lib/properties/webkitTextFillColor.js +25 -21
  81. package/lib/properties/webkitTextStrokeColor.js +25 -21
  82. package/lib/properties/width.js +28 -24
  83. package/lib/utils/propertyDescriptors.js +129 -42
  84. package/lib/utils/strings.js +11 -156
  85. package/package.json +11 -21
  86. package/lib/generated/allProperties.js +0 -653
  87. package/lib/generated/implementedProperties.js +0 -1466
  88. package/lib/generated/properties.js +0 -6637
  89. package/lib/properties/webkitColumnRuleColor.js +0 -45
  90. package/lib/properties/webkitTapHighlightColor.js +0 -45
  91. package/lib/properties/webkitTextEmphasisColor.js +0 -45
  92. package/lib/utils/allExtraProperties.js +0 -155
  93. package/lib/utils/camelize.js +0 -37
@@ -5,39 +5,17 @@ const parsers = require("../parsers");
5
5
  const property = "flex-shrink";
6
6
  const shorthand = "flex";
7
7
 
8
- module.exports.parse = (v, opt = {}) => {
9
- const { globalObject } = opt;
10
- if (v === "") {
11
- return v;
12
- }
13
- const value = parsers.parsePropertyValue(property, v, {
14
- globalObject,
15
- inArray: true
16
- });
17
- if (Array.isArray(value) && value.length === 1) {
18
- return parsers.resolveNumericValue(value, {
19
- min: 0
20
- });
21
- } else if (typeof value === "string") {
22
- return value;
23
- }
24
- };
25
-
26
- module.exports.definition = {
8
+ const descriptor = {
27
9
  set(v) {
28
10
  v = parsers.prepareValue(v);
29
11
  if (parsers.hasVarFunc(v)) {
30
12
  this._setProperty(shorthand, "");
31
13
  this._setProperty(property, v);
32
14
  } else {
33
- const val = module.exports.parse(v, {
34
- globalObject: this._global
35
- });
15
+ const val = parse(v);
36
16
  if (typeof val === "string") {
37
17
  const priority =
38
- !this._priorities.get(shorthand) && this._priorities.has(property)
39
- ? this._priorities.get(property)
40
- : "";
18
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
41
19
  this._flexBoxSetter(property, val, priority, shorthand);
42
20
  }
43
21
  }
@@ -49,4 +27,28 @@ module.exports.definition = {
49
27
  configurable: true
50
28
  };
51
29
 
52
- module.exports.property = property;
30
+ /**
31
+ * Parses the flex-shrink property value.
32
+ *
33
+ * @param {string} v - The value to parse.
34
+ * @returns {string|undefined} The parsed value or undefined if invalid.
35
+ */
36
+ function parse(v) {
37
+ if (v === "") {
38
+ return v;
39
+ }
40
+ const value = parsers.parsePropertyValue(property, v);
41
+ if (Array.isArray(value) && value.length === 1) {
42
+ return parsers.resolveNumericValue(value, {
43
+ min: 0
44
+ });
45
+ } else if (typeof value === "string") {
46
+ return value;
47
+ }
48
+ }
49
+
50
+ module.exports = {
51
+ descriptor,
52
+ parse,
53
+ property
54
+ };
@@ -4,31 +4,13 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "float";
6
6
 
7
- module.exports.parse = (v, opt = {}) => {
8
- const { globalObject } = opt;
9
- if (v === "") {
10
- return v;
11
- }
12
- const value = parsers.parsePropertyValue(property, v, {
13
- globalObject,
14
- inArray: true
15
- });
16
- if (Array.isArray(value) && value.length === 1) {
17
- return parsers.resolveKeywordValue(value);
18
- } else if (typeof value === "string") {
19
- return value;
20
- }
21
- };
22
-
23
- module.exports.definition = {
7
+ const descriptor = {
24
8
  set(v) {
25
9
  v = parsers.prepareValue(v);
26
10
  if (parsers.hasVarFunc(v)) {
27
11
  this._setProperty(property, v);
28
12
  } else {
29
- const val = module.exports.parse(v, {
30
- globalObject: this._global
31
- });
13
+ const val = parse(v);
32
14
  if (typeof val === "string") {
33
15
  const priority = this._priorities.get(property) ?? "";
34
16
  this._setProperty(property, val, priority);
@@ -42,4 +24,26 @@ module.exports.definition = {
42
24
  configurable: true
43
25
  };
44
26
 
45
- module.exports.property = property;
27
+ /**
28
+ * Parses the float property value.
29
+ *
30
+ * @param {string} v - The value to parse.
31
+ * @returns {string|undefined} The parsed value or undefined if invalid.
32
+ */
33
+ function parse(v) {
34
+ if (v === "") {
35
+ return v;
36
+ }
37
+ const value = parsers.parsePropertyValue(property, v);
38
+ if (Array.isArray(value) && value.length === 1) {
39
+ return parsers.resolveKeywordValue(value);
40
+ } else if (typeof value === "string") {
41
+ return value;
42
+ }
43
+ }
44
+
45
+ module.exports = {
46
+ descriptor,
47
+ parse,
48
+ property
49
+ };
@@ -4,31 +4,13 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "flood-color";
6
6
 
7
- module.exports.parse = (v, opt = {}) => {
8
- const { globalObject } = opt;
9
- if (v === "") {
10
- return v;
11
- }
12
- const value = parsers.parsePropertyValue(property, v, {
13
- globalObject,
14
- inArray: true
15
- });
16
- if (Array.isArray(value) && value.length === 1) {
17
- return parsers.resolveColorValue(value);
18
- } else if (typeof value === "string") {
19
- return value;
20
- }
21
- };
22
-
23
- module.exports.definition = {
7
+ const descriptor = {
24
8
  set(v) {
25
9
  v = parsers.prepareValue(v);
26
10
  if (parsers.hasVarFunc(v)) {
27
11
  this._setProperty(property, v);
28
12
  } else {
29
- const val = module.exports.parse(v, {
30
- globalObject: this._global
31
- });
13
+ const val = parse(v);
32
14
  if (typeof val === "string") {
33
15
  const priority = this._priorities.get(property) ?? "";
34
16
  this._setProperty(property, val, priority);
@@ -42,4 +24,26 @@ module.exports.definition = {
42
24
  configurable: true
43
25
  };
44
26
 
45
- module.exports.property = property;
27
+ /**
28
+ * Parses the flood-color property value.
29
+ *
30
+ * @param {string} v - The value to parse.
31
+ * @returns {string|undefined} The parsed value or undefined if invalid.
32
+ */
33
+ function parse(v) {
34
+ if (v === "") {
35
+ return v;
36
+ }
37
+ const value = parsers.parsePropertyValue(property, v);
38
+ if (Array.isArray(value) && value.length === 1) {
39
+ return parsers.resolveColorValue(value);
40
+ } else if (typeof value === "string") {
41
+ return value;
42
+ }
43
+ }
44
+
45
+ module.exports = {
46
+ descriptor,
47
+ parse,
48
+ property
49
+ };
@@ -8,9 +8,12 @@ const fontSize = require("./fontSize");
8
8
  const lineHeight = require("./lineHeight");
9
9
  const fontFamily = require("./fontFamily");
10
10
 
11
+ // Constants
12
+ const { AST_TYPES } = parsers;
13
+
11
14
  const property = "font";
12
15
 
13
- module.exports.shorthandFor = new Map([
16
+ const shorthandFor = new Map([
14
17
  [fontStyle.property, fontStyle],
15
18
  [fontVariant.property, fontVariant],
16
19
  [fontWeight.property, fontWeight],
@@ -19,8 +22,69 @@ module.exports.shorthandFor = new Map([
19
22
  [fontFamily.property, fontFamily]
20
23
  ]);
21
24
 
22
- module.exports.parse = (v, opt = {}) => {
23
- const { globalObject } = opt;
25
+ const descriptor = {
26
+ set(v) {
27
+ v = parsers.prepareValue(v);
28
+ if (v === "" || parsers.hasVarFunc(v)) {
29
+ for (const [key] of shorthandFor) {
30
+ this._setProperty(key, "");
31
+ }
32
+ this._setProperty(property, v);
33
+ } else {
34
+ const obj = parse(v);
35
+ if (!obj) {
36
+ return;
37
+ }
38
+ const priority = this._priorities.get(property) ?? "";
39
+ const str = new Set();
40
+ for (const [key] of shorthandFor) {
41
+ const val = obj[key];
42
+ if (typeof val === "string") {
43
+ this._setProperty(key, val, priority);
44
+ if (val && val !== "normal" && !str.has(val)) {
45
+ if (key === lineHeight.property) {
46
+ str.add(`/ ${val}`);
47
+ } else {
48
+ str.add(val);
49
+ }
50
+ }
51
+ }
52
+ }
53
+ this._setProperty(property, [...str].join(" "), priority);
54
+ }
55
+ },
56
+ get() {
57
+ const val = this.getPropertyValue(property);
58
+ if (parsers.hasVarFunc(val)) {
59
+ return val;
60
+ }
61
+ const str = new Set();
62
+ for (const [key] of shorthandFor) {
63
+ const v = this.getPropertyValue(key);
64
+ if (parsers.hasVarFunc(v)) {
65
+ return "";
66
+ }
67
+ if (v && v !== "normal" && !str.has(v)) {
68
+ if (key === lineHeight.property) {
69
+ str.add(`/ ${v}`);
70
+ } else {
71
+ str.add(`${v}`);
72
+ }
73
+ }
74
+ }
75
+ return [...str].join(" ");
76
+ },
77
+ enumerable: true,
78
+ configurable: true
79
+ };
80
+
81
+ /**
82
+ * Parses the font property value.
83
+ *
84
+ * @param {string} v - The value to parse.
85
+ * @returns {object|undefined} The parsed value object or undefined if invalid.
86
+ */
87
+ function parse(v) {
24
88
  if (v === "") {
25
89
  return v;
26
90
  } else if (parsers.hasCalcFunc(v)) {
@@ -29,7 +93,6 @@ module.exports.parse = (v, opt = {}) => {
29
93
  if (!parsers.isValidPropertyValue(property, v)) {
30
94
  return;
31
95
  }
32
- const { AST_TYPES } = parsers;
33
96
  const [fontBlock, ...families] = parsers.splitValue(v, {
34
97
  delimiter: ","
35
98
  });
@@ -47,28 +110,18 @@ module.exports.parse = (v, opt = {}) => {
47
110
  if (!lineB || !familiesB.length) {
48
111
  return;
49
112
  }
50
- const lineHeightB = lineHeight.parse(lineB, {
51
- global
52
- });
113
+ const lineHeightB = lineHeight.parse(lineB);
53
114
  if (typeof lineHeightB !== "string") {
54
115
  return;
55
116
  }
56
- const familyB = fontFamily.parse(familiesB.join(" "), {
57
- globalObject,
58
- caseSensitive: true
59
- });
117
+ const familyB = fontFamily.parse(familiesB.join(" "));
60
118
  if (typeof familyB === "string") {
61
119
  fontFamilies.add(familyB);
62
120
  } else {
63
121
  return;
64
122
  }
65
123
  const parts = parsers.splitValue(fontBlockA.trim());
66
- const properties = [
67
- fontStyle.property,
68
- fontVariant.property,
69
- fontWeight.property,
70
- fontSize.property
71
- ];
124
+ const properties = [fontStyle.property, fontVariant.property, fontWeight.property, fontSize.property];
72
125
  for (const part of parts) {
73
126
  if (part === "normal") {
74
127
  continue;
@@ -76,9 +129,7 @@ module.exports.parse = (v, opt = {}) => {
76
129
  for (const longhand of properties) {
77
130
  switch (longhand) {
78
131
  case fontSize.property: {
79
- const parsedValue = fontSize.parse(part, {
80
- globalObject
81
- });
132
+ const parsedValue = fontSize.parse(part);
82
133
  if (typeof parsedValue === "string") {
83
134
  font[longhand] = parsedValue;
84
135
  }
@@ -87,10 +138,8 @@ module.exports.parse = (v, opt = {}) => {
87
138
  case fontStyle.property:
88
139
  case fontWeight.property: {
89
140
  if (font[longhand] === "normal") {
90
- const longhandItem = module.exports.shorthandFor.get(longhand);
91
- const parsedValue = longhandItem.parse(part, {
92
- globalObject
93
- });
141
+ const longhandItem = shorthandFor.get(longhand);
142
+ const parsedValue = longhandItem.parse(part);
94
143
  if (typeof parsedValue === "string") {
95
144
  font[longhand] = parsedValue;
96
145
  }
@@ -99,9 +148,7 @@ module.exports.parse = (v, opt = {}) => {
99
148
  }
100
149
  case fontVariant.property: {
101
150
  if (font[longhand] === "normal") {
102
- const parsedValue = fontVariant.parse(part, {
103
- globalObject
104
- });
151
+ const parsedValue = fontVariant.parse(part);
105
152
  if (typeof parsedValue === "string") {
106
153
  if (parsedValue === "small-cap") {
107
154
  font[longhand] = parsedValue;
@@ -126,10 +173,7 @@ module.exports.parse = (v, opt = {}) => {
126
173
  const revParts = parsers.splitValue(fontBlockA.trim()).toReversed();
127
174
  if (revParts.length === 1) {
128
175
  const [part] = revParts;
129
- const value = parsers.parsePropertyValue(property, part, {
130
- globalObject,
131
- inArray: true
132
- });
176
+ const value = parsers.parsePropertyValue(property, part);
133
177
  if (Array.isArray(value) && value.length === 1) {
134
178
  const [{ name, type }] = value;
135
179
  if (type === AST_TYPES.GLOBAL_KEYWORD) {
@@ -145,12 +189,7 @@ module.exports.parse = (v, opt = {}) => {
145
189
  }
146
190
  return;
147
191
  }
148
- const properties = [
149
- fontStyle.property,
150
- fontVariant.property,
151
- fontWeight.property,
152
- lineHeight.property
153
- ];
192
+ const properties = [fontStyle.property, fontVariant.property, fontWeight.property, lineHeight.property];
154
193
  for (const longhand of properties) {
155
194
  font[longhand] = "normal";
156
195
  }
@@ -167,10 +206,8 @@ module.exports.parse = (v, opt = {}) => {
167
206
  case fontWeight.property:
168
207
  case lineHeight.property: {
169
208
  if (font[longhand] === "normal") {
170
- const longhandItem = module.exports.shorthandFor.get(longhand);
171
- const parsedValue = longhandItem.parse(part, {
172
- globalObject
173
- });
209
+ const longhandItem = shorthandFor.get(longhand);
210
+ const parsedValue = longhandItem.parse(part);
174
211
  if (typeof parsedValue === "string") {
175
212
  font[longhand] = parsedValue;
176
213
  }
@@ -179,9 +216,7 @@ module.exports.parse = (v, opt = {}) => {
179
216
  }
180
217
  case fontVariant.property: {
181
218
  if (font[longhand] === "normal") {
182
- const parsedValue = fontVariant.parse(part, {
183
- globalObject
184
- });
219
+ const parsedValue = fontVariant.parse(part);
185
220
  if (typeof parsedValue === "string") {
186
221
  if (parsedValue === "small-cap") {
187
222
  font[longhand] = parsedValue;
@@ -197,16 +232,11 @@ module.exports.parse = (v, opt = {}) => {
197
232
  }
198
233
  }
199
234
  } else {
200
- const parsedFontSize = fontSize.parse(part, {
201
- globalObject
202
- });
235
+ const parsedFontSize = fontSize.parse(part);
203
236
  if (typeof parsedFontSize === "string") {
204
237
  fontSizeA = parsedFontSize;
205
238
  } else {
206
- const parsedFontFamily = fontFamily.parse(part, {
207
- globalObject,
208
- caseSensitive: true
209
- });
239
+ const parsedFontFamily = fontFamily.parse(part);
210
240
  if (typeof parsedFontFamily === "string") {
211
241
  revFontFamily.push(parsedFontFamily);
212
242
  } else {
@@ -215,10 +245,7 @@ module.exports.parse = (v, opt = {}) => {
215
245
  }
216
246
  }
217
247
  }
218
- const family = fontFamily.parse(revFontFamily.toReversed().join(" "), {
219
- globalObject,
220
- caseSensitive: true
221
- });
248
+ const family = fontFamily.parse(revFontFamily.toReversed().join(" "));
222
249
  if (fontSizeA && family) {
223
250
  font[fontSize.property] = fontSizeA;
224
251
  fontFamilies.add(fontFamily.parse(family));
@@ -227,10 +254,7 @@ module.exports.parse = (v, opt = {}) => {
227
254
  }
228
255
  }
229
256
  for (const family of families) {
230
- const parsedFontFamily = fontFamily.parse(family, {
231
- globalObject,
232
- caseSensitive: true
233
- });
257
+ const parsedFontFamily = fontFamily.parse(family);
234
258
  if (parsedFontFamily) {
235
259
  fontFamilies.add(parsedFontFamily);
236
260
  } else {
@@ -239,64 +263,11 @@ module.exports.parse = (v, opt = {}) => {
239
263
  }
240
264
  font[fontFamily.property] = [...fontFamilies].join(", ");
241
265
  return font;
242
- };
266
+ }
243
267
 
244
- module.exports.definition = {
245
- set(v) {
246
- v = parsers.prepareValue(v);
247
- if (v === "" || parsers.hasVarFunc(v)) {
248
- for (const [key] of module.exports.shorthandFor) {
249
- this._setProperty(key, "");
250
- }
251
- this._setProperty(property, v);
252
- } else {
253
- const obj = module.exports.parse(v, {
254
- globalObject: this._global
255
- });
256
- if (!obj) {
257
- return;
258
- }
259
- const priority = this._priorities.get(property) ?? "";
260
- const str = new Set();
261
- for (const [key] of module.exports.shorthandFor) {
262
- const val = obj[key];
263
- if (typeof val === "string") {
264
- this._setProperty(key, val, priority);
265
- if (val && val !== "normal" && !str.has(val)) {
266
- if (key === lineHeight.property) {
267
- str.add(`/ ${val}`);
268
- } else {
269
- str.add(val);
270
- }
271
- }
272
- }
273
- }
274
- this._setProperty(property, [...str].join(" "), priority);
275
- }
276
- },
277
- get() {
278
- const val = this.getPropertyValue(property);
279
- if (parsers.hasVarFunc(val)) {
280
- return val;
281
- }
282
- const str = new Set();
283
- for (const [key] of module.exports.shorthandFor) {
284
- const v = this.getPropertyValue(key);
285
- if (parsers.hasVarFunc(v)) {
286
- return "";
287
- }
288
- if (v && v !== "normal" && !str.has(v)) {
289
- if (key === lineHeight.property) {
290
- str.add(`/ ${v}`);
291
- } else {
292
- str.add(`${v}`);
293
- }
294
- }
295
- }
296
- return [...str].join(" ");
297
- },
298
- enumerable: true,
299
- configurable: true
268
+ module.exports = {
269
+ descriptor,
270
+ parse,
271
+ property,
272
+ shorthandFor
300
273
  };
301
-
302
- module.exports.property = property;
@@ -2,24 +2,51 @@
2
2
 
3
3
  const parsers = require("../parsers");
4
4
 
5
+ // Constants
6
+ const { AST_TYPES } = parsers;
7
+
5
8
  const property = "font-family";
6
9
  const shorthand = "font";
7
10
 
8
- module.exports.parse = (v, opt = {}) => {
9
- const { globalObject } = opt;
11
+ const descriptor = {
12
+ set(v) {
13
+ v = parsers.prepareValue(v);
14
+ if (parsers.hasVarFunc(v)) {
15
+ this._setProperty(shorthand, "");
16
+ this._setProperty(property, v);
17
+ } else {
18
+ const val = parse(v);
19
+ if (typeof val === "string") {
20
+ const priority =
21
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
22
+ this._setProperty(property, val, priority);
23
+ }
24
+ }
25
+ },
26
+ get() {
27
+ return this.getPropertyValue(property);
28
+ },
29
+ enumerable: true,
30
+ configurable: true
31
+ };
32
+
33
+ /**
34
+ * Parses the font-family property value.
35
+ *
36
+ * @param {string} v - The value to parse.
37
+ * @returns {string|undefined} The parsed value or undefined if invalid.
38
+ */
39
+ function parse(v) {
10
40
  if (v === "") {
11
41
  return v;
12
42
  }
13
- const { AST_TYPES } = parsers;
14
43
  const values = parsers.splitValue(v, {
15
44
  delimiter: ","
16
45
  });
17
46
  const parsedValues = [];
18
47
  for (const val of values) {
19
48
  const value = parsers.parsePropertyValue(property, val, {
20
- globalObject,
21
- caseSensitive: true,
22
- inArray: true
49
+ caseSensitive: true
23
50
  });
24
51
  if (Array.isArray(value) && value.length) {
25
52
  if (value.length === 1) {
@@ -67,32 +94,10 @@ module.exports.parse = (v, opt = {}) => {
67
94
  if (parsedValues.length) {
68
95
  return parsedValues.join(", ");
69
96
  }
70
- };
97
+ }
71
98
 
72
- module.exports.definition = {
73
- set(v) {
74
- v = parsers.prepareValue(v);
75
- if (parsers.hasVarFunc(v)) {
76
- this._setProperty(shorthand, "");
77
- this._setProperty(property, v);
78
- } else {
79
- const val = module.exports.parse(v, {
80
- globalObject: this._global
81
- });
82
- if (typeof val === "string") {
83
- const priority =
84
- !this._priorities.get(shorthand) && this._priorities.has(property)
85
- ? this._priorities.get(property)
86
- : "";
87
- this._setProperty(property, val, priority);
88
- }
89
- }
90
- },
91
- get() {
92
- return this.getPropertyValue(property);
93
- },
94
- enumerable: true,
95
- configurable: true
99
+ module.exports = {
100
+ descriptor,
101
+ parse,
102
+ property
96
103
  };
97
-
98
- module.exports.property = property;
@@ -5,40 +5,17 @@ const parsers = require("../parsers");
5
5
  const property = "font-size";
6
6
  const shorthand = "font";
7
7
 
8
- module.exports.parse = (v, opt = {}) => {
9
- const { globalObject } = opt;
10
- if (v === "") {
11
- return v;
12
- }
13
- const value = parsers.parsePropertyValue(property, v, {
14
- globalObject,
15
- inArray: true
16
- });
17
- if (Array.isArray(value) && value.length === 1) {
18
- return parsers.resolveNumericValue(value, {
19
- min: 0,
20
- type: "length"
21
- });
22
- } else if (typeof value === "string") {
23
- return value;
24
- }
25
- };
26
-
27
- module.exports.definition = {
8
+ const descriptor = {
28
9
  set(v) {
29
10
  v = parsers.prepareValue(v);
30
11
  if (parsers.hasVarFunc(v)) {
31
12
  this._setProperty(shorthand, "");
32
13
  this._setProperty(property, v);
33
14
  } else {
34
- const val = module.exports.parse(v, {
35
- globalObject: this._global
36
- });
15
+ const val = parse(v);
37
16
  if (typeof val === "string") {
38
17
  const priority =
39
- !this._priorities.get(shorthand) && this._priorities.has(property)
40
- ? this._priorities.get(property)
41
- : "";
18
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
42
19
  this._setProperty(property, val, priority);
43
20
  }
44
21
  }
@@ -50,4 +27,29 @@ module.exports.definition = {
50
27
  configurable: true
51
28
  };
52
29
 
53
- module.exports.property = property;
30
+ /**
31
+ * Parses the font-size property value.
32
+ *
33
+ * @param {string} v - The value to parse.
34
+ * @returns {string|undefined} The parsed value or undefined if invalid.
35
+ */
36
+ function parse(v) {
37
+ if (v === "") {
38
+ return v;
39
+ }
40
+ const value = parsers.parsePropertyValue(property, v);
41
+ if (Array.isArray(value) && value.length === 1) {
42
+ return parsers.resolveNumericValue(value, {
43
+ min: 0,
44
+ type: "length"
45
+ });
46
+ } else if (typeof value === "string") {
47
+ return value;
48
+ }
49
+ }
50
+
51
+ module.exports = {
52
+ descriptor,
53
+ parse,
54
+ property
55
+ };