cssstyle 5.3.6 → 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 +360 -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 +176 -309
  7. package/lib/parsers.js +155 -191
  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 +27 -25
  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} +27 -23
  19. package/lib/properties/{webkitBorderAfterColor.js → borderBlockStartColor.js} +27 -23
  20. package/lib/properties/borderBottom.js +40 -36
  21. package/lib/properties/borderBottomColor.js +26 -22
  22. package/lib/properties/borderBottomStyle.js +26 -22
  23. package/lib/properties/borderBottomWidth.js +29 -25
  24. package/lib/properties/borderCollapse.js +26 -22
  25. package/lib/properties/borderColor.js +36 -33
  26. package/lib/properties/{webkitBorderStartColor.js → borderInlineEndColor.js} +27 -23
  27. package/lib/properties/borderInlineStartColor.js +49 -0
  28. package/lib/properties/borderLeft.js +40 -36
  29. package/lib/properties/borderLeftColor.js +26 -22
  30. package/lib/properties/borderLeftStyle.js +26 -22
  31. package/lib/properties/borderLeftWidth.js +29 -25
  32. package/lib/properties/borderRight.js +40 -36
  33. package/lib/properties/borderRightColor.js +26 -22
  34. package/lib/properties/borderRightStyle.js +26 -22
  35. package/lib/properties/borderRightWidth.js +29 -25
  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 +26 -22
  40. package/lib/properties/borderTopStyle.js +26 -22
  41. package/lib/properties/borderTopWidth.js +29 -25
  42. package/lib/properties/borderWidth.js +36 -33
  43. package/lib/properties/bottom.js +28 -24
  44. package/lib/properties/clear.js +26 -22
  45. package/lib/properties/clip.js +37 -31
  46. package/lib/properties/color.js +26 -22
  47. package/lib/properties/display.js +36 -30
  48. package/lib/properties/flex.js +53 -45
  49. package/lib/properties/flexBasis.js +29 -27
  50. package/lib/properties/flexGrow.js +29 -27
  51. package/lib/properties/flexShrink.js +29 -27
  52. package/lib/properties/float.js +26 -22
  53. package/lib/properties/floodColor.js +26 -22
  54. package/lib/properties/font.js +89 -118
  55. package/lib/properties/fontFamily.js +38 -33
  56. package/lib/properties/fontSize.js +30 -28
  57. package/lib/properties/fontStyle.js +38 -34
  58. package/lib/properties/fontVariant.js +35 -33
  59. package/lib/properties/fontWeight.js +34 -32
  60. package/lib/properties/height.js +29 -25
  61. package/lib/properties/left.js +28 -24
  62. package/lib/properties/lightingColor.js +26 -22
  63. package/lib/properties/lineHeight.js +29 -27
  64. package/lib/properties/margin.js +40 -34
  65. package/lib/properties/marginBottom.js +31 -28
  66. package/lib/properties/marginLeft.js +31 -28
  67. package/lib/properties/marginRight.js +31 -28
  68. package/lib/properties/marginTop.js +31 -28
  69. package/lib/properties/opacity.js +28 -24
  70. package/lib/properties/outlineColor.js +26 -22
  71. package/lib/properties/padding.js +40 -34
  72. package/lib/properties/paddingBottom.js +32 -29
  73. package/lib/properties/paddingLeft.js +32 -29
  74. package/lib/properties/paddingRight.js +32 -29
  75. package/lib/properties/paddingTop.js +32 -29
  76. package/lib/properties/right.js +28 -24
  77. package/lib/properties/stopColor.js +26 -22
  78. package/lib/properties/{webkitBorderBeforeColor.js → textEmphasisColor.js} +27 -23
  79. package/lib/properties/top.js +28 -25
  80. package/lib/properties/webkitTextFillColor.js +26 -22
  81. package/lib/properties/webkitTextStrokeColor.js +26 -22
  82. package/lib/properties/width.js +29 -25
  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 -6638
  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
package/lib/normalize.js CHANGED
@@ -3,6 +3,8 @@
3
3
  const propertyDefinitions = require("./generated/propertyDefinitions");
4
4
  const { hasVarFunc, isGlobalKeyword, isValidPropertyValue, splitValue } = require("./parsers");
5
5
  const background = require("./properties/background");
6
+ const backgroundColor = require("./properties/backgroundColor");
7
+ const backgroundSize = require("./properties/backgroundSize");
6
8
  const border = require("./properties/border");
7
9
  const borderWidth = require("./properties/borderWidth");
8
10
  const borderStyle = require("./properties/borderStyle");
@@ -16,19 +18,8 @@ const font = require("./properties/font");
16
18
  const margin = require("./properties/margin");
17
19
  const padding = require("./properties/padding");
18
20
 
19
- /* constants */
20
- const BACKGROUND = "background";
21
- const BACKGROUND_COLOR = "background-color";
22
- const BACKGROUND_SIZE = "background-size";
23
- const BORDER = "border";
24
- const BORDER_BOTTOM = "border-bottom";
25
- const BORDER_COLOR = "border-color";
21
+ // Constants
26
22
  const BORDER_IMAGE = "border-image";
27
- const BORDER_LEFT = "border-left";
28
- const BORDER_RIGHT = "border-right";
29
- const BORDER_STYLE = "border-style";
30
- const BORDER_TOP = "border-top";
31
- const BORDER_WIDTH = "border-width";
32
23
  const TOP = "top";
33
24
  const RIGHT = "right";
34
25
  const BOTTOM = "bottom";
@@ -44,37 +35,31 @@ const TRBL_INDICES = {
44
35
  [LEFT]: 3
45
36
  };
46
37
 
47
- /* shorthands */
48
38
  const shorthandProperties = new Map([
49
- [BACKGROUND, background],
39
+ [background.property, background],
50
40
  [
51
- BORDER,
41
+ border.property,
52
42
  {
53
- definition: border.definition,
43
+ descriptor: border.descriptor,
54
44
  parse: border.parse,
55
- shorthandFor: new Map([
56
- ...border.shorthandFor,
57
- ...border.positionShorthandFor,
58
- [BORDER_IMAGE, null]
59
- ])
45
+ shorthandFor: new Map([...border.shorthandFor, ...border.positionShorthandFor, [BORDER_IMAGE, null]])
60
46
  }
61
47
  ],
62
- [BORDER_WIDTH, borderWidth],
63
- [BORDER_STYLE, borderStyle],
64
- [BORDER_COLOR, borderColor],
65
- [BORDER_TOP, borderTop],
66
- [BORDER_RIGHT, borderRight],
67
- [BORDER_BOTTOM, borderBottom],
68
- [BORDER_LEFT, borderLeft],
48
+ [borderWidth.property, borderWidth],
49
+ [borderStyle.property, borderStyle],
50
+ [borderColor.property, borderColor],
51
+ [borderTop.property, borderTop],
52
+ [borderRight.property, borderRight],
53
+ [borderBottom.property, borderBottom],
54
+ [borderLeft.property, borderLeft],
69
55
  ["flex", flex],
70
56
  ["font", font],
71
57
  ["margin", margin],
72
58
  ["padding", padding]
73
59
  ]);
