cssstyle 5.3.5 → 5.3.6

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 (86) hide show
  1. package/lib/CSSStyleDeclaration.js +2 -2
  2. package/lib/generated/implementedProperties.js +1 -1
  3. package/lib/generated/properties.js +1958 -2271
  4. package/lib/generated/propertyDefinitions.js +13033 -0
  5. package/lib/normalize.js +1259 -1095
  6. package/lib/parsers.js +588 -228
  7. package/lib/properties/background.js +89 -79
  8. package/lib/properties/backgroundAttachment.js +11 -14
  9. package/lib/properties/backgroundClip.js +11 -14
  10. package/lib/properties/backgroundColor.js +8 -13
  11. package/lib/properties/backgroundImage.js +11 -26
  12. package/lib/properties/backgroundOrigin.js +11 -14
  13. package/lib/properties/backgroundPosition.js +29 -18
  14. package/lib/properties/backgroundRepeat.js +11 -7
  15. package/lib/properties/backgroundSize.js +22 -16
  16. package/lib/properties/border.js +30 -87
  17. package/lib/properties/borderBottom.js +30 -86
  18. package/lib/properties/borderBottomColor.js +8 -14
  19. package/lib/properties/borderBottomStyle.js +8 -13
  20. package/lib/properties/borderBottomWidth.js +11 -23
  21. package/lib/properties/borderCollapse.js +4 -9
  22. package/lib/properties/borderColor.js +17 -23
  23. package/lib/properties/borderLeft.js +30 -86
  24. package/lib/properties/borderLeftColor.js +8 -14
  25. package/lib/properties/borderLeftStyle.js +8 -13
  26. package/lib/properties/borderLeftWidth.js +11 -23
  27. package/lib/properties/borderRight.js +30 -86
  28. package/lib/properties/borderRightColor.js +8 -14
  29. package/lib/properties/borderRightStyle.js +8 -13
  30. package/lib/properties/borderRightWidth.js +11 -23
  31. package/lib/properties/borderSpacing.js +12 -9
  32. package/lib/properties/borderStyle.js +17 -23
  33. package/lib/properties/borderTop.js +30 -86
  34. package/lib/properties/borderTopColor.js +8 -14
  35. package/lib/properties/borderTopStyle.js +8 -13
  36. package/lib/properties/borderTopWidth.js +11 -23
  37. package/lib/properties/borderWidth.js +18 -36
  38. package/lib/properties/bottom.js +6 -17
  39. package/lib/properties/clear.js +4 -9
  40. package/lib/properties/clip.js +10 -5
  41. package/lib/properties/color.js +4 -10
  42. package/lib/properties/display.js +11 -8
  43. package/lib/properties/flex.js +55 -53
  44. package/lib/properties/flexBasis.js +10 -20
  45. package/lib/properties/flexGrow.js +10 -19
  46. package/lib/properties/flexShrink.js +10 -19
  47. package/lib/properties/float.js +4 -9
  48. package/lib/properties/floodColor.js +4 -10
  49. package/lib/properties/font.js +46 -33
  50. package/lib/properties/fontFamily.js +16 -12
  51. package/lib/properties/fontSize.js +11 -22
  52. package/lib/properties/fontStyle.js +14 -8
  53. package/lib/properties/fontVariant.js +11 -18
  54. package/lib/properties/fontWeight.js +14 -25
  55. package/lib/properties/height.js +7 -17
  56. package/lib/properties/left.js +6 -17
  57. package/lib/properties/lightingColor.js +4 -10
  58. package/lib/properties/lineHeight.js +10 -24
  59. package/lib/properties/margin.js +14 -32
  60. package/lib/properties/marginBottom.js +10 -20
  61. package/lib/properties/marginLeft.js +10 -20
  62. package/lib/properties/marginRight.js +10 -20
  63. package/lib/properties/marginTop.js +10 -20
  64. package/lib/properties/opacity.js +6 -18
  65. package/lib/properties/outlineColor.js +4 -10
  66. package/lib/properties/padding.js +15 -30
  67. package/lib/properties/paddingBottom.js +11 -21
  68. package/lib/properties/paddingLeft.js +11 -21
  69. package/lib/properties/paddingRight.js +11 -21
  70. package/lib/properties/paddingTop.js +11 -21
  71. package/lib/properties/right.js +6 -17
  72. package/lib/properties/stopColor.js +4 -10
  73. package/lib/properties/top.js +7 -17
  74. package/lib/properties/webkitBorderAfterColor.js +4 -10
  75. package/lib/properties/webkitBorderBeforeColor.js +4 -10
  76. package/lib/properties/webkitBorderEndColor.js +4 -10
  77. package/lib/properties/webkitBorderStartColor.js +4 -10
  78. package/lib/properties/webkitColumnRuleColor.js +4 -10
  79. package/lib/properties/webkitTapHighlightColor.js +4 -10
  80. package/lib/properties/webkitTextEmphasisColor.js +4 -10
  81. package/lib/properties/webkitTextFillColor.js +4 -10
  82. package/lib/properties/webkitTextStrokeColor.js +4 -10
  83. package/lib/properties/width.js +7 -17
  84. package/lib/utils/propertyDescriptors.js +49 -13
  85. package/lib/utils/strings.js +6 -0
  86. package/package.json +8 -27
