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
|
@@ -12,7 +12,7 @@ const backgroundColor = require("./backgroundColor");
|
|
|
12
12
|
|
|
13
13
|
const property = "background";
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const initialValues = new Map([
|
|
16
16
|
[backgroundImage.property, "none"],
|
|
17
17
|
[backgroundPosition.property, "0% 0%"],
|
|
18
18
|
[backgroundSize.property, "auto"],
|
|
@@ -23,7 +23,7 @@ module.exports.initialValues = new Map([
|
|
|
23
23
|
[backgroundColor.property, "transparent"]
|
|
24
24
|
]);
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const shorthandFor = new Map([
|
|
27
27
|
[backgroundImage.property, backgroundImage],
|
|
28
28
|
[backgroundPosition.property, backgroundPosition],
|
|
29
29
|
[backgroundSize.property, backgroundSize],
|
|
@@ -34,8 +34,165 @@ module.exports.shorthandFor = new Map([
|
|
|
34
34
|
[backgroundColor.property, backgroundColor]
|
|
35
35
|
]);
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const descriptor = {
|
|
38
|
+
set(v) {
|
|
39
|
+
v = parsers.prepareValue(v);
|
|
40
|
+
if (v === "" || parsers.hasVarFunc(v)) {
|
|
41
|
+
for (const [key] of shorthandFor) {
|
|
42
|
+
this._setProperty(key, "");
|
|
43
|
+
}
|
|
44
|
+
this._setProperty(property, v);
|
|
45
|
+
} else {
|
|
46
|
+
const bgValues = parse(v);
|
|
47
|
+
if (!Array.isArray(bgValues)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const bgMap = new Map([
|
|
51
|
+
[backgroundImage.property, []],
|
|
52
|
+
[backgroundPosition.property, []],
|
|
53
|
+
[backgroundSize.property, []],
|
|
54
|
+
[backgroundRepeat.property, []],
|
|
55
|
+
[backgroundOrigin.property, []],
|
|
56
|
+
[backgroundClip.property, []],
|
|
57
|
+
[backgroundAttachment.property, []],
|
|
58
|
+
[backgroundColor.property, []]
|
|
59
|
+
]);
|
|
60
|
+
const backgrounds = [];
|
|
61
|
+
for (const bgValue of bgValues) {
|
|
62
|
+
const bg = [];
|
|
63
|
+
for (const [longhand, value] of Object.entries(bgValue)) {
|
|
64
|
+
if (value) {
|
|
65
|
+
const arr = bgMap.get(longhand);
|
|
66
|
+
arr.push(value);
|
|
67
|
+
bgMap.set(longhand, arr);
|
|
68
|
+
if (value !== initialValues.get(longhand)) {
|
|
69
|
+
if (longhand === backgroundSize.property) {
|
|
70
|
+
bg.push(`/ ${value}`);
|
|
71
|
+
} else {
|
|
72
|
+
bg.push(value);
|
|
73
|
+
}
|
|
74
|
+
} else if (longhand === backgroundImage.property) {
|
|
75
|
+
if (v === "none") {
|
|
76
|
+
bg.push(value);
|
|
77
|
+
}
|
|
78
|
+
} else if (longhand === backgroundColor.property) {
|
|
79
|
+
if (v === "transparent") {
|
|
80
|
+
bg.push(value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
backgrounds.push(bg.join(" "));
|
|
86
|
+
}
|
|
87
|
+
const priority = this._priorities.get(property) ?? "";
|
|
88
|
+
for (const [longhand, value] of bgMap) {
|
|
89
|
+
this._setProperty(longhand, value.join(", "), priority);
|
|
90
|
+
}
|
|
91
|
+
this._setProperty(property, backgrounds.join(", "), priority);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
get() {
|
|
95
|
+
const v = this.getPropertyValue(property);
|
|
96
|
+
if (parsers.hasVarFunc(v)) {
|
|
97
|
+
return v;
|
|
98
|
+
}
|
|
99
|
+
const bgMap = new Map();
|
|
100
|
+
let l = 0;
|
|
101
|
+
for (const [longhand] of shorthandFor) {
|
|
102
|
+
const val = this.getPropertyValue(longhand);
|
|
103
|
+
if (longhand === backgroundImage.property) {
|
|
104
|
+
if (val === "none" && v === "none" && this.getPropertyValue(backgroundColor.property) === "transparent") {
|
|
105
|
+
return val;
|
|
106
|
+
}
|
|
107
|
+
if (val !== initialValues.get(longhand)) {
|
|
108
|
+
const imgValues = parsers.splitValue(val, {
|
|
109
|
+
delimiter: ","
|
|
110
|
+
});
|
|
111
|
+
l = imgValues.length;
|
|
112
|
+
bgMap.set(longhand, imgValues);
|
|
113
|
+
}
|
|
114
|
+
} else if (longhand === backgroundColor.property) {
|
|
115
|
+
if (val !== initialValues.get(longhand) || v.includes(val)) {
|
|
116
|
+
bgMap.set(longhand, [val]);
|
|
117
|
+
}
|
|
118
|
+
} else if (val !== initialValues.get(longhand)) {
|
|
119
|
+
bgMap.set(
|
|
120
|
+
longhand,
|
|
121
|
+
parsers.splitValue(val, {
|
|
122
|
+
delimiter: ","
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (l === 0) {
|
|
128
|
+
const bgColArr = bgMap.get(backgroundColor.property);
|
|
129
|
+
const background = bgColArr ? bgColArr[0] : null;
|
|
130
|
+
if (background) {
|
|
131
|
+
return background;
|
|
132
|
+
}
|
|
133
|
+
return "";
|
|
134
|
+
}
|
|
135
|
+
const bgValues = [];
|
|
136
|
+
for (let i = 0; i < l; i++) {
|
|
137
|
+
bgValues[i] = [];
|
|
138
|
+
}
|
|
139
|
+
for (const [longhand, values] of bgMap) {
|
|
140
|
+
for (let i = 0; i < l; i++) {
|
|
141
|
+
switch (longhand) {
|
|
142
|
+
case backgroundColor.property: {
|
|
143
|
+
if (i === l - 1) {
|
|
144
|
+
const value = values[0];
|
|
145
|
+
if (parsers.hasVarFunc(value)) {
|
|
146
|
+
return "";
|
|
147
|
+
}
|
|
148
|
+
if (value && value !== initialValues.get(longhand)) {
|
|
149
|
+
const bgValue = bgValues[i];
|
|
150
|
+
bgValue.push(value);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case backgroundSize.property: {
|
|
156
|
+
const value = values[i];
|
|
157
|
+
if (parsers.hasVarFunc(value)) {
|
|
158
|
+
return "";
|
|
159
|
+
}
|
|
160
|
+
if (value && value !== initialValues.get(longhand)) {
|
|
161
|
+
const bgValue = bgValues[i];
|
|
162
|
+
bgValue.push(`/ ${value}`);
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
default: {
|
|
167
|
+
const value = values[i];
|
|
168
|
+
if (parsers.hasVarFunc(value)) {
|
|
169
|
+
return "";
|
|
170
|
+
}
|
|
171
|
+
if (value && value !== initialValues.get(longhand)) {
|
|
172
|
+
const bgValue = bgValues[i];
|
|
173
|
+
bgValue.push(value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const backgrounds = [];
|
|
180
|
+
for (const bgValue of bgValues) {
|
|
181
|
+
backgrounds.push(bgValue.join(" "));
|
|
182
|
+
}
|
|
183
|
+
return backgrounds.join(", ");
|
|
184
|
+
},
|
|
185
|
+
enumerable: true,
|
|
186
|
+
configurable: true
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Parses the background property value.
|
|
191
|
+
*
|
|
192
|
+
* @param {string} v - The value to parse.
|
|
193
|
+
* @returns {Array<object>|undefined} The parsed background values or undefined if invalid.
|
|
194
|
+
*/
|
|
195
|
+
function parse(v) {
|
|
39
196
|
if (v === "") {
|
|
40
197
|
return v;
|
|
41
198
|
} else if (parsers.hasCalcFunc(v)) {
|
|
@@ -51,30 +208,24 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
51
208
|
const l = values.length;
|
|
52
209
|
for (let i = 0; i < l; i++) {
|
|
53
210
|
let bg = {
|
|
54
|
-
[backgroundImage.property]:
|
|
55
|
-
[backgroundPosition.property]:
|
|
56
|
-
[backgroundSize.property]:
|
|
57
|
-
[backgroundRepeat.property]:
|
|
58
|
-
[backgroundOrigin.property]:
|
|
59
|
-
[backgroundClip.property]:
|
|
60
|
-
[backgroundAttachment.property]:
|
|
61
|
-
|
|
62
|
-
),
|
|
63
|
-
[backgroundColor.property]: module.exports.initialValues.get(backgroundColor.property)
|
|
211
|
+
[backgroundImage.property]: initialValues.get(backgroundImage.property),
|
|
212
|
+
[backgroundPosition.property]: initialValues.get(backgroundPosition.property),
|
|
213
|
+
[backgroundSize.property]: initialValues.get(backgroundSize.property),
|
|
214
|
+
[backgroundRepeat.property]: initialValues.get(backgroundRepeat.property),
|
|
215
|
+
[backgroundOrigin.property]: initialValues.get(backgroundOrigin.property),
|
|
216
|
+
[backgroundClip.property]: initialValues.get(backgroundClip.property),
|
|
217
|
+
[backgroundAttachment.property]: initialValues.get(backgroundAttachment.property),
|
|
218
|
+
[backgroundColor.property]: initialValues.get(backgroundColor.property)
|
|
64
219
|
};
|
|
65
220
|
if (l > 1 && i !== l - 1) {
|
|
66
221
|
bg = {
|
|
67
|
-
[backgroundImage.property]:
|
|
68
|
-
[backgroundPosition.property]:
|
|
69
|
-
|
|
70
|
-
),
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[backgroundClip.property]: module.exports.initialValues.get(backgroundClip.property),
|
|
75
|
-
[backgroundAttachment.property]: module.exports.initialValues.get(
|
|
76
|
-
backgroundAttachment.property
|
|
77
|
-
)
|
|
222
|
+
[backgroundImage.property]: initialValues.get(backgroundImage.property),
|
|
223
|
+
[backgroundPosition.property]: initialValues.get(backgroundPosition.property),
|
|
224
|
+
[backgroundSize.property]: initialValues.get(backgroundSize.property),
|
|
225
|
+
[backgroundRepeat.property]: initialValues.get(backgroundRepeat.property),
|
|
226
|
+
[backgroundOrigin.property]: initialValues.get(backgroundOrigin.property),
|
|
227
|
+
[backgroundClip.property]: initialValues.get(backgroundClip.property),
|
|
228
|
+
[backgroundAttachment.property]: initialValues.get(backgroundAttachment.property)
|
|
78
229
|
};
|
|
79
230
|
}
|
|
80
231
|
const bgPosition = [];
|
|
@@ -91,13 +242,13 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
91
242
|
const parts1 = parsers.splitValue(bgPart1);
|
|
92
243
|
for (const part of parts1) {
|
|
93
244
|
let partValid = false;
|
|
94
|
-
for (const [longhand, value] of
|
|
245
|
+
for (const [longhand, value] of shorthandFor) {
|
|
95
246
|
if (parsers.isValidPropertyValue(longhand, part)) {
|
|
96
247
|
partValid = true;
|
|
97
248
|
switch (longhand) {
|
|
98
249
|
case backgroundClip.property:
|
|
99
250
|
case backgroundOrigin.property: {
|
|
100
|
-
const parsedValue = value.parse(part
|
|
251
|
+
const parsedValue = value.parse(part);
|
|
101
252
|
if (parsedValue) {
|
|
102
253
|
bgBox.push(parsedValue);
|
|
103
254
|
}
|
|
@@ -107,21 +258,21 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
107
258
|
if (i !== values.length - 1) {
|
|
108
259
|
return;
|
|
109
260
|
}
|
|
110
|
-
const parsedValue = value.parse(part
|
|
261
|
+
const parsedValue = value.parse(part);
|
|
111
262
|
if (parsedValue) {
|
|
112
263
|
bg[longhand] = parsedValue;
|
|
113
264
|
}
|
|
114
265
|
break;
|
|
115
266
|
}
|
|
116
267
|
case backgroundPosition.property: {
|
|
117
|
-
const parsedValue = value.parse(part
|
|
268
|
+
const parsedValue = value.parse(part);
|
|
118
269
|
if (parsedValue) {
|
|
119
270
|
bgPosition.push(parsedValue);
|
|
120
271
|
}
|
|
121
272
|
break;
|
|
122
273
|
}
|
|
123
274
|
case backgroundRepeat.property: {
|
|
124
|
-
const parsedValue = value.parse(part
|
|
275
|
+
const parsedValue = value.parse(part);
|
|
125
276
|
if (parsedValue) {
|
|
126
277
|
bgRepeat.push(parsedValue);
|
|
127
278
|
}
|
|
@@ -131,7 +282,7 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
131
282
|
break;
|
|
132
283
|
}
|
|
133
284
|
default: {
|
|
134
|
-
const parsedValue = value.parse(part
|
|
285
|
+
const parsedValue = value.parse(part);
|
|
135
286
|
if (parsedValue) {
|
|
136
287
|
bg[longhand] = parsedValue;
|
|
137
288
|
}
|
|
@@ -147,13 +298,13 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
147
298
|
const parts2 = parsers.splitValue(bgPart2);
|
|
148
299
|
for (const part of parts2) {
|
|
149
300
|
let partValid = false;
|
|
150
|
-
for (const [longhand, value] of
|
|
301
|
+
for (const [longhand, value] of shorthandFor) {
|
|
151
302
|
if (parsers.isValidPropertyValue(longhand, part)) {
|
|
152
303
|
partValid = true;
|
|
153
304
|
switch (longhand) {
|
|
154
305
|
case backgroundClip.property:
|
|
155
306
|
case backgroundOrigin.property: {
|
|
156
|
-
const parsedValue = value.parse(part
|
|
307
|
+
const parsedValue = value.parse(part);
|
|
157
308
|
if (parsedValue) {
|
|
158
309
|
bgBox.push(parsedValue);
|
|
159
310
|
}
|
|
@@ -163,7 +314,7 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
163
314
|
if (i !== l - 1) {
|
|
164
315
|
return;
|
|
165
316
|
}
|
|
166
|
-
const parsedValue = value.parse(part
|
|
317
|
+
const parsedValue = value.parse(part);
|
|
167
318
|
if (parsedValue) {
|
|
168
319
|
bg[longhand] = parsedValue;
|
|
169
320
|
}
|
|
@@ -173,21 +324,21 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
173
324
|
break;
|
|
174
325
|
}
|
|
175
326
|
case backgroundRepeat.property: {
|
|
176
|
-
const parsedValue = value.parse(part
|
|
327
|
+
const parsedValue = value.parse(part);
|
|
177
328
|
if (parsedValue) {
|
|
178
329
|
bgRepeat.push(parsedValue);
|
|
179
330
|
}
|
|
180
331
|
break;
|
|
181
332
|
}
|
|
182
333
|
case backgroundSize.property: {
|
|
183
|
-
const parsedValue = value.parse(part
|
|
334
|
+
const parsedValue = value.parse(part);
|
|
184
335
|
if (parsedValue) {
|
|
185
336
|
bgSize.push(parsedValue);
|
|
186
337
|
}
|
|
187
338
|
break;
|
|
188
339
|
}
|
|
189
340
|
default: {
|
|
190
|
-
const parsedValue = value.parse(part
|
|
341
|
+
const parsedValue = value.parse(part);
|
|
191
342
|
if (parsedValue) {
|
|
192
343
|
bg[longhand] = parsedValue;
|
|
193
344
|
}
|
|
@@ -201,22 +352,22 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
201
352
|
}
|
|
202
353
|
}
|
|
203
354
|
if (bgPosition.length) {
|
|
204
|
-
const { parse: parser } =
|
|
205
|
-
const value = parser(bgPosition.join(" ")
|
|
355
|
+
const { parse: parser } = shorthandFor.get(backgroundPosition.property);
|
|
356
|
+
const value = parser(bgPosition.join(" "));
|
|
206
357
|
if (value) {
|
|
207
358
|
bg[backgroundPosition.property] = value;
|
|
208
359
|
}
|
|
209
360
|
}
|
|
210
361
|
if (bgSize.length) {
|
|
211
|
-
const { parse: parser } =
|
|
212
|
-
const value = parser(bgSize.join(" ")
|
|
362
|
+
const { parse: parser } = shorthandFor.get(backgroundSize.property);
|
|
363
|
+
const value = parser(bgSize.join(" "));
|
|
213
364
|
if (value) {
|
|
214
365
|
bg[backgroundSize.property] = value;
|
|
215
366
|
}
|
|
216
367
|
}
|
|
217
368
|
if (bgRepeat.length) {
|
|
218
|
-
const { parse: parser } =
|
|
219
|
-
const value = parser(bgRepeat.join(" ")
|
|
369
|
+
const { parse: parser } = shorthandFor.get(backgroundRepeat.property);
|
|
370
|
+
const value = parser(bgRepeat.join(" "));
|
|
220
371
|
if (value) {
|
|
221
372
|
bg[backgroundRepeat.property] = value;
|
|
222
373
|
}
|
|
@@ -243,164 +394,12 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
243
394
|
bgValues.push(bg);
|
|
244
395
|
}
|
|
245
396
|
return bgValues;
|
|
246
|
-
}
|
|
397
|
+
}
|
|
247
398
|
|
|
248
|
-
module.exports
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
this._setProperty(property, v);
|
|
256
|
-
} else {
|
|
257
|
-
const bgValues = module.exports.parse(v, {
|
|
258
|
-
globalObject: this._global
|
|
259
|
-
});
|
|
260
|
-
if (!Array.isArray(bgValues)) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
const bgMap = new Map([
|
|
264
|
-
[backgroundImage.property, []],
|
|
265
|
-
[backgroundPosition.property, []],
|
|
266
|
-
[backgroundSize.property, []],
|
|
267
|
-
[backgroundRepeat.property, []],
|
|
268
|
-
[backgroundOrigin.property, []],
|
|
269
|
-
[backgroundClip.property, []],
|
|
270
|
-
[backgroundAttachment.property, []],
|
|
271
|
-
[backgroundColor.property, []]
|
|
272
|
-
]);
|
|
273
|
-
const backgrounds = [];
|
|
274
|
-
for (const bgValue of bgValues) {
|
|
275
|
-
const bg = [];
|
|
276
|
-
for (const [longhand, value] of Object.entries(bgValue)) {
|
|
277
|
-
if (value) {
|
|
278
|
-
const arr = bgMap.get(longhand);
|
|
279
|
-
arr.push(value);
|
|
280
|
-
bgMap.set(longhand, arr);
|
|
281
|
-
if (value !== module.exports.initialValues.get(longhand)) {
|
|
282
|
-
if (longhand === backgroundSize.property) {
|
|
283
|
-
bg.push(`/ ${value}`);
|
|
284
|
-
} else {
|
|
285
|
-
bg.push(value);
|
|
286
|
-
}
|
|
287
|
-
} else if (longhand === backgroundImage.property) {
|
|
288
|
-
if (v === "none") {
|
|
289
|
-
bg.push(value);
|
|
290
|
-
}
|
|
291
|
-
} else if (longhand === backgroundColor.property) {
|
|
292
|
-
if (v === "transparent") {
|
|
293
|
-
bg.push(value);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
backgrounds.push(bg.join(" "));
|
|
299
|
-
}
|
|
300
|
-
const priority = this._priorities.get(property) ?? "";
|
|
301
|
-
for (const [longhand, value] of bgMap) {
|
|
302
|
-
this._setProperty(longhand, value.join(", "), priority);
|
|
303
|
-
}
|
|
304
|
-
this._setProperty(property, backgrounds.join(", "), priority);
|
|
305
|
-
}
|
|
306
|
-
},
|
|
307
|
-
get() {
|
|
308
|
-
const v = this.getPropertyValue(property);
|
|
309
|
-
if (parsers.hasVarFunc(v)) {
|
|
310
|
-
return v;
|
|
311
|
-
}
|
|
312
|
-
const bgMap = new Map();
|
|
313
|
-
let l = 0;
|
|
314
|
-
for (const [longhand] of module.exports.shorthandFor) {
|
|
315
|
-
const val = this.getPropertyValue(longhand);
|
|
316
|
-
if (longhand === backgroundImage.property) {
|
|
317
|
-
if (
|
|
318
|
-
val === "none" &&
|
|
319
|
-
v === "none" &&
|
|
320
|
-
this.getPropertyValue(backgroundColor.property) === "transparent"
|
|
321
|
-
) {
|
|
322
|
-
return val;
|
|
323
|
-
}
|
|
324
|
-
if (val !== module.exports.initialValues.get(longhand)) {
|
|
325
|
-
const imgValues = parsers.splitValue(val, {
|
|
326
|
-
delimiter: ","
|
|
327
|
-
});
|
|
328
|
-
l = imgValues.length;
|
|
329
|
-
bgMap.set(longhand, imgValues);
|
|
330
|
-
}
|
|
331
|
-
} else if (longhand === backgroundColor.property) {
|
|
332
|
-
if (val !== module.exports.initialValues.get(longhand) || v.includes(val)) {
|
|
333
|
-
bgMap.set(longhand, [val]);
|
|
334
|
-
}
|
|
335
|
-
} else if (val !== module.exports.initialValues.get(longhand)) {
|
|
336
|
-
bgMap.set(
|
|
337
|
-
longhand,
|
|
338
|
-
parsers.splitValue(val, {
|
|
339
|
-
delimiter: ","
|
|
340
|
-
})
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
if (l === 0) {
|
|
345
|
-
const bgColArr = bgMap.get(backgroundColor.property);
|
|
346
|
-
const background = bgColArr ? bgColArr[0] : null;
|
|
347
|
-
if (background) {
|
|
348
|
-
return background;
|
|
349
|
-
}
|
|
350
|
-
return "";
|
|
351
|
-
}
|
|
352
|
-
const bgValues = [];
|
|
353
|
-
for (let i = 0; i < l; i++) {
|
|
354
|
-
bgValues[i] = [];
|
|
355
|
-
}
|
|
356
|
-
for (const [longhand, values] of bgMap) {
|
|
357
|
-
for (let i = 0; i < l; i++) {
|
|
358
|
-
switch (longhand) {
|
|
359
|
-
case backgroundColor.property: {
|
|
360
|
-
if (i === l - 1) {
|
|
361
|
-
const value = values[0];
|
|
362
|
-
if (parsers.hasVarFunc(value)) {
|
|
363
|
-
return "";
|
|
364
|
-
}
|
|
365
|
-
if (value && value !== module.exports.initialValues.get(longhand)) {
|
|
366
|
-
const bgValue = bgValues[i];
|
|
367
|
-
bgValue.push(value);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
case backgroundSize.property: {
|
|
373
|
-
const value = values[i];
|
|
374
|
-
if (parsers.hasVarFunc(value)) {
|
|
375
|
-
return "";
|
|
376
|
-
}
|
|
377
|
-
if (value && value !== module.exports.initialValues.get(longhand)) {
|
|
378
|
-
const bgValue = bgValues[i];
|
|
379
|
-
bgValue.push(`/ ${value}`);
|
|
380
|
-
}
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
default: {
|
|
384
|
-
const value = values[i];
|
|
385
|
-
if (parsers.hasVarFunc(value)) {
|
|
386
|
-
return "";
|
|
387
|
-
}
|
|
388
|
-
if (value && value !== module.exports.initialValues.get(longhand)) {
|
|
389
|
-
const bgValue = bgValues[i];
|
|
390
|
-
bgValue.push(value);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
const backgrounds = [];
|
|
397
|
-
for (const bgValue of bgValues) {
|
|
398
|
-
backgrounds.push(bgValue.join(" "));
|
|
399
|
-
}
|
|
400
|
-
return backgrounds.join(", ");
|
|
401
|
-
},
|
|
402
|
-
enumerable: true,
|
|
403
|
-
configurable: true
|
|
399
|
+
module.exports = {
|
|
400
|
+
descriptor,
|
|
401
|
+
initialValues,
|
|
402
|
+
parse,
|
|
403
|
+
property,
|
|
404
|
+
shorthandFor
|
|
404
405
|
};
|
|
405
|
-
|
|
406
|
-
module.exports.property = property;
|
|
@@ -5,18 +5,42 @@ const parsers = require("../parsers");
|
|
|
5
5
|
const property = "background-attachment";
|
|
6
6
|
const shorthand = "background";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const descriptor = {
|
|
9
|
+
set(v) {
|
|
10
|
+
v = parsers.prepareValue(v);
|
|
11
|
+
if (parsers.hasVarFunc(v)) {
|
|
12
|
+
this._setProperty(shorthand, "");
|
|
13
|
+
this._setProperty(property, v);
|
|
14
|
+
} else {
|
|
15
|
+
const val = parse(v);
|
|
16
|
+
if (typeof val === "string") {
|
|
17
|
+
const priority =
|
|
18
|
+
!this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
|
|
19
|
+
this._setProperty(property, val, priority);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
get() {
|
|
24
|
+
return this.getPropertyValue(property);
|
|
25
|
+
},
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Parses the background-attachment property value.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} v - The value to parse.
|
|
34
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
35
|
+
*/
|
|
36
|
+
function parse(v) {
|
|
10
37
|
if (v === "") {
|
|
11
38
|
return v;
|
|
12
39
|
}
|
|
13
40
|
const values = parsers.splitValue(v, { delimiter: "," });
|
|
14
41
|
const parsedValues = [];
|
|
15
42
|
for (const val of values) {
|
|
16
|
-
const value = parsers.parsePropertyValue(property, val
|
|
17
|
-
globalObject,
|
|
18
|
-
inArray: true
|
|
19
|
-
});
|
|
43
|
+
const value = parsers.parsePropertyValue(property, val);
|
|
20
44
|
if (Array.isArray(value) && value.length === 1) {
|
|
21
45
|
const parsedValue = parsers.resolveKeywordValue(value);
|
|
22
46
|
if (!parsedValue) {
|
|
@@ -30,32 +54,10 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
30
54
|
if (parsedValues.length) {
|
|
31
55
|
return parsedValues.join(", ");
|
|
32
56
|
}
|
|
33
|
-
}
|
|
57
|
+
}
|
|
34
58
|
|
|
35
|
-
module.exports
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this._setProperty(shorthand, "");
|
|
40
|
-
this._setProperty(property, v);
|
|
41
|
-
} else {
|
|
42
|
-
const val = module.exports.parse(v, {
|
|
43
|
-
globalObject: this._global
|
|
44
|
-
});
|
|
45
|
-
if (typeof val === "string") {
|
|
46
|
-
const priority =
|
|
47
|
-
!this._priorities.get(shorthand) && this._priorities.has(property)
|
|
48
|
-
? this._priorities.get(property)
|
|
49
|
-
: "";
|
|
50
|
-
this._setProperty(property, val, priority);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
get() {
|
|
55
|
-
return this.getPropertyValue(property);
|
|
56
|
-
},
|
|
57
|
-
enumerable: true,
|
|
58
|
-
configurable: true
|
|
59
|
+
module.exports = {
|
|
60
|
+
descriptor,
|
|
61
|
+
parse,
|
|
62
|
+
property
|
|
59
63
|
};
|
|
60
|
-
|
|
61
|
-
module.exports.property = property;
|
|
@@ -5,18 +5,42 @@ const parsers = require("../parsers");
|
|
|
5
5
|
const property = "background-clip";
|
|
6
6
|
const shorthand = "background";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const descriptor = {
|
|
9
|
+
set(v) {
|
|
10
|
+
v = parsers.prepareValue(v);
|
|
11
|
+
if (parsers.hasVarFunc(v)) {
|
|
12
|
+
this._setProperty(shorthand, "");
|
|
13
|
+
this._setProperty(property, v);
|
|
14
|
+
} else {
|
|
15
|
+
const val = parse(v);
|
|
16
|
+
if (typeof val === "string") {
|
|
17
|
+
const priority =
|
|
18
|
+
!this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
|
|
19
|
+
this._setProperty(property, val, priority);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
get() {
|
|
24
|
+
return this.getPropertyValue(property);
|
|
25
|
+
},
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Parses the background-clip property value.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} v - The value to parse.
|
|
34
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
35
|
+
*/
|
|
36
|
+
function parse(v) {
|
|
10
37
|
if (v === "") {
|
|
11
38
|
return v;
|
|
12
39
|
}
|
|
13
40
|
const values = parsers.splitValue(v, { delimiter: "," });
|
|
14
41
|
const parsedValues = [];
|
|
15
42
|
for (const val of values) {
|
|
16
|
-
const value = parsers.parsePropertyValue(property, val
|
|
17
|
-
globalObject,
|
|
18
|
-
inArray: true
|
|
19
|
-
});
|
|
43
|
+
const value = parsers.parsePropertyValue(property, val);
|
|
20
44
|
if (Array.isArray(value) && value.length === 1) {
|
|
21
45
|
const parsedValue = parsers.resolveKeywordValue(value);
|
|
22
46
|
if (!parsedValue) {
|
|
@@ -30,32 +54,10 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
30
54
|
if (parsedValues.length) {
|
|
31
55
|
return parsedValues.join(", ");
|
|
32
56
|
}
|
|
33
|
-
}
|
|
57
|
+
}
|
|
34
58
|
|
|
35
|
-
module.exports
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this._setProperty(shorthand, "");
|
|
40
|
-
this._setProperty(property, v);
|
|
41
|
-
} else {
|
|
42
|
-
const val = module.exports.parse(v, {
|
|
43
|
-
globalObject: this._global
|
|
44
|
-
});
|
|
45
|
-
if (typeof val === "string") {
|
|
46
|
-
const priority =
|
|
47
|
-
!this._priorities.get(shorthand) && this._priorities.has(property)
|
|
48
|
-
? this._priorities.get(property)
|
|
49
|
-
: "";
|
|
50
|
-
this._setProperty(property, val, priority);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
get() {
|
|
55
|
-
return this.getPropertyValue(property);
|
|
56
|
-
},
|
|
57
|
-
enumerable: true,
|
|
58
|
-
configurable: true
|
|
59
|
+
module.exports = {
|
|
60
|
+
descriptor,
|
|
61
|
+
parse,
|
|
62
|
+
property
|
|
59
63
|
};
|
|
60
|
-
|
|
61
|
-
module.exports.property = property;
|