74
60
 
75
- /* borders */
76
61
  const borderProperties = new Set([
77
- BORDER,
62
+ border.property,
78
63
  BORDER_IMAGE,
79
64
  ...border.shorthandFor.keys(),
80
65
  ...border.positionShorthandFor.keys(),
@@ -83,44 +68,78 @@ const borderProperties = new Set([
83
68
  ...borderBottom.shorthandFor.keys(),
84
69
  ...borderLeft.shorthandFor.keys()
85
70
  ]);
86
- const borderPositions = new Set([TOP, RIGHT, BOTTOM, LEFT]);
71
+
87
72
  const borderLines = new Set([WIDTH, STYLE, COLOR]);
88
73
 
74
+ const borderPositions = new Set([TOP, RIGHT, BOTTOM, LEFT]);
75
+
76
+ const borderCollectionConfig = {
77
+ [WIDTH]: {
78
+ shorthand: borderWidth.property,
79
+ generator: generateBorderLineShorthand
80
+ },
81
+ [STYLE]: {
82
+ shorthand: borderStyle.property,
83
+ generator: generateBorderLineShorthand
84
+ },
85
+ [COLOR]: {
86
+ shorthand: borderColor.property,
87
+ generator: generateBorderLineShorthand
88
+ },
89
+ [TOP]: {
90
+ shorthand: borderTop.property,
91
+ generator: generateBorderPositionShorthand
92
+ },
93
+ [RIGHT]: {
94
+ shorthand: borderRight.property,
95
+ generator: generateBorderPositionShorthand
96
+ },
97
+ [BOTTOM]: {
98
+ shorthand: borderBottom.property,
99
+ generator: generateBorderPositionShorthand
100
+ },
101
+ [LEFT]: {
102
+ shorthand: borderLeft.property,
103
+ generator: generateBorderPositionShorthand
104
+ }
105
+ };
106
+
89
107
  /**
90
108
  * Ensures consistent object shape.
91
109
  *
92
110
  * @param {string} property - The property name.
93
111
  * @param {string} [value=""] - The property value.
94
112
  * @param {string} [priority=""] - The priority.
95
- * @returns {Object} The property item object.
113
+ * @returns {object} The property item object.
96
114
  */
97
- const createPropertyItem = (property, value = "", priority = "") => ({
98
- property,
99
- value,
100
- priority
101
- });
115
+ function createPropertyItem(property, value = "", priority = "") {
116
+ return {
117
+ property,
118
+ value,
119
+ priority
120
+ };
121
+ }
102
122
 
103
123
  /**
104
124
  * Retrieves a property item from the map or creates a default one if it doesn't exist.
105
125
  *
106
126
  * @param {string} property - The name of the property.
107
127
  * @param {Map} properties - The map containing all properties.
108
- * @returns {Object} The property item containing name, value, and priority.
128
+ * @returns {object} The property item containing name, value, and priority.
109
129
  */
110
- const getPropertyItem = (property, properties) => {
130
+ function getPropertyItem(property, properties) {
111
131
  const propertyItem = properties.get(property) ?? createPropertyItem(property);
112
132
  return propertyItem;
113
- };
133
+ }
114
134
 
115
135
  /**
116
- * Calculates the value for a specific position (top, right, bottom, left)
117
- * based on the array of values provided for a shorthand property.
136
+ * Calculates the value for a specific position from shorthand values.
118
137
  *
119
138
  * @param {string[]} positionValues - The values extracted from the shorthand property.
120
139
  * @param {string} position - The specific position (top, right, bottom, left) to retrieve.
121
140
  * @returns {string} The calculated value for the position.
122
141
  */
123
- const getPositionValue = (positionValues, position) => {
142
+ function getPositionValue(positionValues, position) {
124
143
  const [val1, val2, val3, val4] = positionValues;
125
144
  const index = TRBL_INDICES[position] ?? -1;
126
145
  // If a specific position (top, right, bottom, left) is requested.
@@ -183,26 +202,25 @@ const getPositionValue = (positionValues, position) => {
183
202
  return val1;
184
203
  }
185
204
  }
186
- };
205
+ }
187
206
 
188
207
  /**
189
208
  * Replaces the background shorthand property based on individual longhand values.
190
209
  *
191
210
  * @param {string} property - The specific background longhand property being updated.
192
211
  * @param {Map} properties - The map of all properties.
193
- * @param {Object} opt - Parsing options including global object and configurations.
194
212
  * @returns {string} The constructed background shorthand string.
195
213
  */
196
- const replaceBackgroundShorthand = (property, properties, opt) => {
214
+ function replaceBackgroundShorthand(property, properties) {
197
215
  const { value: propertyValue } = properties.get(property);
198
- const parsedValue = background.shorthandFor.get(property).parse(propertyValue, opt);
216
+ const parsedValue = background.shorthandFor.get(property).parse(propertyValue);
199
217
  const values = splitValue(parsedValue, {
200
218
  delimiter: ","
201
219
  });
202
- const { value: shorthandValue } = properties.get(BACKGROUND);
203
- const bgValues = background.parse(shorthandValue, opt);
220
+ const { value: shorthandValue } = properties.get(background.property);
221
+ const bgValues = background.parse(shorthandValue);
204
222
  const bgLength = bgValues.length;
205
- if (property === BACKGROUND_COLOR) {
223
+ if (property === backgroundColor.property) {
206
224
  bgValues[bgLength - 1][property] = parsedValue[0];
207
225
  } else {
208
226
  for (let i = 0; i < bgLength; i++) {
@@ -216,7 +234,7 @@ const replaceBackgroundShorthand = (property, properties, opt) => {
216
234
  if (!value || value === background.initialValues.get(longhand)) {
217
235
  continue;
218
236
  }
219
- if (longhand === BACKGROUND_SIZE) {
237
+ if (longhand === backgroundSize.property) {
220
238
  bg.push(`/ ${value}`);
221
239
  } else {
222
240
  bg.push(value);
@@ -225,7 +243,7 @@ const replaceBackgroundShorthand = (property, properties, opt) => {
225
243
  backgrounds.push(bg.join(" "));
226
244
  }
227
245
  return backgrounds.join(", ");
228
- };
246
+ }
229
247
 
230
248
  /**
231
249
  * Checks if a property value matches the value within a border shorthand.
@@ -233,40 +251,29 @@ const replaceBackgroundShorthand = (property, properties, opt) => {
233
251
  * @param {string} property - The property to check.
234
252
  * @param {string} value - The value to compare.
235
253
  * @param {string} shorthandValue - The shorthand string to parse and compare against.
236
- * @param {Object} [opt={}] - Parsing options.
237
254
  * @returns {boolean} True if the value matches the shorthand's value.
238
255
  */
239
- const matchesBorderShorthandValue = (property, value, shorthandValue, opt = {}) => {
240
- const { globalObject, options } = opt;
241
- const obj = border.parse(shorthandValue, {
242
- globalObject,
243
- options
244
- });
256
+ function matchesBorderShorthandValue(property, value, shorthandValue) {
257
+ const obj = border.parse(shorthandValue);
245
258
  if (Object.hasOwn(obj, property)) {
246
259
  return value === obj[property];
247
260
  }
248
261
  return value === border.initialValues.get(property);
249
- };
262
+ }
250
263
 
251
264
  /**
252
265
  * Replaces or updates a value within a border shorthand string.
253
266
  *
254
267
  * @param {string} value - The new value to insert.
255
268
  * @param {string} shorthandValue - The existing shorthand string.
256
- * @param {Object} [opt={}] - Parsing options.
257
269
  * @returns {string} The updated border shorthand string.
258
270
  */
259
- const replaceBorderShorthandValue = (value, shorthandValue, opt = {}) => {
260
- const { globalObject, options } = opt;
271
+ function replaceBorderShorthandValue(value, shorthandValue) {
261
272
  const borderFirstInitialKey = border.initialValues.keys().next().value;
262
273
  const borderFirstInitialValue = border.initialValues.get(borderFirstInitialKey);
263
- const parseOpt = {
264
- globalObject,
265
- options
266
- };
267
- const valueObj = border.parse(value, parseOpt);
274
+ const valueObj = border.parse(value);
268
275
  const shorthandObj = shorthandValue
269
- ? border.parse(shorthandValue, parseOpt)
276
+ ? border.parse(shorthandValue)
270
277
  : {
271
278
  [borderFirstInitialKey]: borderFirstInitialValue
272
279
  };
@@ -287,16 +294,13 @@ const replaceBorderShorthandValue = (value, shorthandValue, opt = {}) => {
287
294
  }
288
295
  } else {
289
296
  shorthandObj[key] = parsedValue;
290
- if (
291
- shorthandObj[borderFirstInitialKey] &&
292
- shorthandObj[borderFirstInitialKey] === borderFirstInitialValue
293
- ) {
297
+ if (shorthandObj[borderFirstInitialKey] && shorthandObj[borderFirstInitialKey] === borderFirstInitialValue) {
294
298
  delete shorthandObj[borderFirstInitialKey];
295
299
  }
296
300
  }
297
301
  }
298
302
  return Object.values(shorthandObj).join(" ");
299
- };
303
+ }
300
304
 
301
305
  /**
302
306
  * Replaces a value at a specific position (top, right, bottom, left) within a position shorthand.
@@ -306,7 +310,7 @@ const replaceBorderShorthandValue = (value, shorthandValue, opt = {}) => {
306
310
  * @param {string} position - The position to update.
307
311
  * @returns {string} The updated shorthand string.
308
312
  */
309
- const replacePositionValue = (value, positionValues, position) => {
313
+ function replacePositionValue(value, positionValues, position) {
310
314
  const index = TRBL_INDICES[position] ?? -1;
311
315
  let currentValues = positionValues;
312
316
  if (index !== -1) {
@@ -497,36 +501,22 @@ const replacePositionValue = (value, positionValues, position) => {
497
501
  return val1;
498
502
  }
499
503
  }
500
- };
504
+ }
501
505
 
502
506
  /**
503
507
  * Handles border property preparation when the value is a string.
504
508
  *
505
- * @param {Object} params - The parameters object.
509
+ * @param {object} params - The parameters object.
506
510
  * @param {string} params.property - The property name.
507
511
  * @param {string} params.value - The property value.
508
512
  * @param {string} params.priority - The property priority.
509
513
  * @param {Map} params.properties - The map of properties.
510
- * @param {Object} params.parts - The split property name parts.
511
- * @param {Object} params.opt - Parsing options.
514
+ * @param {object} params.parts - The split property name parts.
512
515
  * @param {Map} params.borderItems - The map to store processed border items.
513
516
  */
514
- const prepareBorderStringValue = ({
515
- property,
516
- value,
517
- priority,
518
- properties,
519
- parts,
520
- opt,
521
- borderItems
522
- }) => {
517
+ function prepareBorderStringValue({ property, value, priority, properties, parts, borderItems }) {
523
518
  const { prop1, prop2, prop3 } = parts;
524
- const { globalObject, options } = opt;
525
- const parseOpt = {
526
- globalObject,
527
- options
528
- };
529
- const shorthandItem = getPropertyItem(BORDER, properties);
519
+ const shorthandItem = getPropertyItem(border.property, properties);
530
520
  const imageItem = getPropertyItem(BORDER_IMAGE, properties);
531
521
  // Handle longhand properties.
532
522
  if (prop3) {
@@ -554,23 +544,17 @@ const prepareBorderStringValue = ({
554
544
  positionItem.value = "";
555
545
  }
556
546
  } else {
557
- if (
558
- shorthandItem.value &&
559
- !matchesBorderShorthandValue(lineProperty, propertyValue, shorthandItem.value, parseOpt)
560
- ) {
547
+ if (shorthandItem.value && !matchesBorderShorthandValue(lineProperty, propertyValue, shorthandItem.value)) {
561
548
  shorthandItem.value = "";
562
549
  }
563
550
  if (lineItem.value) {
564
551
  lineItem.value = replacePositionValue(propertyValue, splitValue(lineItem.value), prop2);
565
552
  }
566
- if (
567
- positionItem.value &&
568
- !matchesBorderShorthandValue(lineProperty, propertyValue, positionItem.value, parseOpt)
569
- ) {
553
+ if (positionItem.value && !matchesBorderShorthandValue(lineProperty, propertyValue, positionItem.value)) {
570
554
  positionItem.value = "";
571
555
  }
572
556
  }
573
- borderItems.set(BORDER, shorthandItem);
557
+ borderItems.set(border.property, shorthandItem);
574
558
  borderItems.set(BORDER_IMAGE, imageItem);
575
559
  borderItems.set(lineProperty, lineItem);
576
560
  borderItems.set(positionProperty, positionItem);
@@ -607,28 +591,16 @@ const prepareBorderStringValue = ({
607
591
  lineColorItem.value = "";
608
592
  }
609
593
  } else {
610
- if (
611
- shorthandItem.value &&
612
- !matchesBorderShorthandValue(property, propertyValue, shorthandItem.value, parseOpt)
613
- ) {
594
+ if (shorthandItem.value && !matchesBorderShorthandValue(property, propertyValue, shorthandItem.value)) {
614
595
  shorthandItem.value = "";
615
596
  }
616
- if (
617
- lineWidthItem.value &&
618
- isValidPropertyValue(lineWidthProperty, propertyValue, globalObject)
619
- ) {
597
+ if (lineWidthItem.value && isValidPropertyValue(lineWidthProperty, propertyValue)) {
620
598
  lineWidthItem.value = propertyValue;
621
599
  }
622
- if (
623
- lineStyleItem.value &&
624
- isValidPropertyValue(lineStyleProperty, propertyValue, globalObject)
625
- ) {
600
+ if (lineStyleItem.value && isValidPropertyValue(lineStyleProperty, propertyValue)) {
626
601
  lineStyleItem.value = propertyValue;
627
602
  }
628
- if (
629
- lineColorItem.value &&
630
- isValidPropertyValue(lineColorProperty, propertyValue, globalObject)
631
- ) {
603
+ if (lineColorItem.value && isValidPropertyValue(lineColorProperty, propertyValue)) {
632
604
  lineColorItem.value = propertyValue;
633
605
  }
634
606
  }
@@ -639,7 +611,7 @@ const prepareBorderStringValue = ({
639
611
  longhandItem.priority = priority;
640
612
  borderItems.set(longhandProperty, longhandItem);
641
613
  }
642
- borderItems.set(BORDER, shorthandItem);
614
+ borderItems.set(border.property, shorthandItem);
643
615
  borderItems.set(BORDER_IMAGE, imageItem);
644
616
  borderItems.set(lineWidthProperty, lineWidthItem);
645
617
  borderItems.set(lineStyleProperty, lineStyleItem);
@@ -665,11 +637,7 @@ const prepareBorderStringValue = ({
665
637
  const longhandProperty = `${prop1}-${position}-${prop2}`;
666
638
  const longhandItem = getPropertyItem(longhandProperty, properties);
667
639
  if (propertyValue) {
668
- positionItem.value = replaceBorderShorthandValue(
669
- propertyValue,
670
- positionItem.value,
671
- parseOpt
672
- );
640
+ positionItem.value = replaceBorderShorthandValue(propertyValue, positionItem.value);
673
641
  } else {
674
642
  positionItem.value = "";
675
643
  }
@@ -678,7 +646,7 @@ const prepareBorderStringValue = ({
678
646
  borderItems.set(positionProperty, positionItem);
679
647
  borderItems.set(longhandProperty, longhandItem);
680
648
  }
681
- borderItems.set(BORDER, shorthandItem);
649
+ borderItems.set(border.property, shorthandItem);
682
650
  borderItems.set(BORDER_IMAGE, imageItem);
683
651
  borderItems.set(lineProperty, lineItem);
684
652
  // Handle border shorthand.
@@ -709,30 +677,24 @@ const prepareBorderStringValue = ({
709
677
  borderItems.set(property, shorthandItem);
710
678
  borderItems.set(BORDER_IMAGE, imageItem);
711
679
  }
712
- };
680
+ }
713
681
 
714
682
  /**
715
683
  * Handles border property preparation when the value is an array.
716
684
  *
717
- * @param {Object} params - The parameters object.
685
+ * @param {object} params - The parameters object.
718
686
  * @param {Array} params.value - The property value.
719
687
  * @param {string} params.priority - The property priority.
720
688
  * @param {Map} params.properties - The map of properties.
721
- * @param {Object} params.parts - The split property name parts.
722
- * @param {Object} params.opt - Parsing options.
689
+ * @param {object} params.parts - The split property name parts.
723
690
  * @param {Map} params.borderItems - The map to store processed border items.
724
691
  */
725
- const prepareBorderArrayValue = ({ value, priority, properties, parts, opt, borderItems }) => {
692
+ function prepareBorderArrayValue({ value, priority, properties, parts, borderItems }) {
726
693
  const { prop1, prop2 } = parts;
727
- const { globalObject, options } = opt;
728
- const parseOpt = {
729
- globalObject,
730
- options
731
- };
732
694
  if (!value.length || !borderLines.has(prop2)) {
733
695
  return;
734
696
  }
735
- const shorthandItem = getPropertyItem(BORDER, properties);
697
+ const shorthandItem = getPropertyItem(border.property, properties);
736
698
  const imageItem = getPropertyItem(BORDER_IMAGE, properties);
737
699
  const lineProperty = `${prop1}-${prop2}`;
738
700
  const lineItem = getPropertyItem(lineProperty, properties);
@@ -742,11 +704,7 @@ const prepareBorderArrayValue = ({ value, priority, properties, parts, opt, bord
742
704
  if (hasVarFunc(shorthandItem.value)) {
743
705
  shorthandItem.value = "";
744
706
  } else if (propertyValue) {
745
- shorthandItem.value = replaceBorderShorthandValue(
746
- propertyValue,
747
- shorthandItem.value,
748
- parseOpt
749
- );
707
+ shorthandItem.value = replaceBorderShorthandValue(propertyValue, shorthandItem.value);
750
708
  }
751
709
  }
752
710
  } else {
@@ -790,11 +748,7 @@ const prepareBorderArrayValue = ({ value, priority, properties, parts, opt, bord
790
748
  const positionProperty = `${prop1}-${position}`;
791
749
  const positionItem = getPropertyItem(positionProperty, properties);
792
750
  if (positionItem.value && positionValues[position]) {
793
- positionItem.value = replaceBorderShorthandValue(
794
- positionValues[position],
795
- positionItem.value,
796
- parseOpt
797
- );
751
+ positionItem.value = replaceBorderShorthandValue(positionValues[position], positionItem.value);
798
752
  }
799
753
  const longhandProperty = `${positionProperty}-${prop2}`;
800
754
  const longhandItem = getPropertyItem(longhandProperty, properties);
@@ -803,45 +757,31 @@ const prepareBorderArrayValue = ({ value, priority, properties, parts, opt, bord
803
757
  borderItems.set(positionProperty, positionItem);
804
758
  borderItems.set(longhandProperty, longhandItem);
805
759
  }
806
- borderItems.set(BORDER, shorthandItem);
760
+ borderItems.set(border.property, shorthandItem);
807
761
  borderItems.set(BORDER_IMAGE, imageItem);
808
762
  borderItems.set(lineProperty, lineItem);
809
- };
763
+ }
810
764
 
811
765
  /**
812
766
  * Handles border property preparation when the value is an object.
813
767
  *
814
- * @param {Object} params - The parameters object.
768
+ * @param {object} params - The parameters object.
815
769
  * @param {string} params.property - The property name.
816
- * @param {Object} params.value - The property value.
770
+ * @param {object} params.value - The property value.
817
771
  * @param {string} params.priority - The property priority.
818
772
  * @param {Map} params.properties - The map of properties.
819
- * @param {Object} params.parts - The split property name parts.
820
- * @param {Object} params.opt - Parsing options.
773
+ * @param {object} params.parts - The split property name parts.
821
774
  * @param {Map} params.borderItems - The map to store processed border items.
822
775
  */
823
- const prepareBorderObjectValue = ({
824
- property,
825
- value,
826
- priority,
827
- properties,
828
- parts,
829
- opt,
830
- borderItems
831
- }) => {
776
+ function prepareBorderObjectValue({ property, value, priority, properties, parts, borderItems }) {
832
777
  const { prop1, prop2 } = parts;
833
- const { globalObject, options } = opt;
834
- const parseOpt = {
835
- globalObject,
836
- options
837
- };
838
778
  const imageItem = getPropertyItem(BORDER_IMAGE, properties);
839
779
  // Handle position shorthands.
840
780
  if (prop2) {
841
781
  if (!borderPositions.has(prop2)) {
842
782
  return;
843
783
  }
844
- const shorthandItem = getPropertyItem(BORDER, properties);
784
+ const shorthandItem = getPropertyItem(border.property, properties);
845
785
  const lineWidthProperty = `${prop1}-width`;
846
786
  const lineWidthItem = getPropertyItem(lineWidthProperty, properties);
847
787
  const lineStyleProperty = `${prop1}-style`;
@@ -852,7 +792,7 @@ const prepareBorderObjectValue = ({
852
792
  const positionItem = getPropertyItem(positionProperty, properties);
853
793
  if (shorthandItem.value) {
854
794
  for (const positionValue of Object.values(value)) {
855
- if (!matchesBorderShorthandValue(property, positionValue, shorthandItem.value, parseOpt)) {
795
+ if (!matchesBorderShorthandValue(property, positionValue, shorthandItem.value)) {
856
796
  shorthandItem.value = "";
857
797
  break;
858
798
  }
@@ -867,29 +807,17 @@ const prepareBorderObjectValue = ({
867
807
  ? value[longhandProperty]
868
808
  : border.initialValues.get(`${prop1}-${line}`);
869
809
  if (line === WIDTH && lineWidthItem.value) {
870
- lineWidthItem.value = replacePositionValue(
871
- itemValue,
872
- splitValue(lineWidthItem.value),
873
- prop2
874
- );
810
+ lineWidthItem.value = replacePositionValue(itemValue, splitValue(lineWidthItem.value), prop2);
875
811
  } else if (line === STYLE && lineStyleItem.value) {
876
- lineStyleItem.value = replacePositionValue(
877
- itemValue,
878
- splitValue(lineStyleItem.value),
879
- prop2
880
- );
812
+ lineStyleItem.value = replacePositionValue(itemValue, splitValue(lineStyleItem.value), prop2);
881
813
  } else if (line === COLOR && lineColorItem.value) {
882
- lineColorItem.value = replacePositionValue(
883
- itemValue,
884
- splitValue(lineColorItem.value),
885
- prop2
886
- );
814
+ lineColorItem.value = replacePositionValue(itemValue, splitValue(lineColorItem.value), prop2);
887
815
  }
888
816
  longhandItem.value = itemValue;
889
817
  longhandItem.priority = priority;
890
818
  borderItems.set(longhandProperty, longhandItem);
891
819
  }
892
- borderItems.set(BORDER, shorthandItem);
820
+ borderItems.set(border.property, shorthandItem);
893
821
  borderItems.set(BORDER_IMAGE, imageItem);
894
822
  borderItems.set(lineWidthProperty, lineWidthItem);
895
823
  borderItems.set(lineStyleProperty, lineStyleItem);
@@ -951,33 +879,32 @@ const prepareBorderObjectValue = ({
951
879
  borderItems.set(lineStyleProperty, lineStyleItem);
952
880
  borderItems.set(lineColorProperty, lineColorItem);
953
881
  }
954
- };
882
+ }
955
883
 
956
884
  /**
957
885
  * Prepares border properties by splitting shorthands and handling updates.
958
886
  *
959
887
  * @param {string} property - The border property name.
960
- * @param {string|Array|Object} value - The value of the property.
888
+ * @param {string|Array|object} value - The value of the property.
961
889
  * @param {string} priority - The priority of the property (e.g., "important").
962
890
  * @param {Map} properties - The map of all properties.
963
- * @param {Object} [opt={}] - Parsing options.
964
891
  * @returns {Map|undefined} A map of expanded or updated border properties.
965
892
  */
966
- const prepareBorderProperties = (property, value, priority, properties, opt = {}) => {
893
+ function prepareBorderProperties(property, value, priority, properties) {
967
894
  if (typeof property !== "string" || value === null) {
968
895
  return;
969
896
  }
970
- if (!property.startsWith(BORDER)) {
897
+ if (!property.startsWith(border.property)) {
971
898
  return;
972
899
  }
973
900
  let prop2, prop3;
974
- if (property.length > BORDER.length) {
901
+ if (property.length > border.property.length) {
975
902
  // Check if next char is '-'
976
- if (property.charCodeAt(BORDER.length) !== 45) {
903
+ if (property.charCodeAt(border.property.length) !== 45) {
977
904
  return;
978
905
  }
979
906
  // property is like "border-..."
980
- const remainder = property.substring(BORDER.length + 1);
907
+ const remainder = property.substring(border.property.length + 1);
981
908
  const hyphenIndex = remainder.indexOf("-");
982
909
  if (hyphenIndex !== -1) {
983
910
  prop2 = remainder.substring(0, hyphenIndex);
@@ -986,14 +913,11 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
986
913
  prop2 = remainder;
987
914
  }
988
915
  }
989
- if (
990
- (borderPositions.has(prop2) && prop3 && !borderLines.has(prop3)) ||
991
- (borderLines.has(prop2) && prop3)
992
- ) {
916
+ if ((borderPositions.has(prop2) && prop3 && !borderLines.has(prop3)) || (borderLines.has(prop2) && prop3)) {
993
917
  return;
994
918
  }
995
919
  const parts = {
996
- prop1: BORDER,
920
+ prop1: border.property,
997
921
  prop2,
998
922
  prop3
999
923
  };
@@ -1005,7 +929,6 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
1005
929
  priority,
1006
930
  properties,
1007
931
  parts,
1008
- opt,
1009
932
  borderItems
1010
933
  });
1011
934
  } else if (Array.isArray(value)) {
@@ -1014,7 +937,6 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
1014
937
  priority,
1015
938
  properties,
1016
939
  parts,
1017
- opt,
1018
940
  borderItems
1019
941
  });
1020
942
  } else if (value && typeof value === "object") {
@@ -1024,35 +946,32 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
1024
946
  priority,
1025
947
  properties,
1026
948
  parts,
1027
- opt,
1028
949
  borderItems
1029
950
  });
1030
951
  }
1031
- if (!borderItems.has(BORDER)) {
952
+ if (!borderItems.has(border.property)) {
1032
953
  return;
1033
954
  }
1034
- const borderProps = new Map([[BORDER, borderItems.get(BORDER)]]);
955
+ const borderProps = new Map([[border.property, borderItems.get(border.property)]]);
1035
956
  for (const line of borderLines) {
1036
- const lineProperty = `${BORDER}-${line}`;
957
+ const lineProperty = `${border.property}-${line}`;
1037
958
  const lineItem = borderItems.get(lineProperty) ?? getPropertyItem(lineProperty, properties);
1038
959
  borderProps.set(lineProperty, lineItem);
1039
960
  }
1040
961
  for (const position of borderPositions) {
1041
- const positionProperty = `${BORDER}-${position}`;
1042
- const positionItem =
1043
- borderItems.get(positionProperty) ?? getPropertyItem(positionProperty, properties);
962
+ const positionProperty = `${border.property}-${position}`;
963
+ const positionItem = borderItems.get(positionProperty) ?? getPropertyItem(positionProperty, properties);
1044
964
  borderProps.set(positionProperty, positionItem);
1045
965
  for (const line of borderLines) {
1046
- const longhandProperty = `${BORDER}-${position}-${line}`;
1047
- const longhandItem =
1048
- borderItems.get(longhandProperty) ?? getPropertyItem(longhandProperty, properties);
966
+ const longhandProperty = `${border.property}-${position}-${line}`;
967
+ const longhandItem = borderItems.get(longhandProperty) ?? getPropertyItem(longhandProperty, properties);
1049
968
  borderProps.set(longhandProperty, longhandItem);
1050
969
  }
1051
970
  }
1052
971
  const borderImageItem = borderItems.get(BORDER_IMAGE) ?? createPropertyItem(BORDER_IMAGE);
1053
972
  borderProps.set(BORDER_IMAGE, borderImageItem);
1054
973
  return borderProps;
1055
- };
974
+ }
1056
975
 
1057
976
  /**
1058
977
  * Generates a border line shorthand property if all line components are present.
@@ -1062,7 +981,7 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
1062
981
  * @param {string} [priority=""] - The priority of the property.
1063
982
  * @returns {Array} A key-value pair for the generated property.
1064
983
  */
1065
- const generateBorderLineShorthand = (items, property, priority = "") => {
984
+ function generateBorderLineShorthand(items, property, priority = "") {
1066
985
  const values = [];
1067
986
  for (const [, item] of items) {
1068
987
  const { value: itemValue } = item;
@@ -1070,7 +989,7 @@ const generateBorderLineShorthand = (items, property, priority = "") => {
1070
989
  }
1071
990
  const value = getPositionValue(values);
1072
991
  return [property, createPropertyItem(property, value, priority)];
1073
- };
992
+ }
1074
993
 
1075
994
  /**
1076
995
  * Generates a border position shorthand property if all position components are present.
@@ -1080,7 +999,7 @@ const generateBorderLineShorthand = (items, property, priority = "") => {
1080
999
  * @param {string} [priority=""] - The priority of the property.
1081
1000
  * @returns {Array} A key-value pair for the generated property.
1082
1001
  */
1083
- const generateBorderPositionShorthand = (items, property, priority = "") => {
1002
+ function generateBorderPositionShorthand(items, property, priority = "") {
1084
1003
  const values = [];
1085
1004
  for (const [, item] of items) {
1086
1005
  const { value: itemValue } = item;
@@ -1088,7 +1007,7 @@ const generateBorderPositionShorthand = (items, property, priority = "") => {
1088
1007
  }
1089
1008
  const value = values.join(" ");
1090
1009
  return [property, createPropertyItem(property, value, priority)];
1091
- };
1010
+ }
1092
1011
 
1093
1012
  /**
1094
1013
  * Generates a border shorthand property if all components match.
@@ -1098,44 +1017,13 @@ const generateBorderPositionShorthand = (items, property, priority = "") => {
1098
1017
  * @param {string} [priority=""] - The priority of the property.
1099
1018
  * @returns {Array|undefined} A key-value pair for the generated property or undefined.
1100
1019
  */
1101
- const generateBorderShorthand = (items, property, priority = "") => {
1020
+ function generateBorderShorthand(items, property, priority = "") {
1102
1021
  const values = new Set(items);
1103
1022
  if (values.size === 1) {
1104
- const value = values.keys().next().value;
1023
+ const { value } = values.keys().next();
1105
1024
  return [property, createPropertyItem(property, value, priority)];
1106
1025
  }
1107
- };
1108
-
1109
- const borderCollectionConfig = {
1110
- [WIDTH]: {
1111
- shorthand: BORDER_WIDTH,
1112
- generator: generateBorderLineShorthand
1113
- },
1114
- [STYLE]: {
1115
- shorthand: BORDER_STYLE,
1116
- generator: generateBorderLineShorthand
1117
- },
1118
- [COLOR]: {
1119
- shorthand: BORDER_COLOR,
1120
- generator: generateBorderLineShorthand
1121
- },
1122
- [TOP]: {
1123
- shorthand: BORDER_TOP,
1124
- generator: generateBorderPositionShorthand
1125
- },
1126
- [RIGHT]: {
1127
- shorthand: BORDER_RIGHT,
1128
- generator: generateBorderPositionShorthand
1129
- },
1130
- [BOTTOM]: {
1131
- shorthand: BORDER_BOTTOM,
1132
- generator: generateBorderPositionShorthand
1133
- },
1134
- [LEFT]: {
1135
- shorthand: BORDER_LEFT,
1136
- generator: generateBorderPositionShorthand
1137
- }
1138
- };
1026
+ }
1139
1027
 
1140
1028
  /**
1141
1029
  * Processes and consolidates border-related longhands into shorthands where possible.
@@ -1143,7 +1031,7 @@ const borderCollectionConfig = {
1143
1031
  * @param {Map} properties - The map of current properties.
1144
1032
  * @returns {Map} The updated map with consolidated border properties.
1145
1033
  */
1146
- const prepareBorderShorthands = (properties) => {
1034
+ function prepareBorderShorthands(properties) {
1147
1035
  const borderCollections = {};
1148
1036
  for (const key of Object.keys(borderCollectionConfig)) {
1149
1037
  borderCollections[key] = {
@@ -1217,15 +1105,14 @@ const prepareBorderShorthands = (properties) => {
1217
1105
  const mixedPriorities = shorthandItems.length && shorthandPriorityItems.length;
1218
1106
  const imageItem = createPropertyItem(BORDER_IMAGE, NONE);
1219
1107
  if (shorthandItems.length === 4) {
1220
- const [property, item] = generateBorderShorthand(shorthandItems, BORDER) ?? [];
1108
+ const [property, item] = generateBorderShorthand(shorthandItems, border.property) ?? [];
1221
1109
  if (property && item) {
1222
1110
  properties.set(property, item);
1223
1111
  properties.delete(BORDER_IMAGE);
1224
1112
  properties.set(BORDER_IMAGE, imageItem);
1225
1113
  }
1226
1114
  } else if (shorthandPriorityItems.length === 4) {
1227
- const [property, item] =
1228
- generateBorderShorthand(shorthandPriorityItems, BORDER, "important") ?? [];
1115
+ const [property, item] = generateBorderShorthand(shorthandPriorityItems, border.property, "important") ?? [];
1229
1116
  if (property && item) {
1230
1117
  properties.set(property, item);
1231
1118
  properties.delete(BORDER_IMAGE);
@@ -1265,7 +1152,7 @@ const prepareBorderShorthands = (properties) => {
1265
1152
  properties.set(BORDER_IMAGE, imageItem);
1266
1153
  }
1267
1154
  return properties;
1268
- };
1155
+ }
1269
1156
 
1270
1157
  /**
1271
1158
  * Processes shorthand properties from the shorthands map.
@@ -1273,7 +1160,7 @@ const prepareBorderShorthands = (properties) => {
1273
1160
  * @param {Map} shorthands - The map containing shorthand property groups.
1274
1161
  * @returns {Map} A map of processed shorthand properties.
1275
1162
  */
1276
- const processShorthandProperties = (shorthands) => {
1163
+ function processShorthandProperties(shorthands) {
1277
1164
  const shorthandItems = new Map();
1278
1165
  for (const [property, item] of shorthands) {
1279
1166
  const shorthandItem = shorthandProperties.get(property);
@@ -1291,7 +1178,7 @@ const processShorthandProperties = (shorthands) => {
1291
1178
  }
1292
1179
  }
1293
1180
  return shorthandItems;
1294
- };
1181
+ }
1295
1182
 
1296
1183
  /**
1297
1184
  * Updates the longhand properties map with a new property item.
@@ -1299,10 +1186,10 @@ const processShorthandProperties = (shorthands) => {
1299
1186
  * If the existing property has "important" priority, it will not be overwritten.
1300
1187
  *
1301
1188
  * @param {string} property - The CSS property name.
1302
- * @param {Object} item - The property item object containing value and priority.
1189
+ * @param {object} item - The property item object containing value and priority.
1303
1190
  * @param {Map} longhandProperties - The map of longhand properties to update.
1304
1191
  */
1305
- const updateLonghandProperties = (property, item, longhandProperties) => {
1192
+ function updateLonghandProperties(property, item, longhandProperties) {
1306
1193
  if (longhandProperties.has(property)) {
1307
1194
  const { priority: longhandPriority } = longhandProperties.get(property);
1308
1195
  if (!longhandPriority) {
@@ -1312,22 +1199,21 @@ const updateLonghandProperties = (property, item, longhandProperties) => {
1312
1199
  } else {
1313
1200
  longhandProperties.set(property, item);
1314
1201
  }
1315
- };
1202
+ }
1316
1203
 
1317
1204
  /**
1318
1205
  * Processes border properties from the borders map, expanding and normalizing them.
1319
1206
  *
1320
1207
  * @param {Map} borders - The map containing accumulated border properties.
1321
- * @param {Object} parseOpt - Options for parsing values.
1322
1208
  * @returns {Map} A map of fully processed and normalized border properties.
1323
1209
  */
1324
- const processBorderProperties = (borders, parseOpt) => {
1210
+ function processBorderProperties(borders) {
1325
1211
  const longhandProperties = new Map();
1326
1212
  for (const [property, item] of borders) {
1327
1213
  if (shorthandProperties.has(property)) {
1328
1214
  const { value, priority } = item;
1329
- if (property === BORDER) {
1330
- const lineItems = border.parse(value, parseOpt);
1215
+ if (property === border.property) {
1216
+ const lineItems = border.parse(value);
1331
1217
  for (const [key, initialValue] of border.initialValues) {
1332
1218
  if (!Object.hasOwn(lineItems, key)) {
1333
1219
  lineItems[key] = initialValue;
@@ -1357,7 +1243,7 @@ const processBorderProperties = (borders, parseOpt) => {
1357
1243
  }
1358
1244
  } else {
1359
1245
  const shorthandItem = shorthandProperties.get(property);
1360
- const parsedItem = shorthandItem.parse(value, parseOpt);
1246
+ const parsedItem = shorthandItem.parse(value);
1361
1247
  if (Array.isArray(parsedItem)) {
1362
1248
  let namePart, linePart;
1363
1249
  const hyphenIndex = property.indexOf("-");
@@ -1398,21 +1284,15 @@ const processBorderProperties = (borders, parseOpt) => {
1398
1284
  }
1399
1285
  const borderItems = prepareBorderShorthands(longhandProperties);
1400
1286
  return borderItems;
1401
- };
1287
+ }
1402
1288
 
1403
1289
  /**
1404
1290
  * Normalize and prepare CSS properties, handling shorthands and longhands.
1405
1291
  *
1406
1292
  * @param {Map} properties - The initial map of properties.
1407
- * @param {Object} [opt={}] - Parsing options.
1408
1293
  * @returns {Map} The normalized map of properties.
1409
1294
  */
1410
- const prepareProperties = (properties, opt = {}) => {
1411
- const { globalObject, options } = opt;
1412
- const parseOpt = {
1413
- globalObject,
1414
- options
1415
- };
1295
+ function prepareProperties(properties) {
1416
1296
  const parsedProperties = new Map();
1417
1297
  const shorthands = new Map();
1418
1298
  const borders = new Map();
@@ -1443,7 +1323,7 @@ const prepareProperties = (properties, opt = {}) => {
1443
1323
  parsedProperties.set(property, item);
1444
1324
  } else if (shorthandProperties.has(property)) {
1445
1325
  const shorthandItem = shorthandProperties.get(property);
1446
- const parsedValues = shorthandItem.parse(value, parseOpt);
1326
+ const parsedValues = shorthandItem.parse(value);
1447
1327
  let omitShorthandProperty = false;
1448
1328
  if (Array.isArray(parsedValues)) {
1449
1329
  const [parsedValue] = parsedValues;
@@ -1458,31 +1338,22 @@ const prepareProperties = (properties, opt = {}) => {
1458
1338
  }
1459
1339
  const { position } = longhandItem;
1460
1340
  const longhandValue = getPositionValue([parsedValue], position);
1461
- parsedProperties.set(
1462
- longhandProperty,
1463
- createPropertyItem(longhandProperty, longhandValue, priority)
1464
- );
1341
+ parsedProperties.set(longhandProperty, createPropertyItem(longhandProperty, longhandValue, priority));
1465
1342
  }
1466
1343
  } else if (parsedValue) {
1467
1344
  for (const longhandProperty of Object.keys(parsedValue)) {
1468
1345
  const longhandValue = parsedValue[longhandProperty];
1469
- parsedProperties.set(
1470
- longhandProperty,
1471
- createPropertyItem(longhandProperty, longhandValue, priority)
1472
- );
1346
+ parsedProperties.set(longhandProperty, createPropertyItem(longhandProperty, longhandValue, priority));
1473
1347
  }
1474
1348
  }
1475
1349
  } else if (parsedValues && typeof parsedValues !== "string") {
1476
1350
  for (const longhandProperty of Object.keys(parsedValues)) {
1477
1351
  const longhandValue = parsedValues[longhandProperty];
1478
- parsedProperties.set(
1479
- longhandProperty,
1480
- createPropertyItem(longhandProperty, longhandValue, priority)
1481
- );
1352
+ parsedProperties.set(longhandProperty, createPropertyItem(longhandProperty, longhandValue, priority));
1482
1353
  }
1483
1354
  }
1484
1355
  if (!omitShorthandProperty) {
1485
- if (property === BACKGROUND) {
1356
+ if (property === background.property) {
1486
1357
  hasPrecedingBackground = true;
1487
1358
  }
1488
1359
  parsedProperties.set(property, createPropertyItem(property, value, priority));
@@ -1490,17 +1361,13 @@ const prepareProperties = (properties, opt = {}) => {
1490
1361
  } else {
1491
1362
  parsedProperties.set(property, createPropertyItem(property, value, priority));
1492
1363
  if (hasPrecedingBackground) {
1493
- const { value: shorthandValue, priority: shorthandPriority } = properties.get(BACKGROUND);
1364
+ const { value: shorthandValue, priority: shorthandPriority } = properties.get(background.property);
1494
1365
  if ((!shorthandPriority || priority) && !hasVarFunc(shorthandValue)) {
1495
- const replacedShorthandValue = replaceBackgroundShorthand(
1496
- property,
1497
- parsedProperties,
1498
- parseOpt
1499
- );
1500
- properties.delete(BACKGROUND);
1366
+ const replacedShorthandValue = replaceBackgroundShorthand(property, parsedProperties);
1367
+ properties.delete(background.property);
1501
1368
  properties.set(
1502
- BACKGROUND,
1503
- createPropertyItem(BACKGROUND, replacedShorthandValue, shorthandPriority)
1369
+ background.property,
1370
+ createPropertyItem(background.property, replacedShorthandValue, shorthandPriority)
1504
1371
  );
1505
1372
  }
1506
1373
  }
@@ -1513,13 +1380,13 @@ const prepareProperties = (properties, opt = {}) => {
1513
1380
  }
1514
1381
  }
1515
1382
  if (borders.size) {
1516
- const borderItems = processBorderProperties(borders, parseOpt);
1383
+ const borderItems = processBorderProperties(borders);
1517
1384
  for (const [property, item] of borderItems) {
1518
1385
  parsedProperties.set(property, item);
1519
1386
  }
1520
1387
  }
1521
1388
  return parsedProperties;
1522
- };
1389
+ }
1523
1390
 
1524
1391
  /**
1525
1392
  * Cleans up redundancy in border properties by removing longhands that are covered by shorthands.
@@ -1527,36 +1394,36 @@ const prepareProperties = (properties, opt = {}) => {
1527
1394
  * @param {Map} properties - The map of properties to normalize.
1528
1395
  * @returns {Map} The normalized properties map.
1529
1396
  */
1530
- const normalizeProperties = (properties) => {
1531
- if (properties.has(BORDER)) {
1397
+ function normalizeProperties(properties) {
1398
+ if (properties.has(border.property)) {
1532
1399
  for (const line of borderLines) {
1533
- properties.delete(`${BORDER}-${line}`);
1400
+ properties.delete(`${border.property}-${line}`);
1534
1401
  }
1535
1402
  for (const position of borderPositions) {
1536
- properties.delete(`${BORDER}-${position}`);
1403
+ properties.delete(`${border.property}-${position}`);
1537
1404
  for (const line of borderLines) {
1538
- properties.delete(`${BORDER}-${position}-${line}`);
1405
+ properties.delete(`${border.property}-${position}-${line}`);
1539
1406
  }
1540
1407
  }
1541
- properties.delete(`${BORDER}-image`);
1408
+ properties.delete(`${border.property}-image`);
1542
1409
  }
1543
1410
  for (const line of borderLines) {
1544
- const lineProperty = `${BORDER}-${line}`;
1411
+ const lineProperty = `${border.property}-${line}`;
1545
1412
  if (properties.has(lineProperty)) {
1546
1413
  for (const position of borderPositions) {
1547
- const positionProperty = `${BORDER}-${position}`;
1548
- const longhandProperty = `${BORDER}-${position}-${line}`;
1414
+ const positionProperty = `${border.property}-${position}`;
1415
+ const longhandProperty = `${border.property}-${position}-${line}`;
1549
1416
  properties.delete(positionProperty);
1550
1417
  properties.delete(longhandProperty);
1551
1418
  }
1552
1419
  }
1553
1420
  }
1554
1421
  for (const position of borderPositions) {
1555
- const positionProperty = `${BORDER}-${position}`;
1422
+ const positionProperty = `${border.property}-${position}`;
1556
1423
  if (properties.has(positionProperty)) {
1557
1424
  const longhandProperties = [];
1558
1425
  for (const line of borderLines) {
1559
- const longhandProperty = `${BORDER}-${position}-${line}`;
1426
+ const longhandProperty = `${border.property}-${position}-${line}`;
1560
1427
  longhandProperties.push(longhandProperty);
1561
1428
  }
1562
1429
  if (longhandProperties.length === 3) {
@@ -1569,7 +1436,7 @@ const normalizeProperties = (properties) => {
1569
1436
  }
1570
1437
  }
1571
1438
  return properties;
1572
- };
1439
+ }
1573
1440
 
1574
1441
  module.exports = {
1575
1442
  borderProperties,