cssstyle 5.3.4 → 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 +245 -1096
  3. package/lib/generated/properties.js +1959 -2272
  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 +11 -6
  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 +16 -40
@@ -11,29 +11,30 @@ const backgroundAttachment = require("./backgroundAttachment");
11
11
  const backgroundColor = require("./backgroundColor");
12
12
 
13
13
  const property = "background";
14
- const initialValues = new Map([
15
- ["background-image", "none"],
16
- ["background-position", "0% 0%"],
17
- ["background-size", "auto"],
18
- ["background-repeat", "repeat"],
19
- ["background-origin", "padding-box"],
20
- ["background-clip", "border-box"],
21
- ["background-attachment", "scroll"],
22
- ["background-color", "transparent"]
14
+
15
+ module.exports.initialValues = new Map([
16
+ [backgroundImage.property, "none"],
17
+ [backgroundPosition.property, "0% 0%"],
18
+ [backgroundSize.property, "auto"],
19
+ [backgroundRepeat.property, "repeat"],
20
+ [backgroundOrigin.property, "padding-box"],
21
+ [backgroundClip.property, "border-box"],
22
+ [backgroundAttachment.property, "scroll"],
23
+ [backgroundColor.property, "transparent"]
23
24
  ]);
24
25
 
25
26
  module.exports.shorthandFor = new Map([
26
- ["background-image", backgroundImage],
27
- ["background-position", backgroundPosition],
28
- ["background-size", backgroundSize],
29
- ["background-repeat", backgroundRepeat],
30
- ["background-origin", backgroundOrigin],
31
- ["background-clip", backgroundClip],
32
- ["background-attachment", backgroundAttachment],
33
- ["background-color", backgroundColor]
27
+ [backgroundImage.property, backgroundImage],
28
+ [backgroundPosition.property, backgroundPosition],
29
+ [backgroundSize.property, backgroundSize],
30
+ [backgroundRepeat.property, backgroundRepeat],
31
+ [backgroundOrigin.property, backgroundOrigin],
32
+ [backgroundClip.property, backgroundClip],
33
+ [backgroundAttachment.property, backgroundAttachment],
34
+ [backgroundColor.property, backgroundColor]
34
35
  ]);
35
36
 
36
- module.exports.parse = function parse(v, opt = {}) {
37
+ module.exports.parse = (v, opt = {}) => {
37
38
  const { globalObject } = opt;
38
39
  if (v === "") {
39
40
  return v;
@@ -50,24 +51,30 @@ module.exports.parse = function parse(v, opt = {}) {
50
51
  const l = values.length;
51
52
  for (let i = 0; i < l; i++) {
52
53
  let bg = {
53
- "background-image": initialValues.get("background-image"),
54
- "background-position": initialValues.get("background-position"),
55
- "background-size": initialValues.get("background-size"),
56
- "background-repeat": initialValues.get("background-repeat"),
57
- "background-origin": initialValues.get("background-origin"),
58
- "background-clip": initialValues.get("background-clip"),
59
- "background-attachment": initialValues.get("background-attachment"),
60
- "background-color": initialValues.get("background-color")
54
+ [backgroundImage.property]: module.exports.initialValues.get(backgroundImage.property),
55
+ [backgroundPosition.property]: module.exports.initialValues.get(backgroundPosition.property),
56
+ [backgroundSize.property]: module.exports.initialValues.get(backgroundSize.property),
57
+ [backgroundRepeat.property]: module.exports.initialValues.get(backgroundRepeat.property),
58
+ [backgroundOrigin.property]: module.exports.initialValues.get(backgroundOrigin.property),
59
+ [backgroundClip.property]: module.exports.initialValues.get(backgroundClip.property),
60
+ [backgroundAttachment.property]: module.exports.initialValues.get(
61
+ backgroundAttachment.property
62
+ ),
63
+ [backgroundColor.property]: module.exports.initialValues.get(backgroundColor.property)
61
64
  };
62
65
  if (l > 1 && i !== l - 1) {
63
66
  bg = {
64
- "background-image": initialValues.get("background-image"),
65
- "background-position": initialValues.get("background-position"),
66
- "background-size": initialValues.get("background-size"),
67
- "background-repeat": initialValues.get("background-repeat"),
68
- "background-origin": initialValues.get("background-origin"),
69
- "background-clip": initialValues.get("background-clip"),
70
- "background-attachment": initialValues.get("background-attachment")
67
+ [backgroundImage.property]: module.exports.initialValues.get(backgroundImage.property),
68
+ [backgroundPosition.property]: module.exports.initialValues.get(
69
+ backgroundPosition.property
70
+ ),
71
+ [backgroundSize.property]: module.exports.initialValues.get(backgroundSize.property),
72
+ [backgroundRepeat.property]: module.exports.initialValues.get(backgroundRepeat.property),
73
+ [backgroundOrigin.property]: module.exports.initialValues.get(backgroundOrigin.property),
74
+ [backgroundClip.property]: module.exports.initialValues.get(backgroundClip.property),
75
+ [backgroundAttachment.property]: module.exports.initialValues.get(
76
+ backgroundAttachment.property
77
+ )
71
78
  };
72
79
  }
73
80
  const bgPosition = [];
@@ -88,15 +95,15 @@ module.exports.parse = function parse(v, opt = {}) {
88
95
  if (parsers.isValidPropertyValue(longhand, part)) {
89
96
  partValid = true;
90
97
  switch (longhand) {
91
- case "background-clip":
92
- case "background-origin": {
98
+ case backgroundClip.property:
99
+ case backgroundOrigin.property: {
93
100
  const parsedValue = value.parse(part, { globalObject });
94
101
  if (parsedValue) {
95
102
  bgBox.push(parsedValue);
96
103
  }
97
104
  break;
98
105
  }
99
- case "background-color": {
106
+ case backgroundColor.property: {
100
107
  if (i !== values.length - 1) {
101
108
  return;
102
109
  }
@@ -106,21 +113,21 @@ module.exports.parse = function parse(v, opt = {}) {
106
113
  }
107
114
  break;
108
115
  }
109
- case "background-position": {
116
+ case backgroundPosition.property: {
110
117
  const parsedValue = value.parse(part, { globalObject });
111
118
  if (parsedValue) {
112
119
  bgPosition.push(parsedValue);
113
120
  }
114
121
  break;
115
122
  }
116
- case "background-repeat": {
123
+ case backgroundRepeat.property: {
117
124
  const parsedValue = value.parse(part, { globalObject });
118
125
  if (parsedValue) {
119
126
  bgRepeat.push(parsedValue);
120
127
  }
121
128
  break;
122
129
  }
123
- case "background-size": {
130
+ case backgroundSize.property: {
124
131
  break;
125
132
  }
126
133
  default: {
@@ -144,15 +151,15 @@ module.exports.parse = function parse(v, opt = {}) {
144
151
  if (parsers.isValidPropertyValue(longhand, part)) {
145
152
  partValid = true;
146
153
  switch (longhand) {
147
- case "background-clip":
148
- case "background-origin": {
154
+ case backgroundClip.property:
155
+ case backgroundOrigin.property: {
149
156
  const parsedValue = value.parse(part, { globalObject });
150
157
  if (parsedValue) {
151
158
  bgBox.push(parsedValue);
152
159
  }
153
160
  break;
154
161
  }
155
- case "background-color": {
162
+ case backgroundColor.property: {
156
163
  if (i !== l - 1) {
157
164
  return;
158
165
  }
@@ -162,17 +169,17 @@ module.exports.parse = function parse(v, opt = {}) {
162
169
  }
163
170
  break;
164
171
  }
165
- case "background-position": {
172
+ case backgroundPosition.property: {
166
173
  break;
167
174
  }
168
- case "background-repeat": {
175
+ case backgroundRepeat.property: {
169
176
  const parsedValue = value.parse(part, { globalObject });
170
177
  if (parsedValue) {
171
178
  bgRepeat.push(parsedValue);
172
179
  }
173
180
  break;
174
181
  }
175
- case "background-size": {
182
+ case backgroundSize.property: {
176
183
  const parsedValue = value.parse(part, { globalObject });
177
184
  if (parsedValue) {
178
185
  bgSize.push(parsedValue);
@@ -194,38 +201,38 @@ module.exports.parse = function parse(v, opt = {}) {
194
201
  }
195
202
  }
196
203
  if (bgPosition.length) {
197
- const { parse: parser } = module.exports.shorthandFor.get("background-position");
204
+ const { parse: parser } = module.exports.shorthandFor.get(backgroundPosition.property);
198
205
  const value = parser(bgPosition.join(" "), { globalObject });
199
206
  if (value) {
200
- bg["background-position"] = value;
207
+ bg[backgroundPosition.property] = value;
201
208
  }
202
209
  }
203
210
  if (bgSize.length) {
204
- const { parse: parser } = module.exports.shorthandFor.get("background-size");
211
+ const { parse: parser } = module.exports.shorthandFor.get(backgroundSize.property);
205
212
  const value = parser(bgSize.join(" "), { globalObject });
206
213
  if (value) {
207
- bg["background-size"] = value;
214
+ bg[backgroundSize.property] = value;
208
215
  }
209
216
  }
210
217
  if (bgRepeat.length) {
211
- const { parse: parser } = module.exports.shorthandFor.get("background-repeat");
218
+ const { parse: parser } = module.exports.shorthandFor.get(backgroundRepeat.property);
212
219
  const value = parser(bgRepeat.join(" "), { globalObject });
213
220
  if (value) {
214
- bg["background-repeat"] = value;
221
+ bg[backgroundRepeat.property] = value;
215
222
  }
216
223
  }
217
224
  if (bgBox.length) {
218
225
  switch (bgBox.length) {
219
226
  case 1: {
220
227
  const [value] = bgBox;
221
- bg["background-origin"] = value;
222
- bg["background-clip"] = value;
228
+ bg[backgroundOrigin.property] = value;
229
+ bg[backgroundClip.property] = value;
223
230
  break;
224
231
  }
225
232
  case 2: {
226
233
  const [value1, value2] = bgBox;
227
- bg["background-origin"] = value1;
228
- bg["background-clip"] = value2;
234
+ bg[backgroundOrigin.property] = value1;
235
+ bg[backgroundClip.property] = value2;
229
236
  break;
230
237
  }
231
238
  default: {
@@ -254,14 +261,14 @@ module.exports.definition = {
254
261
  return;
255
262
  }
256
263
  const bgMap = new Map([
257
- ["background-image", []],
258
- ["background-position", []],
259
- ["background-size", []],
260
- ["background-repeat", []],
261
- ["background-origin", []],
262
- ["background-clip", []],
263
- ["background-attachment", []],
264
- ["background-color", []]
264
+ [backgroundImage.property, []],
265
+ [backgroundPosition.property, []],
266
+ [backgroundSize.property, []],
267
+ [backgroundRepeat.property, []],
268
+ [backgroundOrigin.property, []],
269
+ [backgroundClip.property, []],
270
+ [backgroundAttachment.property, []],
271
+ [backgroundColor.property, []]
265
272
  ]);
266
273
  const backgrounds = [];
267
274
  for (const bgValue of bgValues) {
@@ -271,17 +278,17 @@ module.exports.definition = {
271
278
  const arr = bgMap.get(longhand);
272
279
  arr.push(value);
273
280
  bgMap.set(longhand, arr);
274
- if (value !== initialValues.get(longhand)) {
275
- if (longhand === "background-size") {
281
+ if (value !== module.exports.initialValues.get(longhand)) {
282
+ if (longhand === backgroundSize.property) {
276
283
  bg.push(`/ ${value}`);
277
284
  } else {
278
285
  bg.push(value);
279
286
  }
280
- } else if (longhand === "background-image") {
287
+ } else if (longhand === backgroundImage.property) {
281
288
  if (v === "none") {
282
289
  bg.push(value);
283
290
  }
284
- } else if (longhand === "background-color") {
291
+ } else if (longhand === backgroundColor.property) {
285
292
  if (v === "transparent") {
286
293
  bg.push(value);
287
294
  }
@@ -306,26 +313,26 @@ module.exports.definition = {
306
313
  let l = 0;
307
314
  for (const [longhand] of module.exports.shorthandFor) {
308
315
  const val = this.getPropertyValue(longhand);
309
- if (longhand === "background-image") {
316
+ if (longhand === backgroundImage.property) {
310
317
  if (
311
318
  val === "none" &&
312
319
  v === "none" &&
313
- this.getPropertyValue("background-color") === "transparent"
320
+ this.getPropertyValue(backgroundColor.property) === "transparent"
314
321
  ) {
315
322
  return val;
316
323
  }
317
- if (val !== initialValues.get(longhand)) {
324
+ if (val !== module.exports.initialValues.get(longhand)) {
318
325
  const imgValues = parsers.splitValue(val, {
319
326
  delimiter: ","
320
327
  });
321
328
  l = imgValues.length;
322
329
  bgMap.set(longhand, imgValues);
323
330
  }
324
- } else if (longhand === "background-color") {
325
- if (val !== initialValues.get(longhand) || v.includes(val)) {
331
+ } else if (longhand === backgroundColor.property) {
332
+ if (val !== module.exports.initialValues.get(longhand) || v.includes(val)) {
326
333
  bgMap.set(longhand, [val]);
327
334
  }
328
- } else if (val !== initialValues.get(longhand)) {
335
+ } else if (val !== module.exports.initialValues.get(longhand)) {
329
336
  bgMap.set(
330
337
  longhand,
331
338
  parsers.splitValue(val, {
@@ -335,7 +342,8 @@ module.exports.definition = {
335
342
  }
336
343
  }
337
344
  if (l === 0) {
338
- const [background] = bgMap.get("background-color");
345
+ const bgColArr = bgMap.get(backgroundColor.property);
346
+ const background = bgColArr ? bgColArr[0] : null;
339
347
  if (background) {
340
348
  return background;
341
349
  }
@@ -348,25 +356,25 @@ module.exports.definition = {
348
356
  for (const [longhand, values] of bgMap) {
349
357
  for (let i = 0; i < l; i++) {
350
358
  switch (longhand) {
351
- case "background-color": {
359
+ case backgroundColor.property: {
352
360
  if (i === l - 1) {
353
361
  const value = values[0];
354
362
  if (parsers.hasVarFunc(value)) {
355
363
  return "";
356
364
  }
357
- if (value && value !== initialValues.get(longhand)) {
365
+ if (value && value !== module.exports.initialValues.get(longhand)) {
358
366
  const bgValue = bgValues[i];
359
367
  bgValue.push(value);
360
368
  }
361
369
  }
362
370
  break;
363
371
  }
364
- case "background-size": {
372
+ case backgroundSize.property: {
365
373
  const value = values[i];
366
374
  if (parsers.hasVarFunc(value)) {
367
375
  return "";
368
376
  }
369
- if (value && value !== initialValues.get(longhand)) {
377
+ if (value && value !== module.exports.initialValues.get(longhand)) {
370
378
  const bgValue = bgValues[i];
371
379
  bgValue.push(`/ ${value}`);
372
380
  }
@@ -377,7 +385,7 @@ module.exports.definition = {
377
385
  if (parsers.hasVarFunc(value)) {
378
386
  return "";
379
387
  }
380
- if (value && value !== initialValues.get(longhand)) {
388
+ if (value && value !== module.exports.initialValues.get(longhand)) {
381
389
  const bgValue = bgValues[i];
382
390
  bgValue.push(value);
383
391
  }
@@ -394,3 +402,5 @@ module.exports.definition = {
394
402
  enumerable: true,
395
403
  configurable: true
396
404
  };
405
+
406
+ module.exports.property = property;
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
5
5
  const property = "background-attachment";
6
6
  const shorthand = "background";
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,17 +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;
22
- switch (type) {
23
- case "GlobalKeyword":
24
- case "Identifier": {
25
- parsedValues.push(name);
26
- break;
27
- }
28
- default: {
29
- return;
30
- }
21
+ const parsedValue = parsers.resolveKeywordValue(value);
22
+ if (!parsedValue) {
23
+ return;
31
24
  }
25
+ parsedValues.push(parsedValue);
32
26
  } else if (typeof value === "string") {
33
27
  parsedValues.push(value);
34
28
  }
@@ -49,9 +43,10 @@ module.exports.definition = {
49
43
  globalObject: this._global
50
44
  });
51
45
  if (typeof val === "string") {
52
- const shorthandPriority = this._priorities.get(shorthand);
53
- const prior = this._priorities.get(property) ?? "";
54
- const priority = shorthandPriority && prior ? "" : prior;
46
+ const priority =
47
+ !this._priorities.get(shorthand) && this._priorities.has(property)
48
+ ? this._priorities.get(property)
49
+ : "";
55
50
  this._setProperty(property, val, priority);
56
51
  }
57
52
  }
@@ -62,3 +57,5 @@ module.exports.definition = {
62
57
  enumerable: true,
63
58
  configurable: true
64
59
  };
60
+
61
+ module.exports.property = property;
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
5
5
  const property = "background-clip";
6
6
  const shorthand = "background";
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,17 +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;
22
- switch (type) {
23
- case "GlobalKeyword":
24
- case "Identifier": {
25
- parsedValues.push(name);
26
- break;
27
- }
28
- default: {
29
- return;
30
- }
21
+ const parsedValue = parsers.resolveKeywordValue(value);
22
+ if (!parsedValue) {
23
+ return;
31
24
  }
25
+ parsedValues.push(parsedValue);
32
26
  } else if (typeof value === "string") {
33
27
  parsedValues.push(value);
34
28
  }
@@ -49,9 +43,10 @@ module.exports.definition = {
49
43
  globalObject: this._global
50
44
  });
51
45
  if (typeof val === "string") {
52
- const shorthandPriority = this._priorities.get(shorthand);
53
- const prior = this._priorities.get(property) ?? "";
54
- const priority = shorthandPriority && prior ? "" : prior;
46
+ const priority =
47
+ !this._priorities.get(shorthand) && this._priorities.has(property)
48
+ ? this._priorities.get(property)
49
+ : "";
55
50
  this._setProperty(property, val, priority);
56
51
  }
57
52
  }
@@ -62,3 +57,5 @@ module.exports.definition = {
62
57
  enumerable: true,
63
58
  configurable: true
64
59
  };
60
+
61
+ module.exports.property = property;
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
5
5
  const property = "background-color";
6
6
  const shorthand = "background";
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,15 +15,7 @@ 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;
19
- switch (type) {
20
- case "GlobalKeyword": {
21
- return name;
22
- }
23
- default: {
24
- return parsers.parseColor(value);
25
- }
26
- }
18
+ return parsers.resolveColorValue(value);
27
19
  } else if (typeof value === "string") {
28
20
  return value;
29
21
  }
@@ -40,9 +32,10 @@ module.exports.definition = {
40
32
  globalObject: this._global
41
33
  });
42
34
  if (typeof val === "string") {
43
- const shorthandPriority = this._priorities.get(shorthand);
44
- const prior = this._priorities.get(property) ?? "";
45
- const priority = shorthandPriority && prior ? "" : prior;
35
+ const priority =
36
+ !this._priorities.get(shorthand) && this._priorities.has(property)
37
+ ? this._priorities.get(property)
38
+ : "";
46
39
  this._setProperty(property, val, priority);
47
40
  }
48
41
  }
@@ -53,3 +46,5 @@ module.exports.definition = {
53
46
  enumerable: true,
54
47
  configurable: true
55
48
  };
49
+
50
+ module.exports.property = property;
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
5
5
  const property = "background-image";
6
6
  const shorthand = "background";
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,29 +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;
22
- switch (type) {
23
- case "GlobalKeyword":
24
- case "Identifier": {
25
- parsedValues.push(name);
26
- break;
27
- }
28
- case "Url": {
29
- const parsedValue = parsers.parseUrl(value);
30
- if (!parsedValue) {
31
- return;
32
- }
33
- parsedValues.push(parsedValue);
34
- break;
35
- }
36
- default: {
37
- const parsedValue = parsers.parseGradient(value);
38
- if (!parsedValue) {
39
- return;
40
- }
41
- parsedValues.push(parsedValue);
42
- }
21
+ const parsedValue = parsers.resolveGradientUrlValue(value);
22
+ if (!parsedValue) {
23
+ return;
43
24
  }
25
+ parsedValues.push(parsedValue);
44
26
  } else if (typeof value === "string") {
45
27
  parsedValues.push(value);
46
28
  } else {
@@ -63,9 +45,10 @@ module.exports.definition = {
63
45
  globalObject: this._global
64
46
  });
65
47
  if (typeof val === "string") {
66
- const shorthandPriority = this._priorities.get(shorthand);
67
- const prior = this._priorities.get(property) ?? "";
68
- const priority = shorthandPriority && prior ? "" : prior;
48
+ const priority =
49
+ !this._priorities.get(shorthand) && this._priorities.has(property)
50
+ ? this._priorities.get(property)
51
+ : "";
69
52
  this._setProperty(property, val, priority);
70
53
  }
71
54
  }
@@ -76,3 +59,5 @@ module.exports.definition = {
76
59
  enumerable: true,
77
60
  configurable: true
78
61
  };
62
+
63
+ module.exports.property = property;
@@ -5,7 +5,7 @@ const parsers = require("../parsers");
5
5
  const property = "background-origin";
6
6
  const shorthand = "background";
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,17 +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;
22
- switch (type) {
23
- case "GlobalKeyword":
24
- case "Identifier": {
25
- parsedValues.push(name);
26
- break;
27
- }
28
- default: {
29
- return;
30
- }
21
+ const parsedValue = parsers.resolveKeywordValue(value);
22
+ if (!parsedValue) {
23
+ return;
31
24
  }
25
+ parsedValues.push(parsedValue);
32
26
  } else if (typeof value === "string") {
33
27
  parsedValues.push(value);
34
28
  }
@@ -49,9 +43,10 @@ module.exports.definition = {
49
43
  globalObject: this._global
50
44
  });
51
45
  if (typeof val === "string") {
52
- const shorthandPriority = this._priorities.get(shorthand);
53
- const prior = this._priorities.get(property) ?? "";
54
- const priority = shorthandPriority && prior ? "" : prior;
46
+ const priority =
47
+ !this._priorities.get(shorthand) && this._priorities.has(property)
48
+ ? this._priorities.get(property)
49
+ : "";
55
50
  this._setProperty(property, val, priority);
56
51
  }
57
52
  }
@@ -62,3 +57,5 @@ module.exports.definition = {
62
57
  enumerable: true,
63
58
  configurable: true
64
59
  };
60
+
61
+ module.exports.property = property;