cssstyle 5.2.0 → 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,93 +2,92 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const property = "font-family";
|
|
6
|
+
const shorthand = "font";
|
|
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
|
|
10
|
-
"serif",
|
|
11
|
-
"sans-serif",
|
|
12
|
-
"cursive",
|
|
13
|
-
"fantasy",
|
|
14
|
-
"monospace",
|
|
15
|
-
"system-ui",
|
|
16
|
-
"math",
|
|
17
|
-
"ui-serif",
|
|
18
|
-
"ui-sans-serif",
|
|
19
|
-
"ui-monospace",
|
|
20
|
-
"ui-rounded"
|
|
21
|
-
];
|
|
22
|
-
const genericValues = ["fangsong", "kai", "khmer-mul", "nastaliq"];
|
|
23
|
-
const val = parsers.splitValue(v, {
|
|
13
|
+
const values = parsers.splitValue(v, {
|
|
24
14
|
delimiter: ","
|
|
25
15
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
16
|
+
const parsedValues = [];
|
|
17
|
+
for (const val of values) {
|
|
18
|
+
const value = parsers.parsePropertyValue(property, val, {
|
|
19
|
+
globalObject,
|
|
20
|
+
caseSensitive: true,
|
|
21
|
+
inArray: true
|
|
22
|
+
});
|
|
23
|
+
if (Array.isArray(value) && value.length) {
|
|
24
|
+
if (value.length === 1) {
|
|
25
|
+
const [{ name, type, value: itemValue }] = value;
|
|
26
|
+
switch (type) {
|
|
27
|
+
case "Function": {
|
|
28
|
+
parsedValues.push(`${name}(${itemValue})`);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case "GlobalKeyword":
|
|
32
|
+
case "Identifier": {
|
|
33
|
+
if (name !== "undefined") {
|
|
34
|
+
parsedValues.push(name);
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "String": {
|
|
39
|
+
const parsedValue = itemValue.replaceAll("\\", "").replaceAll('"', '\\"');
|
|
40
|
+
parsedValues.push(`"${parsedValue}"`);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
default: {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
const parts = [];
|
|
49
|
+
for (const item of value) {
|
|
50
|
+
const { name, type } = item;
|
|
51
|
+
if (type === "Identifier") {
|
|
52
|
+
parts.push(name);
|
|
53
|
+
} else {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const parsedValue = parts.join(" ").replaceAll("\\", "").replaceAll('"', '\\"');
|
|
58
|
+
parsedValues.push(`"${parsedValue}"`);
|
|
48
59
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// capitalized, and unquoted font-family names are not restricted to ASCII.
|
|
53
|
-
// However, in the real world, the first letter of the ASCII font-family
|
|
54
|
-
// names are capitalized, and unquoted font-family names do not contain
|
|
55
|
-
// spaces, e.g. `Times`. And non-ASCII font-family names are quoted even
|
|
56
|
-
// without spaces, e.g. `"メイリオ"`.
|
|
57
|
-
// @see https://drafts.csswg.org/css-fonts/#font-family-prop
|
|
58
|
-
if (
|
|
59
|
-
i !== "undefined" &&
|
|
60
|
-
/^(?:[A-Z][A-Za-z\d-]+(?:\s+[A-Z][A-Za-z\d-]+)*|-?[a-z][a-z-]+)$/.test(i)
|
|
61
|
-
) {
|
|
62
|
-
font.push(i.trim());
|
|
63
|
-
valid = true;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (!valid) {
|
|
60
|
+
} else if (typeof value === "string") {
|
|
61
|
+
parsedValues.push(value);
|
|
62
|
+
} else {
|
|
67
63
|
return;
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
module.exports.isValid = function isValid(v) {
|
|
74
|
-
if (v === "") {
|
|
75
|
-
return true;
|
|
66
|
+
if (parsedValues.length) {
|
|
67
|
+
return parsedValues.join(", ");
|
|
76
68
|
}
|
|
77
|
-
return typeof module.exports.parse(v) === "string";
|
|
78
69
|
};
|
|
79
70
|
|
|
80
71
|
module.exports.definition = {
|
|
81
72
|
set(v) {
|
|
82
73
|
v = parsers.prepareValue(v, this._global);
|
|
83
74
|
if (parsers.hasVarFunc(v)) {
|
|
84
|
-
this._setProperty(
|
|
85
|
-
this._setProperty(
|
|
75
|
+
this._setProperty(shorthand, "");
|
|
76
|
+
this._setProperty(property, v);
|
|
86
77
|
} else {
|
|
87
|
-
|
|
78
|
+
const val = module.exports.parse(v, {
|
|
79
|
+
globalObject: this._global
|
|
80
|
+
});
|
|
81
|
+
if (typeof val === "string") {
|
|
82
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
83
|
+
const prior = this._priorities.get(property) ?? "";
|
|
84
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
85
|
+
this._setProperty(property, val, priority);
|
|
86
|
+
}
|
|
88
87
|
}
|
|
89
88
|
},
|
|
90
89
|
get() {
|
|
91
|
-
return this.getPropertyValue(
|
|
90
|
+
return this.getPropertyValue(property);
|
|
92
91
|
},
|
|
93
92
|
enumerable: true,
|
|
94
93
|
configurable: true
|
|
@@ -2,45 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (val) {
|
|
8
|
-
return val;
|
|
9
|
-
}
|
|
10
|
-
const keywords = [
|
|
11
|
-
"xx-small",
|
|
12
|
-
"x-small",
|
|
13
|
-
"small",
|
|
14
|
-
"medium",
|
|
15
|
-
"large",
|
|
16
|
-
"x-large",
|
|
17
|
-
"xx-large",
|
|
18
|
-
"xxx-large",
|
|
19
|
-
"smaller",
|
|
20
|
-
"larger"
|
|
21
|
-
];
|
|
22
|
-
return parsers.parseKeyword(v, keywords);
|
|
23
|
-
};
|
|
5
|
+
const property = "font-size";
|
|
6
|
+
const shorthand = "font";
|
|
24
7
|
|
|
25
|
-
module.exports.
|
|
8
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
9
|
+
const { globalObject } = opt;
|
|
26
10
|
if (v === "") {
|
|
27
|
-
return
|
|
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
|
+
const [{ isNumber, name, type, value: itemValue }] = value;
|
|
19
|
+
switch (type) {
|
|
20
|
+
case "Calc": {
|
|
21
|
+
if (isNumber) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
return `${name}(${itemValue})`;
|
|
25
|
+
}
|
|
26
|
+
case "GlobalKeyword":
|
|
27
|
+
case "Identifier": {
|
|
28
|
+
return name;
|
|
29
|
+
}
|
|
30
|
+
default: {
|
|
31
|
+
return parsers.parseLengthPercentage(value, {
|
|
32
|
+
min: 0
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} else if (typeof value === "string") {
|
|
37
|
+
return value;
|
|
28
38
|
}
|
|
29
|
-
return typeof module.exports.parse(v) === "string";
|
|
30
39
|
};
|
|
31
40
|
|
|
32
41
|
module.exports.definition = {
|
|
33
42
|
set(v) {
|
|
34
43
|
v = parsers.prepareValue(v, this._global);
|
|
35
44
|
if (parsers.hasVarFunc(v)) {
|
|
36
|
-
this._setProperty(
|
|
37
|
-
this._setProperty(
|
|
45
|
+
this._setProperty(shorthand, "");
|
|
46
|
+
this._setProperty(property, v);
|
|
38
47
|
} else {
|
|
39
|
-
|
|
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
|
+
}
|
|
40
57
|
}
|
|
41
58
|
},
|
|
42
59
|
get() {
|
|
43
|
-
return this.getPropertyValue(
|
|
60
|
+
return this.getPropertyValue(property);
|
|
44
61
|
},
|
|
45
62
|
enumerable: true,
|
|
46
63
|
configurable: true
|
|
@@ -2,30 +2,61 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return parsers.parseKeyword(v, keywords);
|
|
8
|
-
};
|
|
5
|
+
const property = "font-style";
|
|
6
|
+
const shorthand = "font";
|
|
9
7
|
|
|
10
|
-
module.exports.
|
|
8
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
9
|
+
const { globalObject } = opt;
|
|
11
10
|
if (v === "") {
|
|
12
|
-
return
|
|
11
|
+
return v;
|
|
12
|
+
}
|
|
13
|
+
const value = parsers.parsePropertyValue(property, v, {
|
|
14
|
+
globalObject,
|
|
15
|
+
inArray: true
|
|
16
|
+
});
|
|
17
|
+
if (Array.isArray(value) && value.length) {
|
|
18
|
+
if (value.length === 1) {
|
|
19
|
+
const [{ name, type }] = value;
|
|
20
|
+
switch (type) {
|
|
21
|
+
case "GlobalKeyword":
|
|
22
|
+
case "Identifier": {
|
|
23
|
+
return name;
|
|
24
|
+
}
|
|
25
|
+
default:
|
|
26
|
+
}
|
|
27
|
+
} else if (value.length === 2) {
|
|
28
|
+
const [part1, part2] = value;
|
|
29
|
+
const val1 = part1.type === "Identifier" && part1.name;
|
|
30
|
+
const val2 = parsers.parseAngle([part2]);
|
|
31
|
+
if (val1 && val1 === "oblique" && val2) {
|
|
32
|
+
return `${val1} ${val2}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
} else if (typeof value === "string") {
|
|
36
|
+
return value;
|
|
13
37
|
}
|
|
14
|
-
return typeof module.exports.parse(v) === "string";
|
|
15
38
|
};
|
|
16
39
|
|
|
17
40
|
module.exports.definition = {
|
|
18
41
|
set(v) {
|
|
19
42
|
v = parsers.prepareValue(v, this._global);
|
|
20
43
|
if (parsers.hasVarFunc(v)) {
|
|
21
|
-
this._setProperty(
|
|
22
|
-
this._setProperty(
|
|
44
|
+
this._setProperty(shorthand, "");
|
|
45
|
+
this._setProperty(property, v);
|
|
23
46
|
} else {
|
|
24
|
-
|
|
47
|
+
const val = module.exports.parse(v, {
|
|
48
|
+
globalObject: this._global
|
|
49
|
+
});
|
|
50
|
+
if (typeof val === "string") {
|
|
51
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
52
|
+
const prior = this._priorities.get(property) ?? "";
|
|
53
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
54
|
+
this._setProperty(property, val, priority);
|
|
55
|
+
}
|
|
25
56
|
}
|
|
26
57
|
},
|
|
27
58
|
get() {
|
|
28
|
-
return this.getPropertyValue(
|
|
59
|
+
return this.getPropertyValue(property);
|
|
29
60
|
},
|
|
30
61
|
enumerable: true,
|
|
31
62
|
configurable: true
|
|
@@ -2,34 +2,71 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (num && parseFloat(num) <= 1000) {
|
|
8
|
-
return num;
|
|
9
|
-
}
|
|
10
|
-
const keywords = ["normal", "none", "small-caps"];
|
|
11
|
-
return parsers.parseKeyword(v, keywords);
|
|
12
|
-
};
|
|
5
|
+
const property = "font-variant";
|
|
6
|
+
const shorthand = "font";
|
|
13
7
|
|
|
14
|
-
module.exports.
|
|
8
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
9
|
+
const { globalObject } = opt;
|
|
15
10
|
if (v === "") {
|
|
16
|
-
return
|
|
11
|
+
return v;
|
|
12
|
+
}
|
|
13
|
+
const values = parsers.splitValue(v);
|
|
14
|
+
const parsedValues = [];
|
|
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: itemValue }] = value;
|
|
22
|
+
switch (type) {
|
|
23
|
+
case "Function": {
|
|
24
|
+
parsedValues.push(`${name}(${itemValue})`);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
case "GlobalKeyword":
|
|
28
|
+
case "Identifier": {
|
|
29
|
+
parsedValues.push(name);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
default: {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} else if (typeof value === "string") {
|
|
37
|
+
parsedValues.push(value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (parsedValues.length) {
|
|
41
|
+
if (parsedValues.length > 1) {
|
|
42
|
+
if (parsedValues.includes("normal") || parsedValues.includes("none")) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return parsedValues.join(" ");
|
|
17
47
|
}
|
|
18
|
-
return typeof module.exports.parse(v) === "string";
|
|
19
48
|
};
|
|
20
49
|
|
|
21
50
|
module.exports.definition = {
|
|
22
51
|
set(v) {
|
|
23
52
|
v = parsers.prepareValue(v, this._global);
|
|
24
53
|
if (parsers.hasVarFunc(v)) {
|
|
25
|
-
this._setProperty(
|
|
26
|
-
this._setProperty(
|
|
54
|
+
this._setProperty(shorthand, "");
|
|
55
|
+
this._setProperty(property, v);
|
|
27
56
|
} else {
|
|
28
|
-
|
|
57
|
+
const val = module.exports.parse(v, {
|
|
58
|
+
globalObject: this._global
|
|
59
|
+
});
|
|
60
|
+
if (typeof val === "string") {
|
|
61
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
62
|
+
const prior = this._priorities.get(property) ?? "";
|
|
63
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
64
|
+
this._setProperty(property, val, priority);
|
|
65
|
+
}
|
|
29
66
|
}
|
|
30
67
|
},
|
|
31
68
|
get() {
|
|
32
|
-
return this.getPropertyValue(
|
|
69
|
+
return this.getPropertyValue(property);
|
|
33
70
|
},
|
|
34
71
|
enumerable: true,
|
|
35
72
|
configurable: true
|
|
@@ -2,34 +2,66 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (num && parseFloat(num) <= 1000) {
|
|
8
|
-
return num;
|
|
9
|
-
}
|
|
10
|
-
const keywords = ["normal", "bold", "lighter", "bolder"];
|
|
11
|
-
return parsers.parseKeyword(v, keywords);
|
|
12
|
-
};
|
|
5
|
+
const property = "font-weight";
|
|
6
|
+
const shorthand = "font";
|
|
13
7
|
|
|
14
|
-
module.exports.
|
|
8
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
9
|
+
const { globalObject } = opt;
|
|
15
10
|
if (v === "") {
|
|
16
|
-
return
|
|
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
|
+
const [{ isNumber, name, type, value: itemValue }] = value;
|
|
19
|
+
switch (type) {
|
|
20
|
+
case "Calc": {
|
|
21
|
+
if (isNumber) {
|
|
22
|
+
return `${name}(${itemValue})`;
|
|
23
|
+
}
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case "GlobalKeyword":
|
|
27
|
+
case "Identifier": {
|
|
28
|
+
return name;
|
|
29
|
+
}
|
|
30
|
+
default: {
|
|
31
|
+
const parsedValue = parsers.parseNumber(value, {
|
|
32
|
+
min: 1,
|
|
33
|
+
max: 1000
|
|
34
|
+
});
|
|
35
|
+
if (parsedValue) {
|
|
36
|
+
return parsedValue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else if (typeof value === "string") {
|
|
41
|
+
return value;
|
|
17
42
|
}
|
|
18
|
-
return typeof module.exports.parse(v) === "string";
|
|
19
43
|
};
|
|
20
44
|
|
|
21
45
|
module.exports.definition = {
|
|
22
46
|
set(v) {
|
|
23
47
|
v = parsers.prepareValue(v, this._global);
|
|
24
48
|
if (parsers.hasVarFunc(v)) {
|
|
25
|
-
this._setProperty(
|
|
26
|
-
this._setProperty(
|
|
49
|
+
this._setProperty(shorthand, "");
|
|
50
|
+
this._setProperty(property, v);
|
|
27
51
|
} else {
|
|
28
|
-
|
|
52
|
+
const val = module.exports.parse(v, {
|
|
53
|
+
globalObject: this._global
|
|
54
|
+
});
|
|
55
|
+
if (typeof val === "string") {
|
|
56
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
57
|
+
const prior = this._priorities.get(property) ?? "";
|
|
58
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
59
|
+
this._setProperty(property, val, priority);
|
|
60
|
+
}
|
|
29
61
|
}
|
|
30
62
|
},
|
|
31
63
|
get() {
|
|
32
|
-
return this.getPropertyValue(
|
|
64
|
+
return this.getPropertyValue(property);
|
|
33
65
|
},
|
|
34
66
|
enumerable: true,
|
|
35
67
|
configurable: true
|
package/lib/properties/height.js
CHANGED
|
@@ -2,29 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const dim = parsers.parseMeasurement(v, true);
|
|
7
|
-
if (dim) {
|
|
8
|
-
return dim;
|
|
9
|
-
}
|
|
10
|
-
const keywords = ["auto", "min-content", "max-content", "fit-content"];
|
|
11
|
-
return parsers.parseKeyword(v, keywords);
|
|
12
|
-
};
|
|
5
|
+
const property = "height";
|
|
13
6
|
|
|
14
|
-
module.exports.
|
|
7
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
8
|
+
const { globalObject } = opt;
|
|
15
9
|
if (v === "") {
|
|
16
|
-
return
|
|
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
|
+
const [{ isNumber, name, type, value: itemValue }] = value;
|
|
18
|
+
switch (type) {
|
|
19
|
+
case "Calc": {
|
|
20
|
+
if (isNumber) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return `${name}(${itemValue})`;
|
|
24
|
+
}
|
|
25
|
+
case "GlobalKeyword":
|
|
26
|
+
case "Identifier": {
|
|
27
|
+
return name;
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
return parsers.parseLengthPercentage(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} else if (typeof value === "string") {
|
|
34
|
+
return value;
|
|
17
35
|
}
|
|
18
|
-
return typeof module.exports.parse(v) === "string";
|
|
19
36
|
};
|
|
20
37
|
|
|
21
38
|
module.exports.definition = {
|
|
22
39
|
set(v) {
|
|
23
40
|
v = parsers.prepareValue(v, this._global);
|
|
24
|
-
|
|
41
|
+
if (parsers.hasVarFunc(v)) {
|
|
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 = this._priorities.get(property) ?? "";
|
|
49
|
+
this._setProperty(property, val, priority);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
25
52
|
},
|
|
26
53
|
get() {
|
|
27
|
-
return this.getPropertyValue(
|
|
54
|
+
return this.getPropertyValue(property);
|
|
28
55
|
},
|
|
29
56
|
enumerable: true,
|
|
30
57
|
configurable: true
|
package/lib/properties/left.js
CHANGED
|
@@ -2,28 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const dim = parsers.parseMeasurement(v);
|
|
7
|
-
if (dim) {
|
|
8
|
-
return dim;
|
|
9
|
-
}
|
|
10
|
-
return parsers.parseKeyword(v, ["auto"]);
|
|
11
|
-
};
|
|
5
|
+
const property = "left";
|
|
12
6
|
|
|
13
|
-
module.exports.
|
|
7
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
8
|
+
const { globalObject } = opt;
|
|
14
9
|
if (v === "") {
|
|
15
|
-
return
|
|
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
|
+
const [{ isNumber, name, type, value: itemValue }] = value;
|
|
18
|
+
switch (type) {
|
|
19
|
+
case "Calc": {
|
|
20
|
+
if (isNumber) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return `${name}(${itemValue})`;
|
|
24
|
+
}
|
|
25
|
+
case "GlobalKeyword":
|
|
26
|
+
case "Identifier": {
|
|
27
|
+
return name;
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
return parsers.parseLengthPercentage(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} else if (typeof value === "string") {
|
|
34
|
+
return value;
|
|
16
35
|
}
|
|
17
|
-
return typeof module.exports.parse(v) === "string";
|
|
18
36
|
};
|
|
19
37
|
|
|
20
38
|
module.exports.definition = {
|
|
21
39
|
set(v) {
|
|
22
40
|
v = parsers.prepareValue(v, this._global);
|
|
23
|
-
|
|
41
|
+
if (parsers.hasVarFunc(v)) {
|
|
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 = this._priorities.get(property) ?? "";
|
|
49
|
+
this._setProperty(property, val, priority);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
24
52
|
},
|
|
25
53
|
get() {
|
|
26
|
-
return this.getPropertyValue(
|
|
54
|
+
return this.getPropertyValue(property);
|
|
27
55
|
},
|
|
28
56
|
enumerable: true,
|
|
29
57
|
configurable: true
|
|
@@ -2,28 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const val = parsers.parseColor(v);
|
|
7
|
-
if (val) {
|
|
8
|
-
return val;
|
|
9
|
-
}
|
|
10
|
-
return parsers.parseKeyword(v);
|
|
11
|
-
};
|
|
5
|
+
const property = "lighting-color";
|
|
12
6
|
|
|
13
|
-
module.exports.
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
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
|
+
const [{ name, type }] = value;
|
|
18
|
+
switch (type) {
|
|
19
|
+
case "GlobalKeyword": {
|
|
20
|
+
return name;
|
|
21
|
+
}
|
|
22
|
+
default: {
|
|
23
|
+
return parsers.parseColor(value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
} else if (typeof value === "string") {
|
|
27
|
+
return value;
|
|
16
28
|
}
|
|
17
|
-
return parsers.isValidColor(v);
|
|
18
29
|
};
|
|
19
30
|
|
|
20
31
|
module.exports.definition = {
|
|
21
32
|
set(v) {
|
|
22
33
|
v = parsers.prepareValue(v, this._global);
|
|
23
|
-
|
|
34
|
+
if (parsers.hasVarFunc(v)) {
|
|
35
|
+
this._setProperty(property, v);
|
|
36
|
+
} else {
|
|
37
|
+
const val = module.exports.parse(v, {
|
|
38
|
+
globalObject: this._global
|
|
39
|
+
});
|
|
40
|
+
if (typeof val === "string") {
|
|
41
|
+
const priority = this._priorities.get(property) ?? "";
|
|
42
|
+
this._setProperty(property, val, priority);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
24
45
|
},
|
|
25
46
|
get() {
|
|
26
|
-
return this.getPropertyValue(
|
|
47
|
+
return this.getPropertyValue(property);
|
|
27
48
|
},
|
|
28
49
|
enumerable: true,
|
|
29
50
|
configurable: true
|