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
|
@@ -5,37 +5,17 @@ const parsers = require("../parsers");
|
|
|
5
5
|
const property = "background-color";
|
|
6
6
|
const shorthand = "background";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const { globalObject } = opt;
|
|
10
|
-
if (v === "") {
|
|
11
|
-
return v;
|
|
12
|
-
}
|
|
13
|
-
const value = parsers.parsePropertyValue(property, v, {
|
|
14
|
-
globalObject,
|
|
15
|
-
inArray: true
|
|
16
|
-
});
|
|
17
|
-
if (Array.isArray(value) && value.length === 1) {
|
|
18
|
-
return parsers.resolveColorValue(value);
|
|
19
|
-
} else if (typeof value === "string") {
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
module.exports.definition = {
|
|
8
|
+
const descriptor = {
|
|
25
9
|
set(v) {
|
|
26
10
|
v = parsers.prepareValue(v);
|
|
27
11
|
if (parsers.hasVarFunc(v)) {
|
|
28
12
|
this._setProperty(shorthand, "");
|
|
29
13
|
this._setProperty(property, v);
|
|
30
14
|
} else {
|
|
31
|
-
const val =
|
|
32
|
-
globalObject: this._global
|
|
33
|
-
});
|
|
15
|
+
const val = parse(v);
|
|
34
16
|
if (typeof val === "string") {
|
|
35
17
|
const priority =
|
|
36
|
-
!this._priorities.get(shorthand) && this._priorities.has(property)
|
|
37
|
-
? this._priorities.get(property)
|
|
38
|
-
: "";
|
|
18
|
+
!this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
|
|
39
19
|
this._setProperty(property, val, priority);
|
|
40
20
|
}
|
|
41
21
|
}
|
|
@@ -47,4 +27,26 @@ module.exports.definition = {
|
|
|
47
27
|
configurable: true
|
|
48
28
|
};
|
|
49
29
|
|
|
50
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Parses the background-color 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) {
|
|
37
|
+
if (v === "") {
|
|
38
|
+
return v;
|
|
39
|
+
}
|
|
40
|
+
const value = parsers.parsePropertyValue(property, v);
|
|
41
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
42
|
+
return parsers.resolveColorValue(value);
|
|
43
|
+
} else if (typeof value === "string") {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
descriptor,
|
|
50
|
+
parse,
|
|
51
|
+
property
|
|
52
|
+
};
|
|
@@ -5,20 +5,44 @@ const parsers = require("../parsers");
|
|
|
5
5
|
const property = "background-image";
|
|
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-image 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
|
-
const parsedValue = parsers.
|
|
45
|
+
const parsedValue = parsers.resolveImageValue(value);
|
|
22
46
|
if (!parsedValue) {
|
|
23
47
|
return;
|
|
24
48
|
}
|
|
@@ -32,32 +56,10 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
32
56
|
if (parsedValues.length) {
|
|
33
57
|
return parsedValues.join(", ");
|
|
34
58
|
}
|
|
35
|
-
}
|
|
59
|
+
}
|
|
36
60
|
|
|
37
|
-
module.exports
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this._setProperty(shorthand, "");
|
|
42
|
-
this._setProperty(property, v);
|
|
43
|
-
} else {
|
|
44
|
-
const val = module.exports.parse(v, {
|
|
45
|
-
globalObject: this._global
|
|
46
|
-
});
|
|
47
|
-
if (typeof val === "string") {
|
|
48
|
-
const priority =
|
|
49
|
-
!this._priorities.get(shorthand) && this._priorities.has(property)
|
|
50
|
-
? this._priorities.get(property)
|
|
51
|
-
: "";
|
|
52
|
-
this._setProperty(property, val, priority);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
get() {
|
|
57
|
-
return this.getPropertyValue(property);
|
|
58
|
-
},
|
|
59
|
-
enumerable: true,
|
|
60
|
-
configurable: true
|
|
61
|
+
module.exports = {
|
|
62
|
+
descriptor,
|
|
63
|
+
parse,
|
|
64
|
+
property
|
|
61
65
|
};
|
|
62
|
-
|
|
63
|
-
module.exports.property = property;
|
|
@@ -5,18 +5,42 @@ const parsers = require("../parsers");
|
|
|
5
5
|
const property = "background-origin";
|
|
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-origin 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;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
+
// Constants
|
|
6
|
+
const { AST_TYPES } = parsers;
|
|
7
|
+
|
|
5
8
|
const property = "background-position";
|
|
6
9
|
const shorthand = "background";
|
|
7
10
|
const keyX = ["left", "right"];
|
|
@@ -10,50 +13,73 @@ const keywordsX = ["center", ...keyX];
|
|
|
10
13
|
const keywordsY = ["center", ...keyY];
|
|
11
14
|
const keywords = ["center", ...keyX, ...keyY];
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
const descriptor = {
|
|
17
|
+
set(v) {
|
|
18
|
+
v = parsers.prepareValue(v);
|
|
19
|
+
if (parsers.hasVarFunc(v)) {
|
|
20
|
+
this._setProperty(shorthand, "");
|
|
21
|
+
this._setProperty(property, v);
|
|
22
|
+
} else {
|
|
23
|
+
const val = parse(v);
|
|
24
|
+
if (typeof val === "string") {
|
|
25
|
+
const priority =
|
|
26
|
+
!this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
|
|
27
|
+
this._setProperty(property, val, priority);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
get() {
|
|
32
|
+
return this.getPropertyValue(property);
|
|
33
|
+
},
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Parses the background-position property value.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} v - The value to parse.
|
|
42
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
43
|
+
*/
|
|
44
|
+
function parse(v) {
|
|
15
45
|
if (v === "") {
|
|
16
46
|
return v;
|
|
17
47
|
}
|
|
18
|
-
const { AST_TYPES } = parsers;
|
|
19
48
|
const values = parsers.splitValue(v, {
|
|
20
49
|
delimiter: ","
|
|
21
50
|
});
|
|
22
51
|
const parsedValues = [];
|
|
23
52
|
for (const val of values) {
|
|
24
|
-
const value = parsers.parsePropertyValue(property, val
|
|
25
|
-
globalObject,
|
|
26
|
-
inArray: true
|
|
27
|
-
});
|
|
53
|
+
const value = parsers.parsePropertyValue(property, val);
|
|
28
54
|
if (Array.isArray(value) && value.length) {
|
|
29
55
|
const [part1, part2, part3, part4] = value;
|
|
30
56
|
let parsedValue = "";
|
|
31
57
|
switch (value.length) {
|
|
32
58
|
case 1: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
if (part1.type === AST_TYPES.GLOBAL_KEYWORD) {
|
|
60
|
+
parsedValue = part1.name;
|
|
61
|
+
} else {
|
|
62
|
+
const val1 =
|
|
63
|
+
part1.type === AST_TYPES.IDENTIFIER
|
|
64
|
+
? part1.name
|
|
65
|
+
: parsers.resolveNumericValue([part1], { type: "length" });
|
|
66
|
+
if (val1) {
|
|
67
|
+
if (val1 === "center") {
|
|
68
|
+
parsedValue = `${val1} ${val1}`;
|
|
69
|
+
} else if (val1 === "top" || val1 === "bottom") {
|
|
70
|
+
parsedValue = `center ${val1}`;
|
|
71
|
+
} else {
|
|
72
|
+
parsedValue = `${val1} center`;
|
|
73
|
+
}
|
|
44
74
|
}
|
|
45
75
|
}
|
|
46
76
|
break;
|
|
47
77
|
}
|
|
48
78
|
case 2: {
|
|
49
79
|
const val1 =
|
|
50
|
-
part1.type === AST_TYPES.IDENTIFIER
|
|
51
|
-
? part1.name
|
|
52
|
-
: parsers.resolveNumericValue([part1], { type: "length" });
|
|
80
|
+
part1.type === AST_TYPES.IDENTIFIER ? part1.name : parsers.resolveNumericValue([part1], { type: "length" });
|
|
53
81
|
const val2 =
|
|
54
|
-
part2.type === AST_TYPES.IDENTIFIER
|
|
55
|
-
? part2.name
|
|
56
|
-
: parsers.resolveNumericValue([part2], { type: "length" });
|
|
82
|
+
part2.type === AST_TYPES.IDENTIFIER ? part2.name : parsers.resolveNumericValue([part2], { type: "length" });
|
|
57
83
|
if (val1 && val2) {
|
|
58
84
|
if (keywordsX.includes(val1) && keywordsY.includes(val2)) {
|
|
59
85
|
parsedValue = `${val1} ${val2}`;
|
|
@@ -76,13 +102,9 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
76
102
|
case 3: {
|
|
77
103
|
const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name;
|
|
78
104
|
const val2 =
|
|
79
|
-
part2.type === AST_TYPES.IDENTIFIER
|
|
80
|
-
? part2.name
|
|
81
|
-
: parsers.resolveNumericValue([part2], { type: "length" });
|
|
105
|
+
part2.type === AST_TYPES.IDENTIFIER ? part2.name : parsers.resolveNumericValue([part2], { type: "length" });
|
|
82
106
|
const val3 =
|
|
83
|
-
part3.type === AST_TYPES.IDENTIFIER
|
|
84
|
-
? part3.name
|
|
85
|
-
: parsers.resolveNumericValue([part3], { type: "length" });
|
|
107
|
+
part3.type === AST_TYPES.IDENTIFIER ? part3.name : parsers.resolveNumericValue([part3], { type: "length" });
|
|
86
108
|
if (val1 && val2 && val3) {
|
|
87
109
|
let posX = "";
|
|
88
110
|
let offX = "";
|
|
@@ -173,32 +195,10 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
173
195
|
if (parsedValues.length) {
|
|
174
196
|
return parsedValues.join(", ");
|
|
175
197
|
}
|
|
176
|
-
}
|
|
198
|
+
}
|
|
177
199
|
|
|
178
|
-
module.exports
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this._setProperty(shorthand, "");
|
|
183
|
-
this._setProperty(property, v);
|
|
184
|
-
} else {
|
|
185
|
-
const val = module.exports.parse(v, {
|
|
186
|
-
globalObject: this._global
|
|
187
|
-
});
|
|
188
|
-
if (typeof val === "string") {
|
|
189
|
-
const priority =
|
|
190
|
-
!this._priorities.get(shorthand) && this._priorities.has(property)
|
|
191
|
-
? this._priorities.get(property)
|
|
192
|
-
: "";
|
|
193
|
-
this._setProperty(property, val, priority);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
get() {
|
|
198
|
-
return this.getPropertyValue(property);
|
|
199
|
-
},
|
|
200
|
-
enumerable: true,
|
|
201
|
-
configurable: true
|
|
200
|
+
module.exports = {
|
|
201
|
+
descriptor,
|
|
202
|
+
parse,
|
|
203
|
+
property
|
|
202
204
|
};
|
|
203
|
-
|
|
204
|
-
module.exports.property = property;
|
|
@@ -2,32 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
+
// Constants
|
|
6
|
+
const { AST_TYPES } = parsers;
|
|
7
|
+
|
|
5
8
|
const property = "background-repeat";
|
|
6
9
|
const shorthand = "background";
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
const descriptor = {
|
|
12
|
+
set(v) {
|
|
13
|
+
v = parsers.prepareValue(v);
|
|
14
|
+
if (parsers.hasVarFunc(v)) {
|
|
15
|
+
this._setProperty(shorthand, "");
|
|
16
|
+
this._setProperty(property, v);
|
|
17
|
+
} else {
|
|
18
|
+
const val = parse(v);
|
|
19
|
+
if (typeof val === "string") {
|
|
20
|
+
const priority =
|
|
21
|
+
!this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
|
|
22
|
+
this._setProperty(property, val, priority);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
get() {
|
|
27
|
+
return this.getPropertyValue(property);
|
|
28
|
+
},
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Parses the background-repeat property value.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} v - The value to parse.
|
|
37
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
38
|
+
*/
|
|
39
|
+
function parse(v) {
|
|
10
40
|
if (v === "") {
|
|
11
41
|
return v;
|
|
12
42
|
}
|
|
13
|
-
const { AST_TYPES } = parsers;
|
|
14
43
|
const values = parsers.splitValue(v, {
|
|
15
44
|
delimiter: ","
|
|
16
45
|
});
|
|
17
46
|
const parsedValues = [];
|
|
18
47
|
for (const val of values) {
|
|
19
|
-
const value = parsers.parsePropertyValue(property, val
|
|
20
|
-
globalObject,
|
|
21
|
-
inArray: true
|
|
22
|
-
});
|
|
48
|
+
const value = parsers.parsePropertyValue(property, val);
|
|
23
49
|
if (Array.isArray(value) && value.length) {
|
|
24
50
|
let parsedValue = "";
|
|
25
51
|
switch (value.length) {
|
|
26
52
|
case 1: {
|
|
27
53
|
const [part1] = value;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
parsedValue = val1;
|
|
54
|
+
if (part1.type === AST_TYPES.GLOBAL_KEYWORD || part1.type === AST_TYPES.IDENTIFIER) {
|
|
55
|
+
parsedValue = part1.name;
|
|
31
56
|
}
|
|
32
57
|
break;
|
|
33
58
|
}
|
|
@@ -62,32 +87,10 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
62
87
|
if (parsedValues.length) {
|
|
63
88
|
return parsedValues.join(", ");
|
|
64
89
|
}
|
|
65
|
-
}
|
|
90
|
+
}
|
|
66
91
|
|
|
67
|
-
module.exports
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this._setProperty(shorthand, "");
|
|
72
|
-
this._setProperty(property, v);
|
|
73
|
-
} else {
|
|
74
|
-
const val = module.exports.parse(v, {
|
|
75
|
-
globalObject: this._global
|
|
76
|
-
});
|
|
77
|
-
if (typeof val === "string") {
|
|
78
|
-
const priority =
|
|
79
|
-
!this._priorities.get(shorthand) && this._priorities.has(property)
|
|
80
|
-
? this._priorities.get(property)
|
|
81
|
-
: "";
|
|
82
|
-
this._setProperty(property, val, priority);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
get() {
|
|
87
|
-
return this.getPropertyValue(property);
|
|
88
|
-
},
|
|
89
|
-
enumerable: true,
|
|
90
|
-
configurable: true
|
|
92
|
+
module.exports = {
|
|
93
|
+
descriptor,
|
|
94
|
+
parse,
|
|
95
|
+
property
|
|
91
96
|
};
|
|
92
|
-
|
|
93
|
-
module.exports.property = property;
|
|
@@ -2,24 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
+
// Constants
|
|
6
|
+
const { AST_TYPES } = parsers;
|
|
7
|
+
|
|
5
8
|
const property = "background-size";
|
|
6
9
|
const shorthand = "background";
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
const descriptor = {
|
|
12
|
+
set(v) {
|
|
13
|
+
v = parsers.prepareValue(v);
|
|
14
|
+
if (parsers.hasVarFunc(v)) {
|
|
15
|
+
this._setProperty(shorthand, "");
|
|
16
|
+
this._setProperty(property, v);
|
|
17
|
+
} else {
|
|
18
|
+
const val = parse(v);
|
|
19
|
+
if (typeof val === "string") {
|
|
20
|
+
const priority =
|
|
21
|
+
!this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
|
|
22
|
+
this._setProperty(property, val, priority);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
get() {
|
|
27
|
+
return this.getPropertyValue(property);
|
|
28
|
+
},
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Parses the background-size property value.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} v - The value to parse.
|
|
37
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
38
|
+
*/
|
|
39
|
+
function parse(v) {
|
|
10
40
|
if (v === "") {
|
|
11
41
|
return v;
|
|
12
42
|
}
|
|
13
|
-
const { AST_TYPES } = parsers;
|
|
14
43
|
const values = parsers.splitValue(v, {
|
|
15
44
|
delimiter: ","
|
|
16
45
|
});
|
|
17
46
|
const parsedValues = [];
|
|
18
47
|
for (const val of values) {
|
|
19
|
-
const value = parsers.parsePropertyValue(property, val
|
|
20
|
-
globalObject,
|
|
21
|
-
inArray: true
|
|
22
|
-
});
|
|
48
|
+
const value = parsers.parsePropertyValue(property, val);
|
|
23
49
|
if (Array.isArray(value) && value.length) {
|
|
24
50
|
if (value.length === 1) {
|
|
25
51
|
const [{ isNumber, name, type, value: itemValue }] = value;
|
|
@@ -95,32 +121,10 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
95
121
|
if (parsedValues.length) {
|
|
96
122
|
return parsedValues.join(", ");
|
|
97
123
|
}
|
|
98
|
-
}
|
|
124
|
+
}
|
|
99
125
|
|
|
100
|
-
module.exports
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this._setProperty(shorthand, "");
|
|
105
|
-
this._setProperty(property, v);
|
|
106
|
-
} else {
|
|
107
|
-
const val = module.exports.parse(v, {
|
|
108
|
-
globalObject: this._global
|
|
109
|
-
});
|
|
110
|
-
if (typeof val === "string") {
|
|
111
|
-
const priority =
|
|
112
|
-
!this._priorities.get(shorthand) && this._priorities.has(property)
|
|
113
|
-
? this._priorities.get(property)
|
|
114
|
-
: "";
|
|
115
|
-
this._setProperty(property, val, priority);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
get() {
|
|
120
|
-
return this.getPropertyValue(property);
|
|
121
|
-
},
|
|
122
|
-
enumerable: true,
|
|
123
|
-
configurable: true
|
|
126
|
+
module.exports = {
|
|
127
|
+
descriptor,
|
|
128
|
+
parse,
|
|
129
|
+
property
|
|
124
130
|
};
|
|
125
|
-
|
|
126
|
-
module.exports.property = property;
|