cssstyle 5.3.7 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/CSSStyleDeclaration.js +359 -395
- package/lib/generated/.gitkeep +0 -0
- package/lib/generated/propertyDefinitions.js +3685 -1498
- package/lib/generated/propertyDescriptors.js +1705 -0
- package/lib/index.js +9 -0
- package/lib/normalize.js +127 -253
- package/lib/parsers.js +152 -164
- package/lib/properties/background.js +201 -202
- package/lib/properties/backgroundAttachment.js +35 -33
- package/lib/properties/backgroundClip.js +35 -33
- package/lib/properties/backgroundColor.js +26 -24
- package/lib/properties/backgroundImage.js +36 -34
- package/lib/properties/backgroundOrigin.js +35 -33
- package/lib/properties/backgroundPosition.js +57 -57
- package/lib/properties/backgroundRepeat.js +40 -37
- package/lib/properties/backgroundSize.js +38 -34
- package/lib/properties/border.js +41 -34
- package/lib/properties/{webkitBorderEndColor.js → borderBlockEndColor.js} +26 -22
- package/lib/properties/{webkitBorderAfterColor.js → borderBlockStartColor.js} +26 -22
- package/lib/properties/borderBottom.js +40 -36
- package/lib/properties/borderBottomColor.js +25 -21
- package/lib/properties/borderBottomStyle.js +25 -21
- package/lib/properties/borderBottomWidth.js +28 -24
- package/lib/properties/borderCollapse.js +25 -21
- package/lib/properties/borderColor.js +36 -33
- package/lib/properties/{webkitBorderStartColor.js → borderInlineEndColor.js} +26 -22
- package/lib/properties/borderInlineStartColor.js +49 -0
- package/lib/properties/borderLeft.js +40 -36
- package/lib/properties/borderLeftColor.js +25 -21
- package/lib/properties/borderLeftStyle.js +25 -21
- package/lib/properties/borderLeftWidth.js +28 -24
- package/lib/properties/borderRight.js +40 -36
- package/lib/properties/borderRightColor.js +25 -21
- package/lib/properties/borderRightStyle.js +25 -21
- package/lib/properties/borderRightWidth.js +28 -24
- package/lib/properties/borderSpacing.js +33 -29
- package/lib/properties/borderStyle.js +36 -33
- package/lib/properties/borderTop.js +40 -36
- package/lib/properties/borderTopColor.js +25 -21
- package/lib/properties/borderTopStyle.js +25 -21
- package/lib/properties/borderTopWidth.js +28 -24
- package/lib/properties/borderWidth.js +36 -33
- package/lib/properties/bottom.js +27 -23
- package/lib/properties/clear.js +25 -21
- package/lib/properties/clip.js +37 -31
- package/lib/properties/color.js +25 -21
- package/lib/properties/display.js +36 -30
- package/lib/properties/flex.js +53 -45
- package/lib/properties/flexBasis.js +28 -26
- package/lib/properties/flexGrow.js +28 -26
- package/lib/properties/flexShrink.js +28 -26
- package/lib/properties/float.js +25 -21
- package/lib/properties/floodColor.js +25 -21
- package/lib/properties/font.js +89 -118
- package/lib/properties/fontFamily.js +38 -33
- package/lib/properties/fontSize.js +29 -27
- package/lib/properties/fontStyle.js +38 -34
- package/lib/properties/fontVariant.js +35 -33
- package/lib/properties/fontWeight.js +33 -31
- package/lib/properties/height.js +28 -24
- package/lib/properties/left.js +27 -23
- package/lib/properties/lightingColor.js +25 -21
- package/lib/properties/lineHeight.js +28 -26
- package/lib/properties/margin.js +40 -34
- package/lib/properties/marginBottom.js +30 -27
- package/lib/properties/marginLeft.js +30 -27
- package/lib/properties/marginRight.js +30 -27
- package/lib/properties/marginTop.js +30 -27
- package/lib/properties/opacity.js +27 -23
- package/lib/properties/outlineColor.js +25 -21
- package/lib/properties/padding.js +40 -34
- package/lib/properties/paddingBottom.js +31 -28
- package/lib/properties/paddingLeft.js +31 -28
- package/lib/properties/paddingRight.js +31 -28
- package/lib/properties/paddingTop.js +31 -28
- package/lib/properties/right.js +27 -23
- package/lib/properties/stopColor.js +25 -21
- package/lib/properties/{webkitBorderBeforeColor.js → textEmphasisColor.js} +26 -22
- package/lib/properties/top.js +27 -23
- package/lib/properties/webkitTextFillColor.js +25 -21
- package/lib/properties/webkitTextStrokeColor.js +25 -21
- package/lib/properties/width.js +28 -24
- package/lib/utils/propertyDescriptors.js +129 -42
- package/lib/utils/strings.js +11 -156
- package/package.json +11 -21
- package/lib/generated/allProperties.js +0 -653
- package/lib/generated/implementedProperties.js +0 -1466
- package/lib/generated/properties.js +0 -6637
- package/lib/properties/webkitColumnRuleColor.js +0 -45
- package/lib/properties/webkitTapHighlightColor.js +0 -45
- package/lib/properties/webkitTextEmphasisColor.js +0 -45
- package/lib/utils/allExtraProperties.js +0 -155
- package/lib/utils/camelize.js +0 -37
package/lib/normalize.js
CHANGED
|
@@ -18,7 +18,7 @@ const font = require("./properties/font");
|
|
|
18
18
|
const margin = require("./properties/margin");
|
|
19
19
|
const padding = require("./properties/padding");
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// Constants
|
|
22
22
|
const BORDER_IMAGE = "border-image";
|
|
23
23
|
const TOP = "top";
|
|
24
24
|
const RIGHT = "right";
|
|
@@ -35,19 +35,14 @@ const TRBL_INDICES = {
|
|
|
35
35
|
[LEFT]: 3
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
/* shorthands */
|
|
39
38
|
const shorthandProperties = new Map([
|
|
40
39
|
[background.property, background],
|
|
41
40
|
[
|
|
42
41
|
border.property,
|
|
43
42
|
{
|
|
44
|
-
|
|
43
|
+
descriptor: border.descriptor,
|
|
45
44
|
parse: border.parse,
|
|
46
|
-
shorthandFor: new Map([
|
|
47
|
-
...border.shorthandFor,
|
|
48
|
-
...border.positionShorthandFor,
|
|
49
|
-
[BORDER_IMAGE, null]
|
|
50
|
-
])
|
|
45
|
+
shorthandFor: new Map([...border.shorthandFor, ...border.positionShorthandFor, [BORDER_IMAGE, null]])
|
|
51
46
|
}
|
|
52
47
|
],
|
|
53
48
|
[borderWidth.property, borderWidth],
|
|
@@ -63,7 +58,6 @@ const shorthandProperties = new Map([
|
|
|
63
58
|
["padding", padding]
|
|
64
59
|
]);
|
|
65
60
|
|
|
66
|
-
/* borders */
|
|
67
61
|
const borderProperties = new Set([
|
|
68
62
|
border.property,
|
|
69
63
|
BORDER_IMAGE,
|
|
@@ -74,44 +68,78 @@ const borderProperties = new Set([
|
|
|
74
68
|
...borderBottom.shorthandFor.keys(),
|
|
75
69
|
...borderLeft.shorthandFor.keys()
|
|
76
70
|
]);
|
|
77
|
-
|
|
71
|
+
|
|
78
72
|
const borderLines = new Set([WIDTH, STYLE, COLOR]);
|
|
79
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
|
+
|
|
80
107
|
/**
|
|
81
108
|
* Ensures consistent object shape.
|
|
82
109
|
*
|
|
83
110
|
* @param {string} property - The property name.
|
|
84
111
|
* @param {string} [value=""] - The property value.
|
|
85
112
|
* @param {string} [priority=""] - The priority.
|
|
86
|
-
* @returns {
|
|
113
|
+
* @returns {object} The property item object.
|
|
87
114
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
115
|
+
function createPropertyItem(property, value = "", priority = "") {
|
|
116
|
+
return {
|
|
117
|
+
property,
|
|
118
|
+
value,
|
|
119
|
+
priority
|
|
120
|
+
};
|
|
121
|
+
}
|
|
93
122
|
|
|
94
123
|
/**
|
|
95
124
|
* Retrieves a property item from the map or creates a default one if it doesn't exist.
|
|
96
125
|
*
|
|
97
126
|
* @param {string} property - The name of the property.
|
|
98
127
|
* @param {Map} properties - The map containing all properties.
|
|
99
|
-
* @returns {
|
|
128
|
+
* @returns {object} The property item containing name, value, and priority.
|
|
100
129
|
*/
|
|
101
|
-
|
|
130
|
+
function getPropertyItem(property, properties) {
|
|
102
131
|
const propertyItem = properties.get(property) ?? createPropertyItem(property);
|
|
103
132
|
return propertyItem;
|
|
104
|
-
}
|
|
133
|
+
}
|
|
105
134
|
|
|
106
135
|
/**
|
|
107
|
-
* Calculates the value for a specific position
|
|
108
|
-
* based on the array of values provided for a shorthand property.
|
|
136
|
+
* Calculates the value for a specific position from shorthand values.
|
|
109
137
|
*
|
|
110
138
|
* @param {string[]} positionValues - The values extracted from the shorthand property.
|
|
111
139
|
* @param {string} position - The specific position (top, right, bottom, left) to retrieve.
|
|
112
140
|
* @returns {string} The calculated value for the position.
|
|
113
141
|
*/
|
|
114
|
-
|
|
142
|
+
function getPositionValue(positionValues, position) {
|
|
115
143
|
const [val1, val2, val3, val4] = positionValues;
|
|
116
144
|
const index = TRBL_INDICES[position] ?? -1;
|
|
117
145
|
// If a specific position (top, right, bottom, left) is requested.
|
|
@@ -174,24 +202,23 @@ const getPositionValue = (positionValues, position) => {
|
|
|
174
202
|
return val1;
|
|
175
203
|
}
|
|
176
204
|
}
|
|
177
|
-
}
|
|
205
|
+
}
|
|
178
206
|
|
|
179
207
|
/**
|
|
180
208
|
* Replaces the background shorthand property based on individual longhand values.
|
|
181
209
|
*
|
|
182
210
|
* @param {string} property - The specific background longhand property being updated.
|
|
183
211
|
* @param {Map} properties - The map of all properties.
|
|
184
|
-
* @param {Object} opt - Parsing options including global object and configurations.
|
|
185
212
|
* @returns {string} The constructed background shorthand string.
|
|
186
213
|
*/
|
|
187
|
-
|
|
214
|
+
function replaceBackgroundShorthand(property, properties) {
|
|
188
215
|
const { value: propertyValue } = properties.get(property);
|
|
189
|
-
const parsedValue = background.shorthandFor.get(property).parse(propertyValue
|
|
216
|
+
const parsedValue = background.shorthandFor.get(property).parse(propertyValue);
|
|
190
217
|
const values = splitValue(parsedValue, {
|
|
191
218
|
delimiter: ","
|
|
192
219
|
});
|
|
193
220
|
const { value: shorthandValue } = properties.get(background.property);
|
|
194
|
-
const bgValues = background.parse(shorthandValue
|
|
221
|
+
const bgValues = background.parse(shorthandValue);
|
|
195
222
|
const bgLength = bgValues.length;
|
|
196
223
|
if (property === backgroundColor.property) {
|
|
197
224
|
bgValues[bgLength - 1][property] = parsedValue[0];
|
|
@@ -216,7 +243,7 @@ const replaceBackgroundShorthand = (property, properties, opt) => {
|
|
|
216
243
|
backgrounds.push(bg.join(" "));
|
|
217
244
|
}
|
|
218
245
|
return backgrounds.join(", ");
|
|
219
|
-
}
|
|
246
|
+
}
|
|
220
247
|
|
|
221
248
|
/**
|
|
222
249
|
* Checks if a property value matches the value within a border shorthand.
|
|
@@ -224,40 +251,29 @@ const replaceBackgroundShorthand = (property, properties, opt) => {
|
|
|
224
251
|
* @param {string} property - The property to check.
|
|
225
252
|
* @param {string} value - The value to compare.
|
|
226
253
|
* @param {string} shorthandValue - The shorthand string to parse and compare against.
|
|
227
|
-
* @param {Object} [opt={}] - Parsing options.
|
|
228
254
|
* @returns {boolean} True if the value matches the shorthand's value.
|
|
229
255
|
*/
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
const obj = border.parse(shorthandValue, {
|
|
233
|
-
globalObject,
|
|
234
|
-
options
|
|
235
|
-
});
|
|
256
|
+
function matchesBorderShorthandValue(property, value, shorthandValue) {
|
|
257
|
+
const obj = border.parse(shorthandValue);
|
|
236
258
|
if (Object.hasOwn(obj, property)) {
|
|
237
259
|
return value === obj[property];
|
|
238
260
|
}
|
|
239
261
|
return value === border.initialValues.get(property);
|
|
240
|
-
}
|
|
262
|
+
}
|
|
241
263
|
|
|
242
264
|
/**
|
|
243
265
|
* Replaces or updates a value within a border shorthand string.
|
|
244
266
|
*
|
|
245
267
|
* @param {string} value - The new value to insert.
|
|
246
268
|
* @param {string} shorthandValue - The existing shorthand string.
|
|
247
|
-
* @param {Object} [opt={}] - Parsing options.
|
|
248
269
|
* @returns {string} The updated border shorthand string.
|
|
249
270
|
*/
|
|
250
|
-
|
|
251
|
-
const { globalObject, options } = opt;
|
|
271
|
+
function replaceBorderShorthandValue(value, shorthandValue) {
|
|
252
272
|
const borderFirstInitialKey = border.initialValues.keys().next().value;
|
|
253
273
|
const borderFirstInitialValue = border.initialValues.get(borderFirstInitialKey);
|
|
254
|
-
const
|
|
255
|
-
globalObject,
|
|
256
|
-
options
|
|
257
|
-
};
|
|
258
|
-
const valueObj = border.parse(value, parseOpt);
|
|
274
|
+
const valueObj = border.parse(value);
|
|
259
275
|
const shorthandObj = shorthandValue
|
|
260
|
-
? border.parse(shorthandValue
|
|
276
|
+
? border.parse(shorthandValue)
|
|
261
277
|
: {
|
|
262
278
|
[borderFirstInitialKey]: borderFirstInitialValue
|
|
263
279
|
};
|
|
@@ -278,16 +294,13 @@ const replaceBorderShorthandValue = (value, shorthandValue, opt = {}) => {
|
|
|
278
294
|
}
|
|
279
295
|
} else {
|
|
280
296
|
shorthandObj[key] = parsedValue;
|
|
281
|
-
if (
|
|
282
|
-
shorthandObj[borderFirstInitialKey] &&
|
|
283
|
-
shorthandObj[borderFirstInitialKey] === borderFirstInitialValue
|
|
284
|
-
) {
|
|
297
|
+
if (shorthandObj[borderFirstInitialKey] && shorthandObj[borderFirstInitialKey] === borderFirstInitialValue) {
|
|
285
298
|
delete shorthandObj[borderFirstInitialKey];
|
|
286
299
|
}
|
|
287
300
|
}
|
|
288
301
|
}
|
|
289
302
|
return Object.values(shorthandObj).join(" ");
|
|
290
|
-
}
|
|
303
|
+
}
|
|
291
304
|
|
|
292
305
|
/**
|
|
293
306
|
* Replaces a value at a specific position (top, right, bottom, left) within a position shorthand.
|
|
@@ -297,7 +310,7 @@ const replaceBorderShorthandValue = (value, shorthandValue, opt = {}) => {
|
|
|
297
310
|
* @param {string} position - The position to update.
|
|
298
311
|
* @returns {string} The updated shorthand string.
|
|
299
312
|
*/
|
|
300
|
-
|
|
313
|
+
function replacePositionValue(value, positionValues, position) {
|
|
301
314
|
const index = TRBL_INDICES[position] ?? -1;
|
|
302
315
|
let currentValues = positionValues;
|
|
303
316
|
if (index !== -1) {
|
|
@@ -488,35 +501,21 @@ const replacePositionValue = (value, positionValues, position) => {
|
|
|
488
501
|
return val1;
|
|
489
502
|
}
|
|
490
503
|
}
|
|
491
|
-
}
|
|
504
|
+
}
|
|
492
505
|
|
|
493
506
|
/**
|
|
494
507
|
* Handles border property preparation when the value is a string.
|
|
495
508
|
*
|
|
496
|
-
* @param {
|
|
509
|
+
* @param {object} params - The parameters object.
|
|
497
510
|
* @param {string} params.property - The property name.
|
|
498
511
|
* @param {string} params.value - The property value.
|
|
499
512
|
* @param {string} params.priority - The property priority.
|
|
500
513
|
* @param {Map} params.properties - The map of properties.
|
|
501
|
-
* @param {
|
|
502
|
-
* @param {Object} params.opt - Parsing options.
|
|
514
|
+
* @param {object} params.parts - The split property name parts.
|
|
503
515
|
* @param {Map} params.borderItems - The map to store processed border items.
|
|
504
516
|
*/
|
|
505
|
-
|
|
506
|
-
property,
|
|
507
|
-
value,
|
|
508
|
-
priority,
|
|
509
|
-
properties,
|
|
510
|
-
parts,
|
|
511
|
-
opt,
|
|
512
|
-
borderItems
|
|
513
|
-
}) => {
|
|
517
|
+
function prepareBorderStringValue({ property, value, priority, properties, parts, borderItems }) {
|
|
514
518
|
const { prop1, prop2, prop3 } = parts;
|
|
515
|
-
const { globalObject, options } = opt;
|
|
516
|
-
const parseOpt = {
|
|
517
|
-
globalObject,
|
|
518
|
-
options
|
|
519
|
-
};
|
|
520
519
|
const shorthandItem = getPropertyItem(border.property, properties);
|
|
521
520
|
const imageItem = getPropertyItem(BORDER_IMAGE, properties);
|
|
522
521
|
// Handle longhand properties.
|
|
@@ -545,19 +544,13 @@ const prepareBorderStringValue = ({
|
|
|
545
544
|
positionItem.value = "";
|
|
546
545
|
}
|
|
547
546
|
} else {
|
|
548
|
-
if (
|
|
549
|
-
shorthandItem.value &&
|
|
550
|
-
!matchesBorderShorthandValue(lineProperty, propertyValue, shorthandItem.value, parseOpt)
|
|
551
|
-
) {
|
|
547
|
+
if (shorthandItem.value && !matchesBorderShorthandValue(lineProperty, propertyValue, shorthandItem.value)) {
|
|
552
548
|
shorthandItem.value = "";
|
|
553
549
|
}
|
|
554
550
|
if (lineItem.value) {
|
|
555
551
|
lineItem.value = replacePositionValue(propertyValue, splitValue(lineItem.value), prop2);
|
|
556
552
|
}
|
|
557
|
-
if (
|
|
558
|
-
positionItem.value &&
|
|
559
|
-
!matchesBorderShorthandValue(lineProperty, propertyValue, positionItem.value, parseOpt)
|
|
560
|
-
) {
|
|
553
|
+
if (positionItem.value && !matchesBorderShorthandValue(lineProperty, propertyValue, positionItem.value)) {
|
|
561
554
|
positionItem.value = "";
|
|
562
555
|
}
|
|
563
556
|
}
|
|
@@ -598,28 +591,16 @@ const prepareBorderStringValue = ({
|
|
|
598
591
|
lineColorItem.value = "";
|
|
599
592
|
}
|
|
600
593
|
} else {
|
|
601
|
-
if (
|
|
602
|
-
shorthandItem.value &&
|
|
603
|
-
!matchesBorderShorthandValue(property, propertyValue, shorthandItem.value, parseOpt)
|
|
604
|
-
) {
|
|
594
|
+
if (shorthandItem.value && !matchesBorderShorthandValue(property, propertyValue, shorthandItem.value)) {
|
|
605
595
|
shorthandItem.value = "";
|
|
606
596
|
}
|
|
607
|
-
if (
|
|
608
|
-
lineWidthItem.value &&
|
|
609
|
-
isValidPropertyValue(lineWidthProperty, propertyValue, globalObject)
|
|
610
|
-
) {
|
|
597
|
+
if (lineWidthItem.value && isValidPropertyValue(lineWidthProperty, propertyValue)) {
|
|
611
598
|
lineWidthItem.value = propertyValue;
|
|
612
599
|
}
|
|
613
|
-
if (
|
|
614
|
-
lineStyleItem.value &&
|
|
615
|
-
isValidPropertyValue(lineStyleProperty, propertyValue, globalObject)
|
|
616
|
-
) {
|
|
600
|
+
if (lineStyleItem.value && isValidPropertyValue(lineStyleProperty, propertyValue)) {
|
|
617
601
|
lineStyleItem.value = propertyValue;
|
|
618
602
|
}
|
|
619
|
-
if (
|
|
620
|
-
lineColorItem.value &&
|
|
621
|
-
isValidPropertyValue(lineColorProperty, propertyValue, globalObject)
|
|
622
|
-
) {
|
|
603
|
+
if (lineColorItem.value && isValidPropertyValue(lineColorProperty, propertyValue)) {
|
|
623
604
|
lineColorItem.value = propertyValue;
|
|
624
605
|
}
|
|
625
606
|
}
|
|
@@ -656,11 +637,7 @@ const prepareBorderStringValue = ({
|
|
|
656
637
|
const longhandProperty = `${prop1}-${position}-${prop2}`;
|
|
657
638
|
const longhandItem = getPropertyItem(longhandProperty, properties);
|
|
658
639
|
if (propertyValue) {
|
|
659
|
-
positionItem.value = replaceBorderShorthandValue(
|
|
660
|
-
propertyValue,
|
|
661
|
-
positionItem.value,
|
|
662
|
-
parseOpt
|
|
663
|
-
);
|
|
640
|
+
positionItem.value = replaceBorderShorthandValue(propertyValue, positionItem.value);
|
|
664
641
|
} else {
|
|
665
642
|
positionItem.value = "";
|
|
666
643
|
}
|
|
@@ -700,26 +677,20 @@ const prepareBorderStringValue = ({
|
|
|
700
677
|
borderItems.set(property, shorthandItem);
|
|
701
678
|
borderItems.set(BORDER_IMAGE, imageItem);
|
|
702
679
|
}
|
|
703
|
-
}
|
|
680
|
+
}
|
|
704
681
|
|
|
705
682
|
/**
|
|
706
683
|
* Handles border property preparation when the value is an array.
|
|
707
684
|
*
|
|
708
|
-
* @param {
|
|
685
|
+
* @param {object} params - The parameters object.
|
|
709
686
|
* @param {Array} params.value - The property value.
|
|
710
687
|
* @param {string} params.priority - The property priority.
|
|
711
688
|
* @param {Map} params.properties - The map of properties.
|
|
712
|
-
* @param {
|
|
713
|
-
* @param {Object} params.opt - Parsing options.
|
|
689
|
+
* @param {object} params.parts - The split property name parts.
|
|
714
690
|
* @param {Map} params.borderItems - The map to store processed border items.
|
|
715
691
|
*/
|
|
716
|
-
|
|
692
|
+
function prepareBorderArrayValue({ value, priority, properties, parts, borderItems }) {
|
|
717
693
|
const { prop1, prop2 } = parts;
|
|
718
|
-
const { globalObject, options } = opt;
|
|
719
|
-
const parseOpt = {
|
|
720
|
-
globalObject,
|
|
721
|
-
options
|
|
722
|
-
};
|
|
723
694
|
if (!value.length || !borderLines.has(prop2)) {
|
|
724
695
|
return;
|
|
725
696
|
}
|
|
@@ -733,11 +704,7 @@ const prepareBorderArrayValue = ({ value, priority, properties, parts, opt, bord
|
|
|
733
704
|
if (hasVarFunc(shorthandItem.value)) {
|
|
734
705
|
shorthandItem.value = "";
|
|
735
706
|
} else if (propertyValue) {
|
|
736
|
-
shorthandItem.value = replaceBorderShorthandValue(
|
|
737
|
-
propertyValue,
|
|
738
|
-
shorthandItem.value,
|
|
739
|
-
parseOpt
|
|
740
|
-
);
|
|
707
|
+
shorthandItem.value = replaceBorderShorthandValue(propertyValue, shorthandItem.value);
|
|
741
708
|
}
|
|
742
709
|
}
|
|
743
710
|
} else {
|
|
@@ -781,11 +748,7 @@ const prepareBorderArrayValue = ({ value, priority, properties, parts, opt, bord
|
|
|
781
748
|
const positionProperty = `${prop1}-${position}`;
|
|
782
749
|
const positionItem = getPropertyItem(positionProperty, properties);
|
|
783
750
|
if (positionItem.value && positionValues[position]) {
|
|
784
|
-
positionItem.value = replaceBorderShorthandValue(
|
|
785
|
-
positionValues[position],
|
|
786
|
-
positionItem.value,
|
|
787
|
-
parseOpt
|
|
788
|
-
);
|
|
751
|
+
positionItem.value = replaceBorderShorthandValue(positionValues[position], positionItem.value);
|
|
789
752
|
}
|
|
790
753
|
const longhandProperty = `${positionProperty}-${prop2}`;
|
|
791
754
|
const longhandItem = getPropertyItem(longhandProperty, properties);
|
|
@@ -797,35 +760,21 @@ const prepareBorderArrayValue = ({ value, priority, properties, parts, opt, bord
|
|
|
797
760
|
borderItems.set(border.property, shorthandItem);
|
|
798
761
|
borderItems.set(BORDER_IMAGE, imageItem);
|
|
799
762
|
borderItems.set(lineProperty, lineItem);
|
|
800
|
-
}
|
|
763
|
+
}
|
|
801
764
|
|
|
802
765
|
/**
|
|
803
766
|
* Handles border property preparation when the value is an object.
|
|
804
767
|
*
|
|
805
|
-
* @param {
|
|
768
|
+
* @param {object} params - The parameters object.
|
|
806
769
|
* @param {string} params.property - The property name.
|
|
807
|
-
* @param {
|
|
770
|
+
* @param {object} params.value - The property value.
|
|
808
771
|
* @param {string} params.priority - The property priority.
|
|
809
772
|
* @param {Map} params.properties - The map of properties.
|
|
810
|
-
* @param {
|
|
811
|
-
* @param {Object} params.opt - Parsing options.
|
|
773
|
+
* @param {object} params.parts - The split property name parts.
|
|
812
774
|
* @param {Map} params.borderItems - The map to store processed border items.
|
|
813
775
|
*/
|
|
814
|
-
|
|
815
|
-
property,
|
|
816
|
-
value,
|
|
817
|
-
priority,
|
|
818
|
-
properties,
|
|
819
|
-
parts,
|
|
820
|
-
opt,
|
|
821
|
-
borderItems
|
|
822
|
-
}) => {
|
|
776
|
+
function prepareBorderObjectValue({ property, value, priority, properties, parts, borderItems }) {
|
|
823
777
|
const { prop1, prop2 } = parts;
|
|
824
|
-
const { globalObject, options } = opt;
|
|
825
|
-
const parseOpt = {
|
|
826
|
-
globalObject,
|
|
827
|
-
options
|
|
828
|
-
};
|
|
829
778
|
const imageItem = getPropertyItem(BORDER_IMAGE, properties);
|
|
830
779
|
// Handle position shorthands.
|
|
831
780
|
if (prop2) {
|
|
@@ -843,7 +792,7 @@ const prepareBorderObjectValue = ({
|
|
|
843
792
|
const positionItem = getPropertyItem(positionProperty, properties);
|
|
844
793
|
if (shorthandItem.value) {
|
|
845
794
|
for (const positionValue of Object.values(value)) {
|
|
846
|
-
if (!matchesBorderShorthandValue(property, positionValue, shorthandItem.value
|
|
795
|
+
if (!matchesBorderShorthandValue(property, positionValue, shorthandItem.value)) {
|
|
847
796
|
shorthandItem.value = "";
|
|
848
797
|
break;
|
|
849
798
|
}
|
|
@@ -858,23 +807,11 @@ const prepareBorderObjectValue = ({
|
|
|
858
807
|
? value[longhandProperty]
|
|
859
808
|
: border.initialValues.get(`${prop1}-${line}`);
|
|
860
809
|
if (line === WIDTH && lineWidthItem.value) {
|
|
861
|
-
lineWidthItem.value = replacePositionValue(
|
|
862
|
-
itemValue,
|
|
863
|
-
splitValue(lineWidthItem.value),
|
|
864
|
-
prop2
|
|
865
|
-
);
|
|
810
|
+
lineWidthItem.value = replacePositionValue(itemValue, splitValue(lineWidthItem.value), prop2);
|
|
866
811
|
} else if (line === STYLE && lineStyleItem.value) {
|
|
867
|
-
lineStyleItem.value = replacePositionValue(
|
|
868
|
-
itemValue,
|
|
869
|
-
splitValue(lineStyleItem.value),
|
|
870
|
-
prop2
|
|
871
|
-
);
|
|
812
|
+
lineStyleItem.value = replacePositionValue(itemValue, splitValue(lineStyleItem.value), prop2);
|
|
872
813
|
} else if (line === COLOR && lineColorItem.value) {
|
|
873
|
-
lineColorItem.value = replacePositionValue(
|
|
874
|
-
itemValue,
|
|
875
|
-
splitValue(lineColorItem.value),
|
|
876
|
-
prop2
|
|
877
|
-
);
|
|
814
|
+
lineColorItem.value = replacePositionValue(itemValue, splitValue(lineColorItem.value), prop2);
|
|
878
815
|
}
|
|
879
816
|
longhandItem.value = itemValue;
|
|
880
817
|
longhandItem.priority = priority;
|
|
@@ -942,19 +879,18 @@ const prepareBorderObjectValue = ({
|
|
|
942
879
|
borderItems.set(lineStyleProperty, lineStyleItem);
|
|
943
880
|
borderItems.set(lineColorProperty, lineColorItem);
|
|
944
881
|
}
|
|
945
|
-
}
|
|
882
|
+
}
|
|
946
883
|
|
|
947
884
|
/**
|
|
948
885
|
* Prepares border properties by splitting shorthands and handling updates.
|
|
949
886
|
*
|
|
950
887
|
* @param {string} property - The border property name.
|
|
951
|
-
* @param {string|Array|
|
|
888
|
+
* @param {string|Array|object} value - The value of the property.
|
|
952
889
|
* @param {string} priority - The priority of the property (e.g., "important").
|
|
953
890
|
* @param {Map} properties - The map of all properties.
|
|
954
|
-
* @param {Object} [opt={}] - Parsing options.
|
|
955
891
|
* @returns {Map|undefined} A map of expanded or updated border properties.
|
|
956
892
|
*/
|
|
957
|
-
|
|
893
|
+
function prepareBorderProperties(property, value, priority, properties) {
|
|
958
894
|
if (typeof property !== "string" || value === null) {
|
|
959
895
|
return;
|
|
960
896
|
}
|
|
@@ -977,10 +913,7 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
|
|
|
977
913
|
prop2 = remainder;
|
|
978
914
|
}
|
|
979
915
|
}
|
|
980
|
-
if (
|
|
981
|
-
(borderPositions.has(prop2) && prop3 && !borderLines.has(prop3)) ||
|
|
982
|
-
(borderLines.has(prop2) && prop3)
|
|
983
|
-
) {
|
|
916
|
+
if ((borderPositions.has(prop2) && prop3 && !borderLines.has(prop3)) || (borderLines.has(prop2) && prop3)) {
|
|
984
917
|
return;
|
|
985
918
|
}
|
|
986
919
|
const parts = {
|
|
@@ -996,7 +929,6 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
|
|
|
996
929
|
priority,
|
|
997
930
|
properties,
|
|
998
931
|
parts,
|
|
999
|
-
opt,
|
|
1000
932
|
borderItems
|
|
1001
933
|
});
|
|
1002
934
|
} else if (Array.isArray(value)) {
|
|
@@ -1005,7 +937,6 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
|
|
|
1005
937
|
priority,
|
|
1006
938
|
properties,
|
|
1007
939
|
parts,
|
|
1008
|
-
opt,
|
|
1009
940
|
borderItems
|
|
1010
941
|
});
|
|
1011
942
|
} else if (value && typeof value === "object") {
|
|
@@ -1015,7 +946,6 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
|
|
|
1015
946
|
priority,
|
|
1016
947
|
properties,
|
|
1017
948
|
parts,
|
|
1018
|
-
opt,
|
|
1019
949
|
borderItems
|
|
1020
950
|
});
|
|
1021
951
|
}
|
|
@@ -1030,20 +960,18 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
|
|
|
1030
960
|
}
|
|
1031
961
|
for (const position of borderPositions) {
|
|
1032
962
|
const positionProperty = `${border.property}-${position}`;
|
|
1033
|
-
const positionItem =
|
|
1034
|
-
borderItems.get(positionProperty) ?? getPropertyItem(positionProperty, properties);
|
|
963
|
+
const positionItem = borderItems.get(positionProperty) ?? getPropertyItem(positionProperty, properties);
|
|
1035
964
|
borderProps.set(positionProperty, positionItem);
|
|
1036
965
|
for (const line of borderLines) {
|
|
1037
966
|
const longhandProperty = `${border.property}-${position}-${line}`;
|
|
1038
|
-
const longhandItem =
|
|
1039
|
-
borderItems.get(longhandProperty) ?? getPropertyItem(longhandProperty, properties);
|
|
967
|
+
const longhandItem = borderItems.get(longhandProperty) ?? getPropertyItem(longhandProperty, properties);
|
|
1040
968
|
borderProps.set(longhandProperty, longhandItem);
|
|
1041
969
|
}
|
|
1042
970
|
}
|
|
1043
971
|
const borderImageItem = borderItems.get(BORDER_IMAGE) ?? createPropertyItem(BORDER_IMAGE);
|
|
1044
972
|
borderProps.set(BORDER_IMAGE, borderImageItem);
|
|
1045
973
|
return borderProps;
|
|
1046
|
-
}
|
|
974
|
+
}
|
|
1047
975
|
|
|
1048
976
|
/**
|
|
1049
977
|
* Generates a border line shorthand property if all line components are present.
|
|
@@ -1053,7 +981,7 @@ const prepareBorderProperties = (property, value, priority, properties, opt = {}
|
|
|
1053
981
|
* @param {string} [priority=""] - The priority of the property.
|
|
1054
982
|
* @returns {Array} A key-value pair for the generated property.
|
|
1055
983
|
*/
|
|
1056
|
-
|
|
984
|
+
function generateBorderLineShorthand(items, property, priority = "") {
|
|
1057
985
|
const values = [];
|
|
1058
986
|
for (const [, item] of items) {
|
|
1059
987
|
const { value: itemValue } = item;
|
|
@@ -1061,7 +989,7 @@ const generateBorderLineShorthand = (items, property, priority = "") => {
|
|
|
1061
989
|
}
|
|
1062
990
|
const value = getPositionValue(values);
|
|
1063
991
|
return [property, createPropertyItem(property, value, priority)];
|
|
1064
|
-
}
|
|
992
|
+
}
|
|
1065
993
|
|
|
1066
994
|
/**
|
|
1067
995
|
* Generates a border position shorthand property if all position components are present.
|
|
@@ -1071,7 +999,7 @@ const generateBorderLineShorthand = (items, property, priority = "") => {
|
|
|
1071
999
|
* @param {string} [priority=""] - The priority of the property.
|
|
1072
1000
|
* @returns {Array} A key-value pair for the generated property.
|
|
1073
1001
|
*/
|
|
1074
|
-
|
|
1002
|
+
function generateBorderPositionShorthand(items, property, priority = "") {
|
|
1075
1003
|
const values = [];
|
|
1076
1004
|
for (const [, item] of items) {
|
|
1077
1005
|
const { value: itemValue } = item;
|
|
@@ -1079,7 +1007,7 @@ const generateBorderPositionShorthand = (items, property, priority = "") => {
|
|
|
1079
1007
|
}
|
|
1080
1008
|
const value = values.join(" ");
|
|
1081
1009
|
return [property, createPropertyItem(property, value, priority)];
|
|
1082
|
-
}
|
|
1010
|
+
}
|
|
1083
1011
|
|
|
1084
1012
|
/**
|
|
1085
1013
|
* Generates a border shorthand property if all components match.
|
|
@@ -1089,44 +1017,13 @@ const generateBorderPositionShorthand = (items, property, priority = "") => {
|
|
|
1089
1017
|
* @param {string} [priority=""] - The priority of the property.
|
|
1090
1018
|
* @returns {Array|undefined} A key-value pair for the generated property or undefined.
|
|
1091
1019
|
*/
|
|
1092
|
-
|
|
1020
|
+
function generateBorderShorthand(items, property, priority = "") {
|
|
1093
1021
|
const values = new Set(items);
|
|
1094
1022
|
if (values.size === 1) {
|
|
1095
|
-
const value = values.keys().next()
|
|
1023
|
+
const { value } = values.keys().next();
|
|
1096
1024
|
return [property, createPropertyItem(property, value, priority)];
|
|
1097
1025
|
}
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
const borderCollectionConfig = {
|
|
1101
|
-
[WIDTH]: {
|
|
1102
|
-
shorthand: borderWidth.property,
|
|
1103
|
-
generator: generateBorderLineShorthand
|
|
1104
|
-
},
|
|
1105
|
-
[STYLE]: {
|
|
1106
|
-
shorthand: borderStyle.property,
|
|
1107
|
-
generator: generateBorderLineShorthand
|
|
1108
|
-
},
|
|
1109
|
-
[COLOR]: {
|
|
1110
|
-
shorthand: borderColor.property,
|
|
1111
|
-
generator: generateBorderLineShorthand
|
|
1112
|
-
},
|
|
1113
|
-
[TOP]: {
|
|
1114
|
-
shorthand: borderTop.property,
|
|
1115
|
-
generator: generateBorderPositionShorthand
|
|
1116
|
-
},
|
|
1117
|
-
[RIGHT]: {
|
|
1118
|
-
shorthand: borderRight.property,
|
|
1119
|
-
generator: generateBorderPositionShorthand
|
|
1120
|
-
},
|
|
1121
|
-
[BOTTOM]: {
|
|
1122
|
-
shorthand: borderBottom.property,
|
|
1123
|
-
generator: generateBorderPositionShorthand
|
|
1124
|
-
},
|
|
1125
|
-
[LEFT]: {
|
|
1126
|
-
shorthand: borderLeft.property,
|
|
1127
|
-
generator: generateBorderPositionShorthand
|
|
1128
|
-
}
|
|
1129
|
-
};
|
|
1026
|
+
}
|
|
1130
1027
|
|
|
1131
1028
|
/**
|
|
1132
1029
|
* Processes and consolidates border-related longhands into shorthands where possible.
|
|
@@ -1134,7 +1031,7 @@ const borderCollectionConfig = {
|
|
|
1134
1031
|
* @param {Map} properties - The map of current properties.
|
|
1135
1032
|
* @returns {Map} The updated map with consolidated border properties.
|
|
1136
1033
|
*/
|
|
1137
|
-
|
|
1034
|
+
function prepareBorderShorthands(properties) {
|
|
1138
1035
|
const borderCollections = {};
|
|
1139
1036
|
for (const key of Object.keys(borderCollectionConfig)) {
|
|
1140
1037
|
borderCollections[key] = {
|
|
@@ -1215,8 +1112,7 @@ const prepareBorderShorthands = (properties) => {
|
|
|
1215
1112
|
properties.set(BORDER_IMAGE, imageItem);
|
|
1216
1113
|
}
|
|
1217
1114
|
} else if (shorthandPriorityItems.length === 4) {
|
|
1218
|
-
const [property, item] =
|
|
1219
|
-
generateBorderShorthand(shorthandPriorityItems, border.property, "important") ?? [];
|
|
1115
|
+
const [property, item] = generateBorderShorthand(shorthandPriorityItems, border.property, "important") ?? [];
|
|
1220
1116
|
if (property && item) {
|
|
1221
1117
|
properties.set(property, item);
|
|
1222
1118
|
properties.delete(BORDER_IMAGE);
|
|
@@ -1256,7 +1152,7 @@ const prepareBorderShorthands = (properties) => {
|
|
|
1256
1152
|
properties.set(BORDER_IMAGE, imageItem);
|
|
1257
1153
|
}
|
|
1258
1154
|
return properties;
|
|
1259
|
-
}
|
|
1155
|
+
}
|
|
1260
1156
|
|
|
1261
1157
|
/**
|
|
1262
1158
|
* Processes shorthand properties from the shorthands map.
|
|
@@ -1264,7 +1160,7 @@ const prepareBorderShorthands = (properties) => {
|
|
|
1264
1160
|
* @param {Map} shorthands - The map containing shorthand property groups.
|
|
1265
1161
|
* @returns {Map} A map of processed shorthand properties.
|
|
1266
1162
|
*/
|
|
1267
|
-
|
|
1163
|
+
function processShorthandProperties(shorthands) {
|
|
1268
1164
|
const shorthandItems = new Map();
|
|
1269
1165
|
for (const [property, item] of shorthands) {
|
|
1270
1166
|
const shorthandItem = shorthandProperties.get(property);
|
|
@@ -1282,7 +1178,7 @@ const processShorthandProperties = (shorthands) => {
|
|
|
1282
1178
|
}
|
|
1283
1179
|
}
|
|
1284
1180
|
return shorthandItems;
|
|
1285
|
-
}
|
|
1181
|
+
}
|
|
1286
1182
|
|
|
1287
1183
|
/**
|
|
1288
1184
|
* Updates the longhand properties map with a new property item.
|
|
@@ -1290,10 +1186,10 @@ const processShorthandProperties = (shorthands) => {
|
|
|
1290
1186
|
* If the existing property has "important" priority, it will not be overwritten.
|
|
1291
1187
|
*
|
|
1292
1188
|
* @param {string} property - The CSS property name.
|
|
1293
|
-
* @param {
|
|
1189
|
+
* @param {object} item - The property item object containing value and priority.
|
|
1294
1190
|
* @param {Map} longhandProperties - The map of longhand properties to update.
|
|
1295
1191
|
*/
|
|
1296
|
-
|
|
1192
|
+
function updateLonghandProperties(property, item, longhandProperties) {
|
|
1297
1193
|
if (longhandProperties.has(property)) {
|
|
1298
1194
|
const { priority: longhandPriority } = longhandProperties.get(property);
|
|
1299
1195
|
if (!longhandPriority) {
|
|
@@ -1303,22 +1199,21 @@ const updateLonghandProperties = (property, item, longhandProperties) => {
|
|
|
1303
1199
|
} else {
|
|
1304
1200
|
longhandProperties.set(property, item);
|
|
1305
1201
|
}
|
|
1306
|
-
}
|
|
1202
|
+
}
|
|
1307
1203
|
|
|
1308
1204
|
/**
|
|
1309
1205
|
* Processes border properties from the borders map, expanding and normalizing them.
|
|
1310
1206
|
*
|
|
1311
1207
|
* @param {Map} borders - The map containing accumulated border properties.
|
|
1312
|
-
* @param {Object} parseOpt - Options for parsing values.
|
|
1313
1208
|
* @returns {Map} A map of fully processed and normalized border properties.
|
|
1314
1209
|
*/
|
|
1315
|
-
|
|
1210
|
+
function processBorderProperties(borders) {
|
|
1316
1211
|
const longhandProperties = new Map();
|
|
1317
1212
|
for (const [property, item] of borders) {
|
|
1318
1213
|
if (shorthandProperties.has(property)) {
|
|
1319
1214
|
const { value, priority } = item;
|
|
1320
1215
|
if (property === border.property) {
|
|
1321
|
-
const lineItems = border.parse(value
|
|
1216
|
+
const lineItems = border.parse(value);
|
|
1322
1217
|
for (const [key, initialValue] of border.initialValues) {
|
|
1323
1218
|
if (!Object.hasOwn(lineItems, key)) {
|
|
1324
1219
|
lineItems[key] = initialValue;
|
|
@@ -1348,7 +1243,7 @@ const processBorderProperties = (borders, parseOpt) => {
|
|
|
1348
1243
|
}
|
|
1349
1244
|
} else {
|
|
1350
1245
|
const shorthandItem = shorthandProperties.get(property);
|
|
1351
|
-
const parsedItem = shorthandItem.parse(value
|
|
1246
|
+
const parsedItem = shorthandItem.parse(value);
|
|
1352
1247
|
if (Array.isArray(parsedItem)) {
|
|
1353
1248
|
let namePart, linePart;
|
|
1354
1249
|
const hyphenIndex = property.indexOf("-");
|
|
@@ -1389,21 +1284,15 @@ const processBorderProperties = (borders, parseOpt) => {
|
|
|
1389
1284
|
}
|
|
1390
1285
|
const borderItems = prepareBorderShorthands(longhandProperties);
|
|
1391
1286
|
return borderItems;
|
|
1392
|
-
}
|
|
1287
|
+
}
|
|
1393
1288
|
|
|
1394
1289
|
/**
|
|
1395
1290
|
* Normalize and prepare CSS properties, handling shorthands and longhands.
|
|
1396
1291
|
*
|
|
1397
1292
|
* @param {Map} properties - The initial map of properties.
|
|
1398
|
-
* @param {Object} [opt={}] - Parsing options.
|
|
1399
1293
|
* @returns {Map} The normalized map of properties.
|
|
1400
1294
|
*/
|
|
1401
|
-
|
|
1402
|
-
const { globalObject, options } = opt;
|
|
1403
|
-
const parseOpt = {
|
|
1404
|
-
globalObject,
|
|
1405
|
-
options
|
|
1406
|
-
};
|
|
1295
|
+
function prepareProperties(properties) {
|
|
1407
1296
|
const parsedProperties = new Map();
|
|
1408
1297
|
const shorthands = new Map();
|
|
1409
1298
|
const borders = new Map();
|
|
@@ -1434,7 +1323,7 @@ const prepareProperties = (properties, opt = {}) => {
|
|
|
1434
1323
|
parsedProperties.set(property, item);
|
|
1435
1324
|
} else if (shorthandProperties.has(property)) {
|
|
1436
1325
|
const shorthandItem = shorthandProperties.get(property);
|
|
1437
|
-
const parsedValues = shorthandItem.parse(value
|
|
1326
|
+
const parsedValues = shorthandItem.parse(value);
|
|
1438
1327
|
let omitShorthandProperty = false;
|
|
1439
1328
|
if (Array.isArray(parsedValues)) {
|
|
1440
1329
|
const [parsedValue] = parsedValues;
|
|
@@ -1449,27 +1338,18 @@ const prepareProperties = (properties, opt = {}) => {
|
|
|
1449
1338
|
}
|
|
1450
1339
|
const { position } = longhandItem;
|
|
1451
1340
|
const longhandValue = getPositionValue([parsedValue], position);
|
|
1452
|
-
parsedProperties.set(
|
|
1453
|
-
longhandProperty,
|
|
1454
|
-
createPropertyItem(longhandProperty, longhandValue, priority)
|
|
1455
|
-
);
|
|
1341
|
+
parsedProperties.set(longhandProperty, createPropertyItem(longhandProperty, longhandValue, priority));
|
|
1456
1342
|
}
|
|
1457
1343
|
} else if (parsedValue) {
|
|
1458
1344
|
for (const longhandProperty of Object.keys(parsedValue)) {
|
|
1459
1345
|
const longhandValue = parsedValue[longhandProperty];
|
|
1460
|
-
parsedProperties.set(
|
|
1461
|
-
longhandProperty,
|
|
1462
|
-
createPropertyItem(longhandProperty, longhandValue, priority)
|
|
1463
|
-
);
|
|
1346
|
+
parsedProperties.set(longhandProperty, createPropertyItem(longhandProperty, longhandValue, priority));
|
|
1464
1347
|
}
|
|
1465
1348
|
}
|
|
1466
1349
|
} else if (parsedValues && typeof parsedValues !== "string") {
|
|
1467
1350
|
for (const longhandProperty of Object.keys(parsedValues)) {
|
|
1468
1351
|
const longhandValue = parsedValues[longhandProperty];
|
|
1469
|
-
parsedProperties.set(
|
|
1470
|
-
longhandProperty,
|
|
1471
|
-
createPropertyItem(longhandProperty, longhandValue, priority)
|
|
1472
|
-
);
|
|
1352
|
+
parsedProperties.set(longhandProperty, createPropertyItem(longhandProperty, longhandValue, priority));
|
|
1473
1353
|
}
|
|
1474
1354
|
}
|
|
1475
1355
|
if (!omitShorthandProperty) {
|
|
@@ -1481,15 +1361,9 @@ const prepareProperties = (properties, opt = {}) => {
|
|
|
1481
1361
|
} else {
|
|
1482
1362
|
parsedProperties.set(property, createPropertyItem(property, value, priority));
|
|
1483
1363
|
if (hasPrecedingBackground) {
|
|
1484
|
-
const { value: shorthandValue, priority: shorthandPriority } = properties.get(
|
|
1485
|
-
background.property
|
|
1486
|
-
);
|
|
1364
|
+
const { value: shorthandValue, priority: shorthandPriority } = properties.get(background.property);
|
|
1487
1365
|
if ((!shorthandPriority || priority) && !hasVarFunc(shorthandValue)) {
|
|
1488
|
-
const replacedShorthandValue = replaceBackgroundShorthand(
|
|
1489
|
-
property,
|
|
1490
|
-
parsedProperties,
|
|
1491
|
-
parseOpt
|
|
1492
|
-
);
|
|
1366
|
+
const replacedShorthandValue = replaceBackgroundShorthand(property, parsedProperties);
|
|
1493
1367
|
properties.delete(background.property);
|
|
1494
1368
|
properties.set(
|
|
1495
1369
|
background.property,
|
|
@@ -1506,13 +1380,13 @@ const prepareProperties = (properties, opt = {}) => {
|
|
|
1506
1380
|
}
|
|
1507
1381
|
}
|
|
1508
1382
|
if (borders.size) {
|
|
1509
|
-
const borderItems = processBorderProperties(borders
|
|
1383
|
+
const borderItems = processBorderProperties(borders);
|
|
1510
1384
|
for (const [property, item] of borderItems) {
|
|
1511
1385
|
parsedProperties.set(property, item);
|
|
1512
1386
|
}
|
|
1513
1387
|
}
|
|
1514
1388
|
return parsedProperties;
|
|
1515
|
-
}
|
|
1389
|
+
}
|
|
1516
1390
|
|
|
1517
1391
|
/**
|
|
1518
1392
|
* Cleans up redundancy in border properties by removing longhands that are covered by shorthands.
|
|
@@ -1520,7 +1394,7 @@ const prepareProperties = (properties, opt = {}) => {
|
|
|
1520
1394
|
* @param {Map} properties - The map of properties to normalize.
|
|
1521
1395
|
* @returns {Map} The normalized properties map.
|
|
1522
1396
|
*/
|
|
1523
|
-
|
|
1397
|
+
function normalizeProperties(properties) {
|
|
1524
1398
|
if (properties.has(border.property)) {
|
|
1525
1399
|
for (const line of borderLines) {
|
|
1526
1400
|
properties.delete(`${border.property}-${line}`);
|
|
@@ -1562,7 +1436,7 @@ const normalizeProperties = (properties) => {
|
|
|
1562
1436
|
}
|
|
1563
1437
|
}
|
|
1564
1438
|
return properties;
|
|
1565
|
-
}
|
|
1439
|
+
}
|
|
1566
1440
|
|
|
1567
1441
|
module.exports = {
|
|
1568
1442
|
borderProperties,
|