@@ -11,15 +11,15 @@ const fontFamily = require("./fontFamily");
11
11
  const property = "font";
12
12
 
13
13
  module.exports.shorthandFor = new Map([
14
- ["font-style", fontStyle],
15
- ["font-variant", fontVariant],
16
- ["font-weight", fontWeight],
17
- ["font-size", fontSize],
18
- ["line-height", lineHeight],
19
- ["font-family", fontFamily]
14
+ [fontStyle.property, fontStyle],
15
+ [fontVariant.property, fontVariant],
16
+ [fontWeight.property, fontWeight],
17
+ [fontSize.property, fontSize],
18
+ [lineHeight.property, lineHeight],
19
+ [fontFamily.property, fontFamily]
20
20
  ]);
21
21
 
22
- module.exports.parse = function parse(v, opt = {}) {
22
+ module.exports.parse = (v, opt = {}) => {
23
23
  const { globalObject } = opt;
24
24
  if (v === "") {
25
25
  return v;
@@ -29,6 +29,7 @@ module.exports.parse = function parse(v, opt = {}) {
29
29
  if (!parsers.isValidPropertyValue(property, v)) {
30
30
  return;
31
31
  }
32
+ const { AST_TYPES } = parsers;
32
33
  const [fontBlock, ...families] = parsers.splitValue(v, {
33
34
  delimiter: ","
34
35
  });
@@ -36,9 +37,9 @@ module.exports.parse = function parse(v, opt = {}) {
36
37
  delimiter: "/"
37
38
  });
38
39
  const font = {
39
- "font-style": "normal",
40
- "font-variant": "normal",
41
- "font-weight": "normal"
40
+ [fontStyle.property]: "normal",
41
+ [fontVariant.property]: "normal",
42
+ [fontWeight.property]: "normal"
42
43
  };
43
44
  const fontFamilies = new Set();
44
45
  if (fontBlockB) {
@@ -62,14 +63,19 @@ module.exports.parse = function parse(v, opt = {}) {
62
63
  return;
63
64
  }
64
65
  const parts = parsers.splitValue(fontBlockA.trim());
65
- const properties = ["font-style", "font-variant", "font-weight", "font-size"];
66
+ const properties = [
67
+ fontStyle.property,
68
+ fontVariant.property,
69
+ fontWeight.property,
70
+ fontSize.property
71
+ ];
66
72
  for (const part of parts) {
67
73
  if (part === "normal") {
68
74
  continue;
69
75
  } else {
70
76
  for (const longhand of properties) {
71
77
  switch (longhand) {
72
- case "font-size": {
78
+ case fontSize.property: {
73
79
  const parsedValue = fontSize.parse(part, {
74
80
  globalObject
75
81
  });
@@ -78,8 +84,8 @@ module.exports.parse = function parse(v, opt = {}) {
78
84
  }
79
85
  break;
80
86
  }
81
- case "font-style":
82
- case "font-weight": {
87
+ case fontStyle.property:
88
+ case fontWeight.property: {
83
89
  if (font[longhand] === "normal") {
84
90
  const longhandItem = module.exports.shorthandFor.get(longhand);
85
91
  const parsedValue = longhandItem.parse(part, {
@@ -91,7 +97,7 @@ module.exports.parse = function parse(v, opt = {}) {
91
97
  }
92
98
  break;
93
99
  }
94
- case "font-variant": {
100
+ case fontVariant.property: {
95
101
  if (font[longhand] === "normal") {
96
102
  const parsedValue = fontVariant.parse(part, {
97
103
  globalObject
@@ -111,8 +117,8 @@ module.exports.parse = function parse(v, opt = {}) {
111
117
  }
112
118
  }
113
119
  }
114
- if (Object.hasOwn(font, "font-size")) {
115
- font["line-height"] = lineHeightB;
120
+ if (Object.hasOwn(font, fontSize.property)) {
121
+ font[lineHeight.property] = lineHeightB;
116
122
  } else {
117
123
  return;
118
124
  }
@@ -126,20 +132,25 @@ module.exports.parse = function parse(v, opt = {}) {
126
132
  });
127
133
  if (Array.isArray(value) && value.length === 1) {
128
134
  const [{ name, type }] = value;
129
- if (type === "GlobalKeyword") {
135
+ if (type === AST_TYPES.GLOBAL_KEYWORD) {
130
136
  return {
131
- "font-style": name,
132
- "font-variant": name,
133
- "font-weight": name,
134
- "font-size": name,
135
- "line-height": name,
136
- "font-family": name
137
+ [fontStyle.property]: name,
138
+ [fontVariant.property]: name,
139
+ [fontWeight.property]: name,
140
+ [fontSize.property]: name,
141
+ [lineHeight.property]: name,
142
+ [fontFamily.property]: name
137
143
  };
138
144
  }
139
145
  }
140
146
  return;
141
147
  }
142
- const properties = ["font-style", "font-variant", "font-weight", "line-height"];
148
+ const properties = [
149
+ fontStyle.property,
150
+ fontVariant.property,
151
+ fontWeight.property,
152
+ lineHeight.property
153
+ ];
143
154
  for (const longhand of properties) {
144
155
  font[longhand] = "normal";
145
156
  }
@@ -152,9 +163,9 @@ module.exports.parse = function parse(v, opt = {}) {
152
163
  } else {
153
164
  for (const longhand of properties) {
154
165
  switch (longhand) {
155
- case "font-style":
156
- case "font-weight":
157
- case "line-height": {
166
+ case fontStyle.property:
167
+ case fontWeight.property:
168
+ case lineHeight.property: {
158
169
  if (font[longhand] === "normal") {
159
170
  const longhandItem = module.exports.shorthandFor.get(longhand);
160
171
  const parsedValue = longhandItem.parse(part, {
@@ -166,7 +177,7 @@ module.exports.parse = function parse(v, opt = {}) {
166
177
  }
167
178
  break;
168
179
  }
169
- case "font-variant": {
180
+ case fontVariant.property: {
170
181
  if (font[longhand] === "normal") {
171
182
  const parsedValue = fontVariant.parse(part, {
172
183
  globalObject
@@ -209,7 +220,7 @@ module.exports.parse = function parse(v, opt = {}) {
209
220
  caseSensitive: true
210
221
  });
211
222
  if (fontSizeA && family) {
212
- font["font-size"] = fontSizeA;
223
+ font[fontSize.property] = fontSizeA;
213
224
  fontFamilies.add(fontFamily.parse(family));
214
225
  } else {
215
226
  return;
@@ -226,7 +237,7 @@ module.exports.parse = function parse(v, opt = {}) {
226
237
  return;
227
238
  }
228
239
  }
229
- font["font-family"] = [...fontFamilies].join(", ");
240
+ font[fontFamily.property] = [...fontFamilies].join(", ");
230
241
  return font;
231
242
  };
232
243
 
@@ -252,7 +263,7 @@ module.exports.definition = {
252
263
  if (typeof val === "string") {
253
264
  this._setProperty(key, val, priority);
254
265
  if (val && val !== "normal" && !str.has(val)) {
255
- if (key === "line-height") {
266
+ if (key === lineHeight.property) {
256
267
  str.add(`/ ${val}`);
257
268
  } else {
258
269
  str.add(val);
@@ -275,7 +286,7 @@ module.exports.definition = {
275
286
  return "";
276
287
  }
277
288
  if (v && v !== "normal" && !str.has(v)) {
278
- if (key === "line-height") {
289
+ if (key === lineHeight.property) {
279
290
  str.add(`/ ${v}`);
280
291
  } else {
281
292
  str.add(`${v}`);
@@ -287,3 +298,5 @@ module.exports.definition = {
287
298
  enumerable: true,
288
299
  configurable: true
289
300
  };
301
+
302
+ module.exports.property = property;
@@ -5,11 +5,12 @@ const parsers = require("../parsers");
5
5
  const property = "font-family";
6
6
  const shorthand = "font";
7
7
 
8
- module.exports.parse = function parse(v, opt = {}) {
8
+ module.exports.parse = (v, opt = {}) => {
9
9
  const { globalObject } = opt;
10
10
  if (v === "") {
11
11
  return v;
12
12
  }
13
+ const { AST_TYPES } = parsers;
13
14
  const values = parsers.splitValue(v, {
14
15
  delimiter: ","
15
16
  });
@@ -24,15 +25,16 @@ module.exports.parse = function parse(v, opt = {}) {
24
25
  if (value.length === 1) {
25
26
  const [{ name, type, value: itemValue }] = value;
26
27
  switch (type) {
27
- case "Function": {
28
+ case AST_TYPES.FUNCTION: {
28
29
  parsedValues.push(`${name}(${itemValue})`);
29
30
  break;
30
31
  }
31
- case "GlobalKeyword":
32
- case "Identifier": {
33
- if (name !== "undefined") {
34
- parsedValues.push(name);
32
+ case AST_TYPES.GLOBAL_KEYWORD:
33
+ case AST_TYPES.IDENTIFIER: {
34
+ if (name === "undefined") {
35
+ return;
35
36
  }
37
+ parsedValues.push(name);
36
38
  break;
37
39
  }
38
40
  case "String": {
@@ -48,11 +50,10 @@ module.exports.parse = function parse(v, opt = {}) {
48
50
  const parts = [];
49
51
  for (const item of value) {
50
52
  const { name, type } = item;
51
- if (type === "Identifier") {
52
- parts.push(name);
53
- } else {
53
+ if (type !== AST_TYPES.IDENTIFIER) {
54
54
  return;
55
55
  }
56
+ parts.push(name);
56
57
  }
57
58
  const parsedValue = parts.join(" ").replaceAll("\\", "").replaceAll('"', '\\"');
58
59
  parsedValues.push(`"${parsedValue}"`);
@@ -79,9 +80,10 @@ module.exports.definition = {
79
80
  globalObject: this._global
80
81
  });
81
82
  if (typeof val === "string") {
82
- const shorthandPriority = this._priorities.get(shorthand);
83
- const prior = this._priorities.get(property) ?? "";
84
- const priority = shorthandPriority && prior ? "" : prior;
83
+ const priority =
84
+ !this._priorities.get(shorthand) && this._priorities.has(property)
85
+ ? this._priorities.get(property)
86
+ : "";
85
87
  this._setProperty(property, val, priority);
86
88
  }
87
89
  }
@@ -92,3 +94,5 @@ module.exports.definition = {
92
94
  enumerable: true,
93
95
  configurable: true
94
96
  };
97
+
98
+ module.exports.property = property;
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
5
5
  const property = "font-size";
6
6
  const shorthand = "font";
7
7
 
8
- module.exports.parse = function parse(v, opt = {}) {
8
+ module.exports.parse = (v, opt = {}) => {
9
9
  const { globalObject } = opt;
10
10
  if (v === "") {
11
11
  return v;
@@ -15,24 +15,10 @@ module.exports.parse = function parse(v, opt = {}) {
15
15
  inArray: true
16
16
  });
17
17
  if (Array.isArray(value) && value.length === 1) {
18
- const [{ isNumber, name, type, value: itemValue }] = value;
19
- switch (type) {
20
- case "Calc": {
21
- if (isNumber) {
22
- return;
23
- }
24
- return `${name}(${itemValue})`;
25
- }
26
- case "GlobalKeyword":
27
- case "Identifier": {
28
- return name;
29
- }
30
- default: {
31
- return parsers.parseLengthPercentage(value, {
32
- min: 0
33
- });
34
- }
35
- }
18
+ return parsers.resolveNumericValue(value, {
19
+ min: 0,
20
+ type: "length"
21
+ });
36
22
  } else if (typeof value === "string") {
37
23
  return value;
38
24
  }
@@ -49,9 +35,10 @@ module.exports.definition = {
49
35
  globalObject: this._global
50
36
  });
51
37
  if (typeof val === "string") {
52
- const shorthandPriority = this._priorities.get(shorthand);
53
- const prior = this._priorities.get(property) ?? "";
54
- const priority = shorthandPriority && prior ? "" : prior;
38
+ const priority =
39
+ !this._priorities.get(shorthand) && this._priorities.has(property)
40
+ ? this._priorities.get(property)
41
+ : "";
55
42
  this._setProperty(property, val, priority);
56
43
  }
57
44
  }
@@ -62,3 +49,5 @@ module.exports.definition = {
62
49
  enumerable: true,
63
50
  configurable: true
64
51
  };
52
+
53
+ module.exports.property = property;
@@ -5,11 +5,12 @@ const parsers = require("../parsers");
5
5
  const property = "font-style";
6
6
  const shorthand = "font";
7
7
 
8
- module.exports.parse = function parse(v, opt = {}) {
8
+ module.exports.parse = (v, opt = {}) => {
9
9
  const { globalObject } = opt;
10
10
  if (v === "") {
11
11
  return v;
12
12
  }
13
+ const { AST_TYPES } = parsers;
13
14
  const value = parsers.parsePropertyValue(property, v, {
14
15
  globalObject,
15
16
  inArray: true
@@ -18,16 +19,18 @@ module.exports.parse = function parse(v, opt = {}) {
18
19
  if (value.length === 1) {
19
20
  const [{ name, type }] = value;
20
21
  switch (type) {
21
- case "GlobalKeyword":
22
- case "Identifier": {
22
+ case AST_TYPES.GLOBAL_KEYWORD:
23
+ case AST_TYPES.IDENTIFIER: {
23
24
  return name;
24
25
  }
25
26
  default:
26
27
  }
27
28
  } else if (value.length === 2) {
28
29
  const [part1, part2] = value;
29
- const val1 = part1.type === "Identifier" && part1.name;
30
- const val2 = parsers.parseAngle([part2]);
30
+ const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name;
31
+ const val2 = parsers.resolveNumericValue([part2], {
32
+ type: "angle"
33
+ });
31
34
  if (val1 && val1 === "oblique" && val2) {
32
35
  return `${val1} ${val2}`;
33
36
  }
@@ -48,9 +51,10 @@ module.exports.definition = {
48
51
  globalObject: this._global
49
52
  });
50
53
  if (typeof val === "string") {
51
- const shorthandPriority = this._priorities.get(shorthand);
52
- const prior = this._priorities.get(property) ?? "";
53
- const priority = shorthandPriority && prior ? "" : prior;
54
+ const priority =
55
+ !this._priorities.get(shorthand) && this._priorities.has(property)
56
+ ? this._priorities.get(property)
57
+ : "";
54
58
  this._setProperty(property, val, priority);
55
59
  }
56
60
  }
@@ -61,3 +65,5 @@ module.exports.definition = {
61
65
  enumerable: true,
62
66
  configurable: true
63
67
  };
68
+
69
+ module.exports.property = property;
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
5
5
  const property = "font-variant";
6
6
  const shorthand = "font";
7
7
 
8
- module.exports.parse = function parse(v, opt = {}) {
8
+ module.exports.parse = (v, opt = {}) => {
9
9
  const { globalObject } = opt;
10
10
  if (v === "") {
11
11
  return v;
@@ -18,21 +18,11 @@ module.exports.parse = function parse(v, opt = {}) {
18
18
  inArray: true
19
19
  });
20
20
  if (Array.isArray(value) && value.length === 1) {
21
- const [{ name, type, value: itemValue }] = value;
22
- switch (type) {
23
- case "Function": {
24
- parsedValues.push(`${name}(${itemValue})`);
25
- break;
26
- }
27
- case "GlobalKeyword":
28
- case "Identifier": {
29
- parsedValues.push(name);
30
- break;
31
- }
32
- default: {
33
- return;
34
- }
21
+ const parsedValue = parsers.resolveFunctionValue(value);
22
+ if (!parsedValue) {
23
+ return;
35
24
  }
25
+ parsedValues.push(parsedValue);
36
26
  } else if (typeof value === "string") {
37
27
  parsedValues.push(value);
38
28
  }
@@ -58,9 +48,10 @@ module.exports.definition = {
58
48
  globalObject: this._global
59
49
  });
60
50
  if (typeof val === "string") {
61
- const shorthandPriority = this._priorities.get(shorthand);
62
- const prior = this._priorities.get(property) ?? "";
63
- const priority = shorthandPriority && prior ? "" : prior;
51
+ const priority =
52
+ !this._priorities.get(shorthand) && this._priorities.has(property)
53
+ ? this._priorities.get(property)
54
+ : "";
64
55
  this._setProperty(property, val, priority);
65
56
  }
66
57
  }
@@ -71,3 +62,5 @@ module.exports.definition = {
71
62
  enumerable: true,
72
63
  configurable: true
73
64
  };
65
+
66
+ module.exports.property = property;
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
5
5
  const property = "font-weight";
6
6
  const shorthand = "font";
7
7
 
8
- module.exports.parse = function parse(v, opt = {}) {
8
+ module.exports.parse = (v, opt = {}) => {
9
9
  const { globalObject } = opt;
10
10
  if (v === "") {
11
11
  return v;
@@ -15,28 +15,14 @@ module.exports.parse = function parse(v, opt = {}) {
15
15
  inArray: true
16
16
  });
17
17
  if (Array.isArray(value) && value.length === 1) {
18
- const [{ isNumber, name, type, value: itemValue }] = value;
19
- switch (type) {
20
- case "Calc": {
21
- if (isNumber) {
22
- return `${name}(${itemValue})`;
23
- }
24
- break;
25
- }
26
- case "GlobalKeyword":
27
- case "Identifier": {
28
- return name;
29
- }
30
- default: {
31
- const parsedValue = parsers.parseNumber(value, {
32
- min: 1,
33
- max: 1000
34
- });
35
- if (parsedValue) {
36
- return parsedValue;
37
- }
38
- }
18
+ const parsedValue = parsers.resolveNumericValue(value, {
19
+ min: 1,
20
+ max: 1000
21
+ });
22
+ if (!parsedValue) {
23
+ return;
39
24
  }
25
+ return parsedValue;
40
26
  } else if (typeof value === "string") {
41
27
  return value;
42
28
  }
@@ -53,9 +39,10 @@ module.exports.definition = {
53
39
  globalObject: this._global
54
40
  });
55
41
  if (typeof val === "string") {
56
- const shorthandPriority = this._priorities.get(shorthand);
57
- const prior = this._priorities.get(property) ?? "";
58
- const priority = shorthandPriority && prior ? "" : prior;
42
+ const priority =
43
+ !this._priorities.get(shorthand) && this._priorities.has(property)
44
+ ? this._priorities.get(property)
45
+ : "";
59
46
  this._setProperty(property, val, priority);
60
47
  }
61
48
  }
@@ -66,3 +53,5 @@ module.exports.definition = {
66
53
  enumerable: true,
67
54
  configurable: true
68
55
  };
56
+
57
+ module.exports.property = property;
@@ -4,7 +4,7 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "height";
6
6
 
7
- module.exports.parse = function parse(v, opt = {}) {
7
+ module.exports.parse = (v, opt = {}) => {
8
8
  const { globalObject } = opt;
9
9
  if (v === "") {
10
10
  return v;
@@ -14,22 +14,10 @@ module.exports.parse = function parse(v, opt = {}) {
14
14
  inArray: true
15
15
  });
16
16
  if (Array.isArray(value) && value.length === 1) {
17
- const [{ isNumber, name, type, value: itemValue }] = value;
18
- switch (type) {
19
- case "Calc": {
20
- if (isNumber) {
21
- return;
22
- }
23
- return `${name}(${itemValue})`;
24
- }
25
- case "GlobalKeyword":
26
- case "Identifier": {
27
- return name;
28
- }
29
- default: {
30
- return parsers.parseLengthPercentage(value);
31
- }
32
- }
17
+ return parsers.resolveNumericValue(value, {
18
+ min: 0,
19
+ type: "length"
20
+ });
33
21
  } else if (typeof value === "string") {
34
22
  return value;
35
23
  }
@@ -56,3 +44,5 @@ module.exports.definition = {
56
44
  enumerable: true,
57
45
  configurable: true
58
46
  };
47
+
48
+ module.exports.property = property;
@@ -4,7 +4,7 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "left";
6
6
 
7
- module.exports.parse = function parse(v, opt = {}) {
7
+ module.exports.parse = (v, opt = {}) => {
8
8
  const { globalObject } = opt;
9
9
  if (v === "") {
10
10
  return v;
@@ -14,22 +14,9 @@ module.exports.parse = function parse(v, opt = {}) {
14
14
  inArray: true
15
15
  });
16
16
  if (Array.isArray(value) && value.length === 1) {
17
- const [{ isNumber, name, type, value: itemValue }] = value;
18
- switch (type) {
19
- case "Calc": {
20
- if (isNumber) {
21
- return;
22
- }
23
- return `${name}(${itemValue})`;
24
- }
25
- case "GlobalKeyword":
26
- case "Identifier": {
27
- return name;
28
- }
29
- default: {
30
- return parsers.parseLengthPercentage(value);
31
- }
32
- }
17
+ return parsers.resolveNumericValue(value, {
18
+ type: "length"
19
+ });
33
20
  } else if (typeof value === "string") {
34
21
  return value;
35
22
  }
@@ -56,3 +43,5 @@ module.exports.definition = {
56
43
  enumerable: true,
57
44
  configurable: true
58
45
  };
46
+
47
+ module.exports.property = property;
@@ -4,7 +4,7 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "lighting-color";
6
6
 
7
- module.exports.parse = function parse(v, opt = {}) {
7
+ module.exports.parse = (v, opt = {}) => {
8
8
  const { globalObject } = opt;
9
9
  if (v === "") {
10
10
  return v;
@@ -14,15 +14,7 @@ module.exports.parse = function parse(v, opt = {}) {
14
14
  inArray: true
15
15
  });
16
16
  if (Array.isArray(value) && value.length === 1) {
17
- const [{ name, type }] = value;
18
- switch (type) {
19
- case "GlobalKeyword": {
20
- return name;
21
- }
22
- default: {
23
- return parsers.parseColor(value);
24
- }
25
- }
17
+ return parsers.resolveColorValue(value);
26
18
  } else if (typeof value === "string") {
27
19
  return value;
28
20
  }
@@ -49,3 +41,5 @@ module.exports.definition = {
49
41
  enumerable: true,
50
42
  configurable: true
51
43
  };
44
+
45
+ module.exports.property = property;
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
5
5
  const property = "line-height";
6
6
  const shorthand = "font";
7
7
 
8
- module.exports.parse = function parse(v, opt = {}) {
8
+ module.exports.parse = (v, opt = {}) => {
9
9
  const { globalObject } = opt;
10
10
  if (v === "") {
11
11
  return v;
@@ -15,26 +15,9 @@ module.exports.parse = function parse(v, opt = {}) {
15
15
  inArray: true
16
16
  });
17
17
  if (Array.isArray(value) && value.length === 1) {
18
- const [{ name, type, value: itemValue }] = value;
19
- switch (type) {
20
- case "Calc": {
21
- return `${name}(${itemValue})`;
22
- }
23
- case "GlobalKeyword":
24
- case "Identifier": {
25
- return name;
26
- }
27
- case "Number": {
28
- return parsers.parseNumber(value, {
29
- min: 0
30
- });
31
- }
32
- default: {
33
- return parsers.parseLengthPercentage(value, {
34
- min: 0
35
- });
36
- }
37
- }
18
+ return parsers.resolveNumericValue(value, {
19
+ min: 0
20
+ });
38
21
  } else if (typeof value === "string") {
39
22
  return value;
40
23
  }
@@ -51,9 +34,10 @@ module.exports.definition = {
51
34
  globalObject: this._global
52
35
  });
53
36
  if (typeof val === "string") {
54
- const shorthandPriority = this._priorities.get(shorthand);
55
- const prior = this._priorities.get(property) ?? "";
56
- const priority = shorthandPriority && prior ? "" : prior;
37
+ const priority =
38
+ !this._priorities.get(shorthand) && this._priorities.has(property)
39
+ ? this._priorities.get(property)
40
+ : "";
57
41
  this._setProperty(property, val, priority);
58
42
  }
59
43
  }
@@ -64,3 +48,5 @@ module.exports.definition = {
64
48
  enumerable: true,
65
49
  configurable: true
66
50
  };
51
+
52
+ module.exports.property = property;