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/properties/bottom.js
CHANGED
|
@@ -4,33 +4,13 @@ const parsers = require("../parsers");
|
|
|
4
4
|
|
|
5
5
|
const property = "bottom";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const { globalObject } = opt;
|
|
9
|
-
if (v === "") {
|
|
10
|
-
return v;
|
|
11
|
-
}
|
|
12
|
-
const value = parsers.parsePropertyValue(property, v, {
|
|
13
|
-
globalObject,
|
|
14
|
-
inArray: true
|
|
15
|
-
});
|
|
16
|
-
if (Array.isArray(value) && value.length === 1) {
|
|
17
|
-
return parsers.resolveNumericValue(value, {
|
|
18
|
-
type: "length"
|
|
19
|
-
});
|
|
20
|
-
} else if (typeof value === "string") {
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
module.exports.definition = {
|
|
7
|
+
const descriptor = {
|
|
26
8
|
set(v) {
|
|
27
9
|
v = parsers.prepareValue(v);
|
|
28
10
|
if (parsers.hasVarFunc(v)) {
|
|
29
11
|
this._setProperty(property, v);
|
|
30
12
|
} else {
|
|
31
|
-
const val =
|
|
32
|
-
globalObject: this._global
|
|
33
|
-
});
|
|
13
|
+
const val = parse(v);
|
|
34
14
|
if (typeof val === "string") {
|
|
35
15
|
const priority = this._priorities.get(property) ?? "";
|
|
36
16
|
this._setProperty(property, val, priority);
|
|
@@ -44,4 +24,28 @@ module.exports.definition = {
|
|
|
44
24
|
configurable: true
|
|
45
25
|
};
|
|
46
26
|
|
|
47
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Parses the bottom property value.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} v - The value to parse.
|
|
31
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
32
|
+
*/
|
|
33
|
+
function parse(v) {
|
|
34
|
+
if (v === "") {
|
|
35
|
+
return v;
|
|
36
|
+
}
|
|
37
|
+
const value = parsers.parsePropertyValue(property, v);
|
|
38
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
39
|
+
return parsers.resolveNumericValue(value, {
|
|
40
|
+
type: "length"
|
|
41
|
+
});
|
|
42
|
+
} else if (typeof value === "string") {
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
descriptor,
|
|
49
|
+
parse,
|
|
50
|
+
property
|
|
51
|
+
};
|
package/lib/properties/clear.js
CHANGED
|
@@ -4,31 +4,13 @@ const parsers = require("../parsers");
|
|
|
4
4
|
|
|
5
5
|
const property = "clear";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const { globalObject } = opt;
|
|
9
|
-
if (v === "") {
|
|
10
|
-
return v;
|
|
11
|
-
}
|
|
12
|
-
const value = parsers.parsePropertyValue(property, v, {
|
|
13
|
-
globalObject,
|
|
14
|
-
inArray: true
|
|
15
|
-
});
|
|
16
|
-
if (Array.isArray(value) && value.length === 1) {
|
|
17
|
-
return parsers.resolveKeywordValue(value);
|
|
18
|
-
} else if (typeof value === "string") {
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
module.exports.definition = {
|
|
7
|
+
const descriptor = {
|
|
24
8
|
set(v) {
|
|
25
9
|
v = parsers.prepareValue(v);
|
|
26
10
|
if (parsers.hasVarFunc(v)) {
|
|
27
11
|
this._setProperty(property, v);
|
|
28
12
|
} else {
|
|
29
|
-
const val =
|
|
30
|
-
globalObject: this._global
|
|
31
|
-
});
|
|
13
|
+
const val = parse(v);
|
|
32
14
|
if (typeof val === "string") {
|
|
33
15
|
const priority = this._priorities.get(property) ?? "";
|
|
34
16
|
this._setProperty(property, val, priority);
|
|
@@ -42,4 +24,26 @@ module.exports.definition = {
|
|
|
42
24
|
configurable: true
|
|
43
25
|
};
|
|
44
26
|
|
|
45
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Parses the clear property value.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} v - The value to parse.
|
|
31
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
32
|
+
*/
|
|
33
|
+
function parse(v) {
|
|
34
|
+
if (v === "") {
|
|
35
|
+
return v;
|
|
36
|
+
}
|
|
37
|
+
const value = parsers.parsePropertyValue(property, v);
|
|
38
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
39
|
+
return parsers.resolveKeywordValue(value);
|
|
40
|
+
} else if (typeof value === "string") {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
descriptor,
|
|
47
|
+
parse,
|
|
48
|
+
property
|
|
49
|
+
};
|
package/lib/properties/clip.js
CHANGED
|
@@ -4,18 +4,42 @@
|
|
|
4
4
|
|
|
5
5
|
const parsers = require("../parsers");
|
|
6
6
|
|
|
7
|
+
// Constants
|
|
8
|
+
const { AST_TYPES } = parsers;
|
|
9
|
+
|
|
7
10
|
const property = "clip";
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
const descriptor = {
|
|
13
|
+
set(v) {
|
|
14
|
+
v = parsers.prepareValue(v);
|
|
15
|
+
if (parsers.hasVarFunc(v)) {
|
|
16
|
+
this._setProperty(property, v);
|
|
17
|
+
} else {
|
|
18
|
+
const val = parse(v);
|
|
19
|
+
if (typeof val === "string") {
|
|
20
|
+
const priority = this._priorities.get(property) ?? "";
|
|
21
|
+
this._setProperty(property, val, priority);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
get() {
|
|
26
|
+
return this.getPropertyValue(property);
|
|
27
|
+
},
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Parses the clip property value.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} v - The value to parse.
|
|
36
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
37
|
+
*/
|
|
38
|
+
function parse(v) {
|
|
11
39
|
if (v === "") {
|
|
12
40
|
return v;
|
|
13
41
|
}
|
|
14
|
-
const
|
|
15
|
-
const value = parsers.parsePropertyValue(property, v, {
|
|
16
|
-
globalObject,
|
|
17
|
-
inArray: true
|
|
18
|
-
});
|
|
42
|
+
const value = parsers.parsePropertyValue(property, v);
|
|
19
43
|
if (Array.isArray(value) && value.length === 1) {
|
|
20
44
|
const [{ name, type, value: itemValue }] = value;
|
|
21
45
|
switch (type) {
|
|
@@ -25,7 +49,7 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
25
49
|
});
|
|
26
50
|
const parsedValues = [];
|
|
27
51
|
for (const item of values) {
|
|
28
|
-
const parsedValue = parsers.parseCSS(item, { context: "value" }
|
|
52
|
+
const parsedValue = parsers.parseCSS(item, { context: "value" });
|
|
29
53
|
const val = parsers.resolveNumericValue(parsedValue.children, {
|
|
30
54
|
type: "length"
|
|
31
55
|
});
|
|
@@ -46,28 +70,10 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
46
70
|
} else if (typeof value === "string") {
|
|
47
71
|
return value;
|
|
48
72
|
}
|
|
49
|
-
}
|
|
73
|
+
}
|
|
50
74
|
|
|
51
|
-
module.exports
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this._setProperty(property, v);
|
|
56
|
-
} else {
|
|
57
|
-
const val = module.exports.parse(v, {
|
|
58
|
-
globalObject: this._global
|
|
59
|
-
});
|
|
60
|
-
if (typeof val === "string") {
|
|
61
|
-
const priority = this._priorities.get(property) ?? "";
|
|
62
|
-
this._setProperty(property, val, priority);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
get() {
|
|
67
|
-
return this.getPropertyValue(property);
|
|
68
|
-
},
|
|
69
|
-
enumerable: true,
|
|
70
|
-
configurable: true
|
|
75
|
+
module.exports = {
|
|
76
|
+
descriptor,
|
|
77
|
+
parse,
|
|
78
|
+
property
|
|
71
79
|
};
|
|
72
|
-
|
|
73
|
-
module.exports.property = property;
|
package/lib/properties/color.js
CHANGED
|
@@ -4,31 +4,13 @@ const parsers = require("../parsers");
|
|
|
4
4
|
|
|
5
5
|
const property = "color";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const { globalObject } = opt;
|
|
9
|
-
if (v === "") {
|
|
10
|
-
return v;
|
|
11
|
-
}
|
|
12
|
-
const value = parsers.parsePropertyValue(property, v, {
|
|
13
|
-
globalObject,
|
|
14
|
-
inArray: true
|
|
15
|
-
});
|
|
16
|
-
if (Array.isArray(value) && value.length === 1) {
|
|
17
|
-
return parsers.resolveColorValue(value);
|
|
18
|
-
} else if (typeof value === "string") {
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
module.exports.definition = {
|
|
7
|
+
const descriptor = {
|
|
24
8
|
set(v) {
|
|
25
9
|
v = parsers.prepareValue(v);
|
|
26
10
|
if (parsers.hasVarFunc(v)) {
|
|
27
11
|
this._setProperty(property, v);
|
|
28
12
|
} else {
|
|
29
|
-
const val =
|
|
30
|
-
globalObject: this._global
|
|
31
|
-
});
|
|
13
|
+
const val = parse(v);
|
|
32
14
|
if (typeof val === "string") {
|
|
33
15
|
const priority = this._priorities.get(property) ?? "";
|
|
34
16
|
this._setProperty(property, val, priority);
|
|
@@ -42,4 +24,26 @@ module.exports.definition = {
|
|
|
42
24
|
configurable: true
|
|
43
25
|
};
|
|
44
26
|
|
|
45
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Parses the color property value.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} v - The value to parse.
|
|
31
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
32
|
+
*/
|
|
33
|
+
function parse(v) {
|
|
34
|
+
if (v === "") {
|
|
35
|
+
return v;
|
|
36
|
+
}
|
|
37
|
+
const value = parsers.parsePropertyValue(property, v);
|
|
38
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
39
|
+
return parsers.resolveColorValue(value);
|
|
40
|
+
} else if (typeof value === "string") {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
descriptor,
|
|
47
|
+
parse,
|
|
48
|
+
property
|
|
49
|
+
};
|
|
@@ -2,22 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
+
// Constants
|
|
6
|
+
const { AST_TYPES } = parsers;
|
|
7
|
+
|
|
5
8
|
const property = "display";
|
|
6
9
|
|
|
7
10
|
/* keywords */
|
|
8
11
|
const displayOutside = ["block", "inline", "run-in"];
|
|
9
12
|
const displayFlow = ["flow", "flow-root"];
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
const descriptor = {
|
|
15
|
+
set(v) {
|
|
16
|
+
v = parsers.prepareValue(v);
|
|
17
|
+
if (parsers.hasVarFunc(v)) {
|
|
18
|
+
this._setProperty(property, v);
|
|
19
|
+
} else {
|
|
20
|
+
const val = parse(v);
|
|
21
|
+
if (typeof val === "string") {
|
|
22
|
+
const priority = this._priorities.get(property) ?? "";
|
|
23
|
+
this._setProperty(property, val, priority);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
get() {
|
|
28
|
+
return this.getPropertyValue(property);
|
|
29
|
+
},
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Parses the display property value.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} v - The value to parse.
|
|
38
|
+
* @returns {string|undefined} The parsed value or undefined if invalid.
|
|
39
|
+
*/
|
|
40
|
+
function parse(v) {
|
|
13
41
|
if (v === "") {
|
|
14
42
|
return v;
|
|
15
43
|
}
|
|
16
|
-
const
|
|
17
|
-
const value = parsers.parsePropertyValue(property, v, {
|
|
18
|
-
globalObject,
|
|
19
|
-
inArray: true
|
|
20
|
-
});
|
|
44
|
+
const value = parsers.parsePropertyValue(property, v);
|
|
21
45
|
if (Array.isArray(value) && value.length) {
|
|
22
46
|
switch (value.length) {
|
|
23
47
|
case 1: {
|
|
@@ -183,28 +207,10 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
183
207
|
} else if (typeof value === "string") {
|
|
184
208
|
return value;
|
|
185
209
|
}
|
|
186
|
-
}
|
|
210
|
+
}
|
|
187
211
|
|
|
188
|
-
module.exports
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
this._setProperty(property, v);
|
|
193
|
-
} else {
|
|
194
|
-
const val = module.exports.parse(v, {
|
|
195
|
-
globalObject: this._global
|
|
196
|
-
});
|
|
197
|
-
if (typeof val === "string") {
|
|
198
|
-
const priority = this._priorities.get(property) ?? "";
|
|
199
|
-
this._setProperty(property, val, priority);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
get() {
|
|
204
|
-
return this.getPropertyValue(property);
|
|
205
|
-
},
|
|
206
|
-
enumerable: true,
|
|
207
|
-
configurable: true
|
|
212
|
+
module.exports = {
|
|
213
|
+
descriptor,
|
|
214
|
+
parse,
|
|
215
|
+
property
|
|
208
216
|
};
|
|
209
|
-
|
|
210
|
-
module.exports.property = property;
|
package/lib/properties/flex.js
CHANGED
|
@@ -5,30 +5,67 @@ const flexGrow = require("./flexGrow");
|
|
|
5
5
|
const flexShrink = require("./flexShrink");
|
|
6
6
|
const flexBasis = require("./flexBasis");
|
|
7
7
|
|
|
8
|
+
// Constants
|
|
9
|
+
const { AST_TYPES } = parsers;
|
|
10
|
+
|
|
8
11
|
const property = "flex";
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
const initialValues = new Map([
|
|
11
14
|
[flexGrow.property, "0"],
|
|
12
15
|
[flexShrink.property, "1"],
|
|
13
16
|
[flexBasis.property, "auto"]
|
|
14
17
|
]);
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
const shorthandFor = new Map([
|
|
17
20
|
[flexGrow.property, flexGrow],
|
|
18
21
|
[flexShrink.property, flexShrink],
|
|
19
22
|
[flexBasis.property, flexBasis]
|
|
20
23
|
]);
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
const descriptor = {
|
|
26
|
+
set(v) {
|
|
27
|
+
v = parsers.prepareValue(v);
|
|
28
|
+
if (parsers.hasVarFunc(v)) {
|
|
29
|
+
for (const [longhand] of shorthandFor) {
|
|
30
|
+
this._setProperty(longhand, "");
|
|
31
|
+
}
|
|
32
|
+
this._setProperty(property, v);
|
|
33
|
+
} else {
|
|
34
|
+
const val = parse(v);
|
|
35
|
+
const priority = this._priorities.get(property) ?? "";
|
|
36
|
+
if (typeof val === "string") {
|
|
37
|
+
for (const [longhand] of shorthandFor) {
|
|
38
|
+
this._setProperty(longhand, val, priority);
|
|
39
|
+
}
|
|
40
|
+
this._setProperty(property, val, priority);
|
|
41
|
+
} else if (val) {
|
|
42
|
+
const values = [];
|
|
43
|
+
for (const [longhand, value] of Object.entries(val)) {
|
|
44
|
+
values.push(value);
|
|
45
|
+
this._setProperty(longhand, value, priority);
|
|
46
|
+
}
|
|
47
|
+
this._setProperty(property, values.join(" "), priority);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
get() {
|
|
52
|
+
return this.getPropertyValue(property);
|
|
53
|
+
},
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Parses the flex property value.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} v - The value to parse.
|
|
62
|
+
* @returns {object|string|undefined} The parsed value or undefined if invalid.
|
|
63
|
+
*/
|
|
64
|
+
function parse(v) {
|
|
24
65
|
if (v === "") {
|
|
25
66
|
return v;
|
|
26
67
|
}
|
|
27
|
-
const
|
|
28
|
-
const value = parsers.parsePropertyValue(property, v, {
|
|
29
|
-
globalObject,
|
|
30
|
-
inArray: true
|
|
31
|
-
});
|
|
68
|
+
const value = parsers.parsePropertyValue(property, v);
|
|
32
69
|
if (Array.isArray(value) && value.length) {
|
|
33
70
|
const flex = {
|
|
34
71
|
[flexGrow.property]: "1",
|
|
@@ -138,41 +175,12 @@ module.exports.parse = (v, opt = {}) => {
|
|
|
138
175
|
} else if (typeof value === "string") {
|
|
139
176
|
return value;
|
|
140
177
|
}
|
|
141
|
-
}
|
|
178
|
+
}
|
|
142
179
|
|
|
143
|
-
module.exports
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
this._setProperty(property, v);
|
|
151
|
-
} else {
|
|
152
|
-
const val = module.exports.parse(v, {
|
|
153
|
-
globalObject: this._global
|
|
154
|
-
});
|
|
155
|
-
const priority = this._priorities.get(property) ?? "";
|
|
156
|
-
if (typeof val === "string") {
|
|
157
|
-
for (const [longhand] of module.exports.shorthandFor) {
|
|
158
|
-
this._setProperty(longhand, val, priority);
|
|
159
|
-
}
|
|
160
|
-
this._setProperty(property, val, priority);
|
|
161
|
-
} else if (val) {
|
|
162
|
-
const values = [];
|
|
163
|
-
for (const [longhand, value] of Object.entries(val)) {
|
|
164
|
-
values.push(value);
|
|
165
|
-
this._setProperty(longhand, value, priority);
|
|
166
|
-
}
|
|
167
|
-
this._setProperty(property, values.join(" "), priority);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
get() {
|
|
172
|
-
return this.getPropertyValue(property);
|
|
173
|
-
},
|
|
174
|
-
enumerable: true,
|
|
175
|
-
configurable: true
|
|
180
|
+
module.exports = {
|
|
181
|
+
descriptor,
|
|
182
|
+
initialValues,
|
|
183
|
+
parse,
|
|
184
|
+
property,
|
|
185
|
+
shorthandFor
|
|
176
186
|
};
|
|
177
|
-
|
|
178
|
-
module.exports.property = property;
|
|
@@ -5,39 +5,17 @@ const parsers = require("../parsers");
|
|
|
5
5
|
const property = "flex-basis";
|
|
6
6
|
const shorthand = "flex";
|
|
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.resolveNumericValue(value, {
|
|
19
|
-
type: "length"
|
|
20
|
-
});
|
|
21
|
-
} else if (typeof value === "string") {
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
module.exports.definition = {
|
|
8
|
+
const descriptor = {
|
|
27
9
|
set(v) {
|
|
28
10
|
v = parsers.prepareValue(v);
|
|
29
11
|
if (parsers.hasVarFunc(v)) {
|
|
30
12
|
this._setProperty(shorthand, "");
|
|
31
13
|
this._setProperty(property, v);
|
|
32
14
|
} else {
|
|
33
|
-
const val =
|
|
34
|
-
globalObject: this._global
|
|
35
|
-
});
|
|
15
|
+
const val = parse(v);
|
|
36
16
|
if (typeof val === "string") {
|
|
37
17
|
const priority =
|
|
38
|
-
!this._priorities.get(shorthand) && this._priorities.has(property)
|
|
39
|
-
? this._priorities.get(property)
|
|
40
|
-
: "";
|
|
18
|
+
!this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
|
|
41
19
|
this._flexBoxSetter(property, val, priority, shorthand);
|
|
42
20
|
}
|
|
43
21
|
}
|
|
@@ -49,4 +27,28 @@ module.exports.definition = {
|
|
|
49
27
|
configurable: true
|
|
50
28
|
};
|
|
51
29
|
|
|
52
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Parses the flex-basis 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.resolveNumericValue(value, {
|
|
43
|
+
type: "length"
|
|
44
|
+
});
|
|
45
|
+
} else if (typeof value === "string") {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
descriptor,
|
|
52
|
+
parse,
|
|
53
|
+
property
|
|
54
|
+
};
|
|
@@ -5,39 +5,17 @@ const parsers = require("../parsers");
|
|
|
5
5
|
const property = "flex-grow";
|
|
6
6
|
const shorthand = "flex";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const { globalObject } = opt;
|
|
10
|
-
if (v === "") {
|
|
11
|
-
return v;
|
|
12
|
-
}
|
|
13
|
-
const value = parsers.parsePropertyValue("flex-grow", v, {
|
|
14
|
-
globalObject,
|
|
15
|
-
inArray: true
|
|
16
|
-
});
|
|
17
|
-
if (Array.isArray(value) && value.length === 1) {
|
|
18
|
-
return parsers.resolveNumericValue(value, {
|
|
19
|
-
min: 0
|
|
20
|
-
});
|
|
21
|
-
} else if (typeof value === "string") {
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
module.exports.definition = {
|
|
8
|
+
const descriptor = {
|
|
27
9
|
set(v) {
|
|
28
10
|
v = parsers.prepareValue(v);
|
|
29
11
|
if (parsers.hasVarFunc(v)) {
|
|
30
12
|
this._setProperty(shorthand, "");
|
|
31
13
|
this._setProperty(property, v);
|
|
32
14
|
} else {
|
|
33
|
-
const val =
|
|
34
|
-
globalObject: this._global
|
|
35
|
-
});
|
|
15
|
+
const val = parse(v);
|
|
36
16
|
if (typeof val === "string") {
|
|
37
17
|
const priority =
|
|
38
|
-
!this._priorities.get(shorthand) && this._priorities.has(property)
|
|
39
|
-
? this._priorities.get(property)
|
|
40
|
-
: "";
|
|
18
|
+
!this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
|
|
41
19
|
this._flexBoxSetter(property, val, priority, shorthand);
|
|
42
20
|
}
|
|
43
21
|
}
|
|
@@ -49,4 +27,28 @@ module.exports.definition = {
|
|
|
49
27
|
configurable: true
|
|
50
28
|
};
|
|
51
29
|
|
|
52
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Parses the flex-grow 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("flex-grow", v);
|
|
41
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
42
|
+
return parsers.resolveNumericValue(value, {
|
|
43
|
+
min: 0
|
|
44
|
+
});
|
|
45
|
+
} else if (typeof value === "string") {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
descriptor,
|
|
52
|
+
parse,
|
|
53
|
+
property
|
|
54
|
+
};
|