cssstyle 5.2.1 → 5.3.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 +250 -254
- package/lib/generated/allProperties.js +39 -1
- package/lib/generated/implementedProperties.js +2219 -80
- package/lib/generated/properties.js +5253 -1904
- package/lib/normalize.js +1417 -0
- package/lib/parsers.js +372 -389
- package/lib/properties/background.js +76 -63
- package/lib/properties/backgroundAttachment.js +37 -22
- package/lib/properties/backgroundClip.js +37 -22
- package/lib/properties/backgroundColor.js +35 -15
- package/lib/properties/backgroundImage.js +49 -19
- package/lib/properties/backgroundOrigin.js +37 -22
- package/lib/properties/backgroundPosition.js +145 -128
- package/lib/properties/backgroundRepeat.js +55 -48
- package/lib/properties/backgroundSize.js +86 -46
- package/lib/properties/border.js +139 -22
- package/lib/properties/borderBottom.js +137 -21
- package/lib/properties/borderBottomColor.js +41 -16
- package/lib/properties/borderBottomStyle.js +39 -30
- package/lib/properties/borderBottomWidth.js +49 -16
- package/lib/properties/borderCollapse.js +32 -8
- package/lib/properties/borderColor.js +96 -23
- package/lib/properties/borderLeft.js +137 -21
- package/lib/properties/borderLeftColor.js +41 -16
- package/lib/properties/borderLeftStyle.js +39 -30
- package/lib/properties/borderLeftWidth.js +49 -16
- package/lib/properties/borderRight.js +137 -21
- package/lib/properties/borderRightColor.js +41 -16
- package/lib/properties/borderRightStyle.js +39 -30
- package/lib/properties/borderRightWidth.js +49 -16
- package/lib/properties/borderSpacing.js +42 -25
- package/lib/properties/borderStyle.js +96 -34
- package/lib/properties/borderTop.js +131 -15
- package/lib/properties/borderTopColor.js +41 -16
- package/lib/properties/borderTopStyle.js +39 -30
- package/lib/properties/borderTopWidth.js +49 -16
- package/lib/properties/borderWidth.js +108 -23
- package/lib/properties/bottom.js +40 -12
- package/lib/properties/clear.js +32 -22
- package/lib/properties/clip.js +46 -32
- package/lib/properties/color.js +34 -13
- package/lib/properties/display.js +169 -179
- package/lib/properties/flex.js +137 -38
- package/lib/properties/flexBasis.js +43 -14
- package/lib/properties/flexGrow.js +42 -9
- package/lib/properties/flexShrink.js +42 -9
- package/lib/properties/float.js +32 -9
- package/lib/properties/floodColor.js +34 -13
- package/lib/properties/font.js +145 -44
- package/lib/properties/fontFamily.js +66 -67
- package/lib/properties/fontSize.js +43 -26
- package/lib/properties/fontStyle.js +42 -11
- package/lib/properties/fontVariant.js +52 -15
- package/lib/properties/fontWeight.js +47 -15
- package/lib/properties/height.js +40 -13
- package/lib/properties/left.js +40 -12
- package/lib/properties/lightingColor.js +34 -13
- package/lib/properties/lineHeight.js +45 -18
- package/lib/properties/margin.js +73 -36
- package/lib/properties/marginBottom.js +43 -19
- package/lib/properties/marginLeft.js +43 -19
- package/lib/properties/marginRight.js +43 -19
- package/lib/properties/marginTop.js +43 -19
- package/lib/properties/opacity.js +41 -28
- package/lib/properties/outlineColor.js +34 -13
- package/lib/properties/padding.js +71 -36
- package/lib/properties/paddingBottom.js +44 -21
- package/lib/properties/paddingLeft.js +44 -19
- package/lib/properties/paddingRight.js +44 -19
- package/lib/properties/paddingTop.js +44 -19
- package/lib/properties/right.js +40 -12
- package/lib/properties/stopColor.js +34 -13
- package/lib/properties/top.js +40 -12
- package/lib/properties/webkitBorderAfterColor.js +34 -13
- package/lib/properties/webkitBorderBeforeColor.js +34 -13
- package/lib/properties/webkitBorderEndColor.js +34 -13
- package/lib/properties/webkitBorderStartColor.js +34 -13
- package/lib/properties/webkitColumnRuleColor.js +34 -13
- package/lib/properties/webkitTapHighlightColor.js +34 -13
- package/lib/properties/webkitTextEmphasisColor.js +34 -13
- package/lib/properties/webkitTextFillColor.js +34 -13
- package/lib/properties/webkitTextStrokeColor.js +34 -13
- package/lib/properties/width.js +40 -13
- package/lib/{allWebkitProperties.js → utils/allExtraProperties.js} +42 -1
- package/lib/utils/propertyDescriptors.js +6 -3
- package/package.json +11 -10
- package/lib/allExtraProperties.js +0 -49
- package/lib/shorthandProperties.js +0 -21
|
@@ -2,21 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const property = "background-origin";
|
|
6
|
+
const shorthand = "background";
|
|
7
|
+
|
|
8
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
9
|
+
const { globalObject } = opt;
|
|
6
10
|
if (v === "") {
|
|
7
11
|
return v;
|
|
8
12
|
}
|
|
9
|
-
const values = parsers.splitValue(v, {
|
|
10
|
-
delimiter: ","
|
|
11
|
-
});
|
|
12
|
-
const keywords = ["border-box", "padding-box", "content-box"];
|
|
13
|
+
const values = parsers.splitValue(v, { delimiter: "," });
|
|
13
14
|
const parsedValues = [];
|
|
14
|
-
for (const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
15
|
+
for (const val of values) {
|
|
16
|
+
const value = parsers.parsePropertyValue(property, val, {
|
|
17
|
+
globalObject,
|
|
18
|
+
inArray: true
|
|
19
|
+
});
|
|
20
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
21
|
+
const [{ name, type }] = value;
|
|
22
|
+
switch (type) {
|
|
23
|
+
case "GlobalKeyword":
|
|
24
|
+
case "Identifier": {
|
|
25
|
+
parsedValues.push(name);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
default: {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} else if (typeof value === "string") {
|
|
33
|
+
parsedValues.push(value);
|
|
20
34
|
}
|
|
21
35
|
}
|
|
22
36
|
if (parsedValues.length) {
|
|
@@ -24,25 +38,26 @@ module.exports.parse = function parse(v) {
|
|
|
24
38
|
}
|
|
25
39
|
};
|
|
26
40
|
|
|
27
|
-
module.exports.isValid = function isValid(v) {
|
|
28
|
-
if (v === "") {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return typeof module.exports.parse(v) === "string";
|
|
32
|
-
};
|
|
33
|
-
|
|
34
41
|
module.exports.definition = {
|
|
35
42
|
set(v) {
|
|
36
43
|
v = parsers.prepareValue(v, this._global);
|
|
37
44
|
if (parsers.hasVarFunc(v)) {
|
|
38
|
-
this._setProperty(
|
|
39
|
-
this._setProperty(
|
|
45
|
+
this._setProperty(shorthand, "");
|
|
46
|
+
this._setProperty(property, v);
|
|
40
47
|
} else {
|
|
41
|
-
|
|
48
|
+
const val = module.exports.parse(v, {
|
|
49
|
+
globalObject: this._global
|
|
50
|
+
});
|
|
51
|
+
if (typeof val === "string") {
|
|
52
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
53
|
+
const prior = this._priorities.get(property) ?? "";
|
|
54
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
55
|
+
this._setProperty(property, val, priority);
|
|
56
|
+
}
|
|
42
57
|
}
|
|
43
58
|
},
|
|
44
59
|
get() {
|
|
45
|
-
return this.getPropertyValue(
|
|
60
|
+
return this.getPropertyValue(property);
|
|
46
61
|
},
|
|
47
62
|
enumerable: true,
|
|
48
63
|
configurable: true
|
|
@@ -2,148 +2,164 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const property = "background-position";
|
|
6
|
+
const shorthand = "background";
|
|
7
|
+
const keyX = ["left", "right"];
|
|
8
|
+
const keyY = ["top", "bottom"];
|
|
9
|
+
const keywordsX = ["center", ...keyX];
|
|
10
|
+
const keywordsY = ["center", ...keyY];
|
|
11
|
+
const keywords = ["center", ...keyX, ...keyY];
|
|
12
|
+
|
|
13
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
14
|
+
const { globalObject } = opt;
|
|
6
15
|
if (v === "") {
|
|
7
16
|
return v;
|
|
8
17
|
}
|
|
9
18
|
const values = parsers.splitValue(v, {
|
|
10
19
|
delimiter: ","
|
|
11
20
|
});
|
|
12
|
-
const keyX = ["left", "right"];
|
|
13
|
-
const keyY = ["top", "bottom"];
|
|
14
|
-
const keywordsX = ["center", ...keyX];
|
|
15
|
-
const keywordsY = ["center", ...keyY];
|
|
16
|
-
const keywords = ["center", ...keyX, ...keyY];
|
|
17
21
|
const parsedValues = [];
|
|
18
|
-
for (const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
for (const val of values) {
|
|
23
|
+
const value = parsers.parsePropertyValue(property, val, {
|
|
24
|
+
globalObject,
|
|
25
|
+
inArray: true
|
|
26
|
+
});
|
|
27
|
+
if (Array.isArray(value) && value.length) {
|
|
28
|
+
let parsedValue = "";
|
|
29
|
+
switch (value.length) {
|
|
30
|
+
case 1: {
|
|
31
|
+
const [part1] = value;
|
|
32
|
+
const val1 =
|
|
33
|
+
part1.type === "Identifier" ? part1.name : parsers.parseLengthPercentage([part1]);
|
|
34
|
+
if (val1) {
|
|
35
|
+
if (val1 === "center") {
|
|
36
|
+
parsedValue = `${val1} ${val1}`;
|
|
37
|
+
} else if (val1 === "top" || val1 === "bottom") {
|
|
38
|
+
parsedValue = `center ${val1}`;
|
|
39
|
+
} else {
|
|
40
|
+
parsedValue = `${val1} center`;
|
|
41
|
+
}
|
|
35
42
|
}
|
|
43
|
+
break;
|
|
36
44
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
parsedValue = `${val2} ${val1}`;
|
|
46
|
-
} else if (keywordsX.includes(val1)) {
|
|
47
|
-
if (val2 === "center" || !keywordsX.includes(val2)) {
|
|
45
|
+
case 2: {
|
|
46
|
+
const [part1, part2] = value;
|
|
47
|
+
const val1 =
|
|
48
|
+
part1.type === "Identifier" ? part1.name : parsers.parseLengthPercentage([part1]);
|
|
49
|
+
const val2 =
|
|
50
|
+
part2.type === "Identifier" ? part2.name : parsers.parseLengthPercentage([part2]);
|
|
51
|
+
if (val1 && val2) {
|
|
52
|
+
if (keywordsX.includes(val1) && keywordsY.includes(val2)) {
|
|
48
53
|
parsedValue = `${val1} ${val2}`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (
|
|
54
|
+
} else if (keywordsY.includes(val1) && keywordsX.includes(val2)) {
|
|
55
|
+
parsedValue = `${val2} ${val1}`;
|
|
56
|
+
} else if (keywordsX.includes(val1)) {
|
|
57
|
+
if (val2 === "center" || !keywordsX.includes(val2)) {
|
|
58
|
+
parsedValue = `${val1} ${val2}`;
|
|
59
|
+
}
|
|
60
|
+
} else if (keywordsY.includes(val2)) {
|
|
61
|
+
if (!keywordsY.includes(val1)) {
|
|
62
|
+
parsedValue = `${val1} ${val2}`;
|
|
63
|
+
}
|
|
64
|
+
} else if (!keywordsY.includes(val1) && !keywordsX.includes(val2)) {
|
|
52
65
|
parsedValue = `${val1} ${val2}`;
|
|
53
66
|
}
|
|
54
|
-
} else if (!keywordsY.includes(val1) && !keywordsX.includes(val2)) {
|
|
55
|
-
parsedValue = `${val1} ${val2}`;
|
|
56
67
|
}
|
|
68
|
+
break;
|
|
57
69
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
case 3: {
|
|
71
|
+
const [part1, part2, part3] = value;
|
|
72
|
+
const val1 = part1.type === "Identifier" && part1.name;
|
|
73
|
+
const val2 =
|
|
74
|
+
part2.type === "Identifier" ? part2.name : parsers.parseLengthPercentage([part2]);
|
|
75
|
+
const val3 =
|
|
76
|
+
part3.type === "Identifier" ? part3.name : parsers.parseLengthPercentage([part3]);
|
|
77
|
+
if (val1 && val2 && val3) {
|
|
78
|
+
let posX = "";
|
|
79
|
+
let offX = "";
|
|
80
|
+
let posY = "";
|
|
81
|
+
let offY = "";
|
|
82
|
+
if (keywordsX.includes(val1)) {
|
|
83
|
+
if (keyY.includes(val2)) {
|
|
84
|
+
if (!keywords.includes(val3)) {
|
|
85
|
+
posX = val1;
|
|
86
|
+
posY = val2;
|
|
87
|
+
offY = val3;
|
|
88
|
+
}
|
|
89
|
+
} else if (keyY.includes(val3)) {
|
|
90
|
+
if (!keywords.includes(val2)) {
|
|
91
|
+
posX = val1;
|
|
92
|
+
offX = val2;
|
|
93
|
+
posY = val3;
|
|
94
|
+
}
|
|
76
95
|
}
|
|
77
|
-
} else if (
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
} else if (keywordsY.includes(val1)) {
|
|
97
|
+
if (keyX.includes(val2)) {
|
|
98
|
+
if (!keywords.includes(val3)) {
|
|
99
|
+
posX = val2;
|
|
100
|
+
offX = val3;
|
|
101
|
+
posY = val1;
|
|
102
|
+
}
|
|
103
|
+
} else if (keyX.includes(val3)) {
|
|
104
|
+
if (!keywords.includes(val2)) {
|
|
105
|
+
posX = val3;
|
|
106
|
+
posY = val1;
|
|
107
|
+
offY = val2;
|
|
108
|
+
}
|
|
82
109
|
}
|
|
83
110
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
posY = val1;
|
|
90
|
-
}
|
|
91
|
-
} else if (keyX.includes(val3)) {
|
|
92
|
-
if (!keywords.includes(val2)) {
|
|
93
|
-
posX = val3;
|
|
94
|
-
posY = val1;
|
|
95
|
-
offY = val2;
|
|
111
|
+
if (posX && posY) {
|
|
112
|
+
if (offX) {
|
|
113
|
+
parsedValue = `${posX} ${offX} ${posY}`;
|
|
114
|
+
} else if (offY) {
|
|
115
|
+
parsedValue = `${posX} ${posY} ${offY}`;
|
|
96
116
|
}
|
|
97
117
|
}
|
|
98
118
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case 4: {
|
|
122
|
+
const [part1, part2, part3, part4] = value;
|
|
123
|
+
const val1 = part1.type === "Identifier" && part1.name;
|
|
124
|
+
const val2 = parsers.parseLengthPercentage([part2]);
|
|
125
|
+
const val3 = part3.type === "Identifier" && part3.name;
|
|
126
|
+
const val4 = parsers.parseLengthPercentage([part4]);
|
|
127
|
+
if (val1 && val2 && val3 && val4) {
|
|
128
|
+
let posX = "";
|
|
129
|
+
let offX = "";
|
|
130
|
+
let posY = "";
|
|
131
|
+
let offY = "";
|
|
132
|
+
if (keywordsX.includes(val1) && keyY.includes(val3)) {
|
|
133
|
+
posX = val1;
|
|
134
|
+
offX = val2;
|
|
135
|
+
posY = val3;
|
|
136
|
+
offY = val4;
|
|
137
|
+
} else if (keyX.includes(val1) && keywordsY.includes(val3)) {
|
|
138
|
+
posX = val1;
|
|
139
|
+
offX = val2;
|
|
140
|
+
posY = val3;
|
|
141
|
+
offY = val4;
|
|
142
|
+
} else if (keyY.includes(val1) && keywordsX.includes(val3)) {
|
|
143
|
+
posX = val3;
|
|
144
|
+
offX = val4;
|
|
145
|
+
posY = val1;
|
|
146
|
+
offY = val2;
|
|
147
|
+
}
|
|
148
|
+
if (posX && offX && posY && offY) {
|
|
149
|
+
parsedValue = `${posX} ${offX} ${posY} ${offY}`;
|
|
104
150
|
}
|
|
105
151
|
}
|
|
152
|
+
break;
|
|
106
153
|
}
|
|
107
|
-
|
|
154
|
+
default:
|
|
108
155
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const val2 = parsers.parseMeasurement(part2);
|
|
114
|
-
const val3 = parsers.parseKeyword(part3, keywords);
|
|
115
|
-
const val4 = parsers.parseMeasurement(part4);
|
|
116
|
-
if (val1 && val2 && val3 && val4) {
|
|
117
|
-
let posX = "";
|
|
118
|
-
let offX = "";
|
|
119
|
-
let posY = "";
|
|
120
|
-
let offY = "";
|
|
121
|
-
if (keywordsX.includes(val1) && keyY.includes(val3)) {
|
|
122
|
-
posX = val1;
|
|
123
|
-
offX = val2;
|
|
124
|
-
posY = val3;
|
|
125
|
-
offY = val4;
|
|
126
|
-
} else if (keyX.includes(val1) && keywordsY.includes(val3)) {
|
|
127
|
-
posX = val1;
|
|
128
|
-
offX = val2;
|
|
129
|
-
posY = val3;
|
|
130
|
-
offY = val4;
|
|
131
|
-
} else if (keyY.includes(val1) && keywordsX.includes(val3)) {
|
|
132
|
-
posX = val3;
|
|
133
|
-
offX = val4;
|
|
134
|
-
posY = val1;
|
|
135
|
-
offY = val2;
|
|
136
|
-
}
|
|
137
|
-
if (posX && offX && posY && offY) {
|
|
138
|
-
parsedValue = `${posX} ${offX} ${posY} ${offY}`;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
156
|
+
if (parsedValue) {
|
|
157
|
+
parsedValues.push(parsedValue);
|
|
158
|
+
} else {
|
|
159
|
+
return;
|
|
141
160
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
parsedValues.push(parsedValue);
|
|
145
|
-
} else {
|
|
146
|
-
return;
|
|
161
|
+
} else if (typeof value === "string") {
|
|
162
|
+
parsedValues.push(value);
|
|
147
163
|
}
|
|
148
164
|
}
|
|
149
165
|
if (parsedValues.length) {
|
|
@@ -151,25 +167,26 @@ module.exports.parse = function parse(v) {
|
|
|
151
167
|
}
|
|
152
168
|
};
|
|
153
169
|
|
|
154
|
-
module.exports.isValid = function isValid(v) {
|
|
155
|
-
if (v === "") {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
return typeof module.exports.parse(v) === "string";
|
|
159
|
-
};
|
|
160
|
-
|
|
161
170
|
module.exports.definition = {
|
|
162
171
|
set(v) {
|
|
163
172
|
v = parsers.prepareValue(v, this._global);
|
|
164
173
|
if (parsers.hasVarFunc(v)) {
|
|
165
|
-
this._setProperty(
|
|
166
|
-
this._setProperty(
|
|
174
|
+
this._setProperty(shorthand, "");
|
|
175
|
+
this._setProperty(property, v);
|
|
167
176
|
} else {
|
|
168
|
-
|
|
177
|
+
const val = module.exports.parse(v, {
|
|
178
|
+
globalObject: this._global
|
|
179
|
+
});
|
|
180
|
+
if (typeof val === "string") {
|
|
181
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
182
|
+
const prior = this._priorities.get(property) ?? "";
|
|
183
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
184
|
+
this._setProperty(property, val, priority);
|
|
185
|
+
}
|
|
169
186
|
}
|
|
170
187
|
},
|
|
171
188
|
get() {
|
|
172
|
-
return this.getPropertyValue(
|
|
189
|
+
return this.getPropertyValue(property);
|
|
173
190
|
},
|
|
174
191
|
enumerable: true,
|
|
175
192
|
configurable: true
|
|
@@ -2,54 +2,60 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const property = "background-repeat";
|
|
6
|
+
const shorthand = "background";
|
|
7
|
+
|
|
8
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
9
|
+
const { globalObject } = opt;
|
|
6
10
|
if (v === "") {
|
|
7
11
|
return v;
|
|
8
12
|
}
|
|
9
13
|
const values = parsers.splitValue(v, {
|
|
10
14
|
delimiter: ","
|
|
11
15
|
});
|
|
12
|
-
const keywordsAxis = ["repeat-x", "repeat-y"];
|
|
13
|
-
const keywordsRepeat = ["repeat", "no-repeat", "space", "round"];
|
|
14
|
-
const keywords = [...keywordsAxis, ...keywordsRepeat];
|
|
15
16
|
const parsedValues = [];
|
|
16
|
-
for (const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
case 2:
|
|
32
|
-
default: {
|
|
33
|
-
const [part1, part2] = parts;
|
|
34
|
-
const val1 = parsers.parseKeyword(part1, keywordsRepeat);
|
|
35
|
-
const val2 = parsers.parseKeyword(part2, keywordsRepeat);
|
|
36
|
-
if (val1 && val2) {
|
|
37
|
-
if (val1 === "repeat" && val2 === "no-repeat") {
|
|
38
|
-
parsedValue = "repeat-x";
|
|
39
|
-
} else if (val1 === "no-repeat" && val2 === "repeat") {
|
|
40
|
-
parsedValue = "repeat-y";
|
|
41
|
-
} else if (val1 === val2) {
|
|
17
|
+
for (const val of values) {
|
|
18
|
+
const value = parsers.parsePropertyValue(property, val, {
|
|
19
|
+
globalObject,
|
|
20
|
+
inArray: true
|
|
21
|
+
});
|
|
22
|
+
if (Array.isArray(value) && value.length) {
|
|
23
|
+
let parsedValue = "";
|
|
24
|
+
switch (value.length) {
|
|
25
|
+
case 1: {
|
|
26
|
+
const [part1] = value;
|
|
27
|
+
const val1 = part1.type === "Identifier" && part1.name;
|
|
28
|
+
if (val1) {
|
|
42
29
|
parsedValue = val1;
|
|
43
|
-
} else {
|
|
44
|
-
parsedValue = `${val1} ${val2}`;
|
|
45
30
|
}
|
|
31
|
+
break;
|
|
46
32
|
}
|
|
33
|
+
case 2: {
|
|
34
|
+
const [part1, part2] = value;
|
|
35
|
+
const val1 = part1.type === "Identifier" && part1.name;
|
|
36
|
+
const val2 = part2.type === "Identifier" && part2.name;
|
|
37
|
+
if (val1 && val2) {
|
|
38
|
+
if (val1 === "repeat" && val2 === "no-repeat") {
|
|
39
|
+
parsedValue = "repeat-x";
|
|
40
|
+
} else if (val1 === "no-repeat" && val2 === "repeat") {
|
|
41
|
+
parsedValue = "repeat-y";
|
|
42
|
+
} else if (val1 === val2) {
|
|
43
|
+
parsedValue = val1;
|
|
44
|
+
} else {
|
|
45
|
+
parsedValue = `${val1} ${val2}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
default:
|
|
47
51
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
if (parsedValue) {
|
|
53
|
+
parsedValues.push(parsedValue);
|
|
54
|
+
} else {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
} else if (typeof value === "string") {
|
|
58
|
+
parsedValues.push(value);
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
if (parsedValues.length) {
|
|
@@ -57,25 +63,26 @@ module.exports.parse = function parse(v) {
|
|
|
57
63
|
}
|
|
58
64
|
};
|
|
59
65
|
|
|
60
|
-
module.exports.isValid = function isValid(v) {
|
|
61
|
-
if (v === "") {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
return typeof module.exports.parse(v) === "string";
|
|
65
|
-
};
|
|
66
|
-
|
|
67
66
|
module.exports.definition = {
|
|
68
67
|
set(v) {
|
|
69
68
|
v = parsers.prepareValue(v, this._global);
|
|
70
69
|
if (parsers.hasVarFunc(v)) {
|
|
71
|
-
this._setProperty(
|
|
72
|
-
this._setProperty(
|
|
70
|
+
this._setProperty(shorthand, "");
|
|
71
|
+
this._setProperty(property, v);
|
|
73
72
|
} else {
|
|
74
|
-
|
|
73
|
+
const val = module.exports.parse(v, {
|
|
74
|
+
globalObject: this._global
|
|
75
|
+
});
|
|
76
|
+
if (typeof val === "string") {
|
|
77
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
78
|
+
const prior = this._priorities.get(property) ?? "";
|
|
79
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
80
|
+
this._setProperty(property, val, priority);
|
|
81
|
+
}
|
|
75
82
|
}
|
|
76
83
|
},
|
|
77
84
|
get() {
|
|
78
|
-
return this.getPropertyValue(
|
|
85
|
+
return this.getPropertyValue(property);
|
|
79
86
|
},
|
|
80
87
|
enumerable: true,
|
|
81
88
|
configurable: true
|