cssstyle 5.2.1 → 5.3.1
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 +5258 -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 +141 -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,26 +2,59 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
5
|
+
const property = "flex-grow";
|
|
6
|
+
const shorthand = "flex";
|
|
8
7
|
|
|
9
|
-
module.exports.
|
|
10
|
-
|
|
8
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
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
|
+
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
|
+
return name;
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
return parsers.parseNumber(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} else if (typeof value === "string") {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
11
36
|
};
|
|
12
37
|
|
|
13
38
|
module.exports.definition = {
|
|
14
39
|
set(v) {
|
|
15
40
|
v = parsers.prepareValue(v, this._global);
|
|
16
41
|
if (parsers.hasVarFunc(v)) {
|
|
17
|
-
this._setProperty(
|
|
18
|
-
this._setProperty(
|
|
42
|
+
this._setProperty(shorthand, "");
|
|
43
|
+
this._setProperty(property, v);
|
|
19
44
|
} else {
|
|
20
|
-
|
|
45
|
+
const val = module.exports.parse(v, {
|
|
46
|
+
globalObject: this._global
|
|
47
|
+
});
|
|
48
|
+
if (typeof val === "string") {
|
|
49
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
50
|
+
const prior = this._priorities.get(property) ?? "";
|
|
51
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
52
|
+
this._flexBoxSetter(property, val, priority, shorthand);
|
|
53
|
+
}
|
|
21
54
|
}
|
|
22
55
|
},
|
|
23
56
|
get() {
|
|
24
|
-
return this.getPropertyValue(
|
|
57
|
+
return this.getPropertyValue(property);
|
|
25
58
|
},
|
|
26
59
|
enumerable: true,
|
|
27
60
|
configurable: true
|
|
@@ -2,26 +2,59 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
5
|
+
const property = "flex-shrink";
|
|
6
|
+
const shorthand = "flex";
|
|
8
7
|
|
|
9
|
-
module.exports.
|
|
10
|
-
|
|
8
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
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
|
+
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
|
+
return name;
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
return parsers.parseNumber(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} else if (typeof value === "string") {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
11
36
|
};
|
|
12
37
|
|
|
13
38
|
module.exports.definition = {
|
|
14
39
|
set(v) {
|
|
15
40
|
v = parsers.prepareValue(v, this._global);
|
|
16
41
|
if (parsers.hasVarFunc(v)) {
|
|
17
|
-
this._setProperty(
|
|
18
|
-
this._setProperty(
|
|
42
|
+
this._setProperty(shorthand, "");
|
|
43
|
+
this._setProperty(property, v);
|
|
19
44
|
} else {
|
|
20
|
-
|
|
45
|
+
const val = module.exports.parse(v, {
|
|
46
|
+
globalObject: this._global
|
|
47
|
+
});
|
|
48
|
+
if (typeof val === "string") {
|
|
49
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
50
|
+
const prior = this._priorities.get(property) ?? "";
|
|
51
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
52
|
+
this._flexBoxSetter(property, val, priority, shorthand);
|
|
53
|
+
}
|
|
21
54
|
}
|
|
22
55
|
},
|
|
23
56
|
get() {
|
|
24
|
-
return this.getPropertyValue(
|
|
57
|
+
return this.getPropertyValue(property);
|
|
25
58
|
},
|
|
26
59
|
enumerable: true,
|
|
27
60
|
configurable: true
|
package/lib/properties/float.js
CHANGED
|
@@ -2,25 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const keywords = ["left", "right", "none", "inline-start", "inline-end"];
|
|
7
|
-
return parsers.parseKeyword(v, keywords);
|
|
8
|
-
};
|
|
5
|
+
const property = "float";
|
|
9
6
|
|
|
10
|
-
module.exports.
|
|
7
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
8
|
+
const { globalObject } = opt;
|
|
11
9
|
if (v === "") {
|
|
12
|
-
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 [{ name, type }] = value;
|
|
18
|
+
switch (type) {
|
|
19
|
+
case "GlobalKeyword":
|
|
20
|
+
case "Identifier": {
|
|
21
|
+
return name;
|
|
22
|
+
}
|
|
23
|
+
default:
|
|
24
|
+
}
|
|
25
|
+
} else if (typeof value === "string") {
|
|
26
|
+
return value;
|
|
13
27
|
}
|
|
14
|
-
return typeof module.exports.parse(v) === "string";
|
|
15
28
|
};
|
|
16
29
|
|
|
17
30
|
module.exports.definition = {
|
|
18
31
|
set(v) {
|
|
19
32
|
v = parsers.prepareValue(v, this._global);
|
|
20
|
-
|
|
33
|
+
if (parsers.hasVarFunc(v)) {
|
|
34
|
+
this._setProperty(property, v);
|
|
35
|
+
} else {
|
|
36
|
+
const val = module.exports.parse(v, {
|
|
37
|
+
globalObject: this._global
|
|
38
|
+
});
|
|
39
|
+
if (typeof val === "string") {
|
|
40
|
+
const priority = this._priorities.get(property) ?? "";
|
|
41
|
+
this._setProperty(property, val, priority);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
21
44
|
},
|
|
22
45
|
get() {
|
|
23
|
-
return this.getPropertyValue(
|
|
46
|
+
return this.getPropertyValue(property);
|
|
24
47
|
},
|
|
25
48
|
enumerable: true,
|
|
26
49
|
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 = "flood-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
|
package/lib/properties/font.js
CHANGED
|
@@ -8,6 +8,8 @@ const fontSize = require("./fontSize");
|
|
|
8
8
|
const lineHeight = require("./lineHeight");
|
|
9
9
|
const fontFamily = require("./fontFamily");
|
|
10
10
|
|
|
11
|
+
const property = "font";
|
|
12
|
+
|
|
11
13
|
module.exports.shorthandFor = new Map([
|
|
12
14
|
["font-style", fontStyle],
|
|
13
15
|
["font-variant", fontVariant],
|
|
@@ -17,11 +19,15 @@ module.exports.shorthandFor = new Map([
|
|
|
17
19
|
["font-family", fontFamily]
|
|
18
20
|
]);
|
|
19
21
|
|
|
20
|
-
module.exports.parse = function parse(v) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
23
|
+
const { globalObject } = opt;
|
|
24
|
+
if (v === "") {
|
|
25
|
+
return v;
|
|
26
|
+
} else if (parsers.hasCalcFunc(v)) {
|
|
27
|
+
v = parsers.resolveCalc(v);
|
|
28
|
+
}
|
|
29
|
+
if (!parsers.isValidPropertyValue(property, v)) {
|
|
30
|
+
return;
|
|
25
31
|
}
|
|
26
32
|
const [fontBlock, ...families] = parsers.splitValue(v, {
|
|
27
33
|
delimiter: ","
|
|
@@ -37,13 +43,21 @@ module.exports.parse = function parse(v) {
|
|
|
37
43
|
const fontFamilies = new Set();
|
|
38
44
|
if (fontBlockB) {
|
|
39
45
|
const [lineB, ...familiesB] = fontBlockB.trim().split(" ");
|
|
40
|
-
if (!lineB || !
|
|
46
|
+
if (!lineB || !familiesB.length) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const lineHeightB = lineHeight.parse(lineB, {
|
|
50
|
+
global
|
|
51
|
+
});
|
|
52
|
+
if (typeof lineHeightB !== "string") {
|
|
41
53
|
return;
|
|
42
54
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
const familyB = fontFamily.parse(familiesB.join(" "), {
|
|
56
|
+
globalObject,
|
|
57
|
+
caseSensitive: true
|
|
58
|
+
});
|
|
59
|
+
if (typeof familyB === "string") {
|
|
60
|
+
fontFamilies.add(familyB);
|
|
47
61
|
} else {
|
|
48
62
|
return;
|
|
49
63
|
}
|
|
@@ -53,15 +67,42 @@ module.exports.parse = function parse(v) {
|
|
|
53
67
|
if (part === "normal") {
|
|
54
68
|
continue;
|
|
55
69
|
} else {
|
|
56
|
-
for (const
|
|
57
|
-
switch (
|
|
58
|
-
case "font-style":
|
|
59
|
-
case "font-variant":
|
|
60
|
-
case "font-weight":
|
|
70
|
+
for (const longhand of properties) {
|
|
71
|
+
switch (longhand) {
|
|
61
72
|
case "font-size": {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
const parsedValue = fontSize.parse(part, {
|
|
74
|
+
globalObject
|
|
75
|
+
});
|
|
76
|
+
if (typeof parsedValue === "string") {
|
|
77
|
+
font[longhand] = parsedValue;
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case "font-style":
|
|
82
|
+
case "font-weight": {
|
|
83
|
+
if (font[longhand] === "normal") {
|
|
84
|
+
const longhandItem = module.exports.shorthandFor.get(longhand);
|
|
85
|
+
const parsedValue = longhandItem.parse(part, {
|
|
86
|
+
globalObject
|
|
87
|
+
});
|
|
88
|
+
if (typeof parsedValue === "string") {
|
|
89
|
+
font[longhand] = parsedValue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case "font-variant": {
|
|
95
|
+
if (font[longhand] === "normal") {
|
|
96
|
+
const parsedValue = fontVariant.parse(part, {
|
|
97
|
+
globalObject
|
|
98
|
+
});
|
|
99
|
+
if (typeof parsedValue === "string") {
|
|
100
|
+
if (parsedValue === "small-cap") {
|
|
101
|
+
font[longhand] = parsedValue;
|
|
102
|
+
} else if (parsedValue !== "normal") {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
65
106
|
}
|
|
66
107
|
break;
|
|
67
108
|
}
|
|
@@ -77,27 +118,66 @@ module.exports.parse = function parse(v) {
|
|
|
77
118
|
}
|
|
78
119
|
} else {
|
|
79
120
|
const revParts = parsers.splitValue(fontBlockA.trim()).toReversed();
|
|
80
|
-
|
|
121
|
+
if (revParts.length === 1) {
|
|
122
|
+
const [part] = revParts;
|
|
123
|
+
const value = parsers.parsePropertyValue(property, part, {
|
|
124
|
+
globalObject,
|
|
125
|
+
inArray: true
|
|
126
|
+
});
|
|
127
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
128
|
+
const [{ name, type }] = value;
|
|
129
|
+
if (type === "GlobalKeyword") {
|
|
130
|
+
return {
|
|
131
|
+
"font-style": name,
|
|
132
|
+
"font-variant": name,
|
|
133
|
+
"font-weight": name,
|
|
134
|
+
"font-size": name,
|
|
135
|
+
"line-height": name,
|
|
136
|
+
"font-family": name
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
81
142
|
const properties = ["font-style", "font-variant", "font-weight", "line-height"];
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
143
|
+
for (const longhand of properties) {
|
|
144
|
+
font[longhand] = "normal";
|
|
145
|
+
}
|
|
146
|
+
const revFontFamily = [];
|
|
86
147
|
let fontSizeA;
|
|
87
148
|
for (const part of revParts) {
|
|
88
149
|
if (fontSizeA) {
|
|
89
|
-
if (part
|
|
150
|
+
if (/^normal$/i.test(part)) {
|
|
90
151
|
continue;
|
|
91
152
|
} else {
|
|
92
|
-
for (const
|
|
93
|
-
switch (
|
|
153
|
+
for (const longhand of properties) {
|
|
154
|
+
switch (longhand) {
|
|
94
155
|
case "font-style":
|
|
95
|
-
case "font-variant":
|
|
96
156
|
case "font-weight":
|
|
97
157
|
case "line-height": {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
158
|
+
if (font[longhand] === "normal") {
|
|
159
|
+
const longhandItem = module.exports.shorthandFor.get(longhand);
|
|
160
|
+
const parsedValue = longhandItem.parse(part, {
|
|
161
|
+
globalObject
|
|
162
|
+
});
|
|
163
|
+
if (typeof parsedValue === "string") {
|
|
164
|
+
font[longhand] = parsedValue;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case "font-variant": {
|
|
170
|
+
if (font[longhand] === "normal") {
|
|
171
|
+
const parsedValue = fontVariant.parse(part, {
|
|
172
|
+
globalObject
|
|
173
|
+
});
|
|
174
|
+
if (typeof parsedValue === "string") {
|
|
175
|
+
if (parsedValue === "small-cap") {
|
|
176
|
+
font[longhand] = parsedValue;
|
|
177
|
+
} else if (parsedValue !== "normal") {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
101
181
|
}
|
|
102
182
|
break;
|
|
103
183
|
}
|
|
@@ -105,16 +185,30 @@ module.exports.parse = function parse(v) {
|
|
|
105
185
|
}
|
|
106
186
|
}
|
|
107
187
|
}
|
|
108
|
-
} else if (fontSize.isValid(part)) {
|
|
109
|
-
fontSizeA = fontSize.parse(part);
|
|
110
|
-
} else if (fontFamily.isValid(part)) {
|
|
111
|
-
revFontFamily.push(part);
|
|
112
188
|
} else {
|
|
113
|
-
|
|
189
|
+
const parsedFontSize = fontSize.parse(part, {
|
|
190
|
+
globalObject
|
|
191
|
+
});
|
|
192
|
+
if (typeof parsedFontSize === "string") {
|
|
193
|
+
fontSizeA = parsedFontSize;
|
|
194
|
+
} else {
|
|
195
|
+
const parsedFontFamily = fontFamily.parse(part, {
|
|
196
|
+
globalObject,
|
|
197
|
+
caseSensitive: true
|
|
198
|
+
});
|
|
199
|
+
if (typeof parsedFontFamily === "string") {
|
|
200
|
+
revFontFamily.push(parsedFontFamily);
|
|
201
|
+
} else {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
114
205
|
}
|
|
115
206
|
}
|
|
116
|
-
const family = revFontFamily.
|
|
117
|
-
|
|
207
|
+
const family = fontFamily.parse(revFontFamily.toReversed().join(" "), {
|
|
208
|
+
globalObject,
|
|
209
|
+
caseSensitive: true
|
|
210
|
+
});
|
|
211
|
+
if (fontSizeA && family) {
|
|
118
212
|
font["font-size"] = fontSizeA;
|
|
119
213
|
fontFamilies.add(fontFamily.parse(family));
|
|
120
214
|
} else {
|
|
@@ -122,8 +216,12 @@ module.exports.parse = function parse(v) {
|
|
|
122
216
|
}
|
|
123
217
|
}
|
|
124
218
|
for (const family of families) {
|
|
125
|
-
|
|
126
|
-
|
|
219
|
+
const parsedFontFamily = fontFamily.parse(family, {
|
|
220
|
+
globalObject,
|
|
221
|
+
caseSensitive: true
|
|
222
|
+
});
|
|
223
|
+
if (parsedFontFamily) {
|
|
224
|
+
fontFamilies.add(parsedFontFamily);
|
|
127
225
|
} else {
|
|
128
226
|
return;
|
|
129
227
|
}
|
|
@@ -139,17 +237,20 @@ module.exports.definition = {
|
|
|
139
237
|
for (const [key] of module.exports.shorthandFor) {
|
|
140
238
|
this._setProperty(key, "");
|
|
141
239
|
}
|
|
142
|
-
this._setProperty(
|
|
240
|
+
this._setProperty(property, v);
|
|
143
241
|
} else {
|
|
144
|
-
const obj = module.exports.parse(v
|
|
242
|
+
const obj = module.exports.parse(v, {
|
|
243
|
+
globalObject: this._global
|
|
244
|
+
});
|
|
145
245
|
if (!obj) {
|
|
146
246
|
return;
|
|
147
247
|
}
|
|
248
|
+
const priority = this._priorities.get(property) ?? "";
|
|
148
249
|
const str = new Set();
|
|
149
250
|
for (const [key] of module.exports.shorthandFor) {
|
|
150
251
|
const val = obj[key];
|
|
151
252
|
if (typeof val === "string") {
|
|
152
|
-
this._setProperty(key, val);
|
|
253
|
+
this._setProperty(key, val, priority);
|
|
153
254
|
if (val && val !== "normal" && !str.has(val)) {
|
|
154
255
|
if (key === "line-height") {
|
|
155
256
|
str.add(`/ ${val}`);
|
|
@@ -159,11 +260,11 @@ module.exports.definition = {
|
|
|
159
260
|
}
|
|
160
261
|
}
|
|
161
262
|
}
|
|
162
|
-
this._setProperty(
|
|
263
|
+
this._setProperty(property, [...str].join(" "), priority);
|
|
163
264
|
}
|
|
164
265
|
},
|
|
165
266
|
get() {
|
|
166
|
-
const val = this.getPropertyValue(
|
|
267
|
+
const val = this.getPropertyValue(property);
|
|
167
268
|
if (parsers.hasVarFunc(val)) {
|
|
168
269
|
return val;
|
|
169
270
|
}
|