cssstyle 4.6.0 → 5.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 +14 -5
- package/lib/generated/implementedProperties.js +13 -10
- package/lib/generated/properties.js +800 -84
- package/lib/parsers.js +6 -24
- package/lib/properties/background.js +350 -19
- package/lib/properties/backgroundAttachment.js +18 -1
- package/lib/properties/backgroundClip.js +49 -0
- package/lib/properties/backgroundImage.js +19 -2
- package/lib/properties/backgroundOrigin.js +49 -0
- package/lib/properties/backgroundPosition.js +142 -18
- package/lib/properties/backgroundRepeat.js +52 -2
- package/lib/properties/backgroundSize.js +80 -0
- package/lib/properties/border.js +9 -4
- package/lib/properties/borderBottom.js +4 -4
- package/lib/properties/borderLeft.js +4 -4
- package/lib/properties/borderRight.js +4 -4
- package/lib/properties/borderTop.js +4 -4
- package/lib/properties/flex.js +5 -5
- package/lib/properties/font.js +7 -8
- package/lib/shorthandProperties.js +21 -0
- package/package.json +2 -2
|
@@ -3,27 +3,151 @@
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
5
|
module.exports.parse = function parse(v) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return;
|
|
6
|
+
if (v === "") {
|
|
7
|
+
return v;
|
|
9
8
|
}
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const values = parsers.splitValue(v, {
|
|
10
|
+
delimiter: ","
|
|
11
|
+
});
|
|
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
|
+
const parsedValues = [];
|
|
18
|
+
for (const value of values) {
|
|
19
|
+
const parts = parsers.splitValue(value);
|
|
20
|
+
if (!parts.length || parts.length > 4) {
|
|
21
|
+
return;
|
|
16
22
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
let parsedValue = "";
|
|
24
|
+
switch (parts.length) {
|
|
25
|
+
case 1: {
|
|
26
|
+
const [part] = parts;
|
|
27
|
+
const val = parsers.parseMeasurement(part) || parsers.parseKeyword(part, keywords);
|
|
28
|
+
if (val) {
|
|
29
|
+
if (val === "center") {
|
|
30
|
+
parsedValue = `${val} ${val}`;
|
|
31
|
+
} else if (val === "top" || val === "bottom") {
|
|
32
|
+
parsedValue = `center ${val}`;
|
|
33
|
+
} else {
|
|
34
|
+
parsedValue = `${val} center`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case 2: {
|
|
40
|
+
const [part1, part2] = parts;
|
|
41
|
+
const val1 = parsers.parseMeasurement(part1) || parsers.parseKeyword(part1, keywords);
|
|
42
|
+
const val2 = parsers.parseMeasurement(part2) || parsers.parseKeyword(part2, keywords);
|
|
43
|
+
if (val1 && val2) {
|
|
44
|
+
if (keywordsY.includes(val1) && keywordsX.includes(val2)) {
|
|
45
|
+
parsedValue = `${val2} ${val1}`;
|
|
46
|
+
} else if (keywordsX.includes(val1)) {
|
|
47
|
+
if (val2 === "center" || !keywordsX.includes(val2)) {
|
|
48
|
+
parsedValue = `${val1} ${val2}`;
|
|
49
|
+
}
|
|
50
|
+
} else if (keywordsY.includes(val2)) {
|
|
51
|
+
if (!keywordsY.includes(val1)) {
|
|
52
|
+
parsedValue = `${val1} ${val2}`;
|
|
53
|
+
}
|
|
54
|
+
} else if (!keywordsY.includes(val1) && !keywordsX.includes(val2)) {
|
|
55
|
+
parsedValue = `${val1} ${val2}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
case 3: {
|
|
61
|
+
const [part1, part2, part3] = parts;
|
|
62
|
+
const val1 = parsers.parseKeyword(part1, keywords);
|
|
63
|
+
const val2 = parsers.parseMeasurement(part2) || parsers.parseKeyword(part2, keywords);
|
|
64
|
+
const val3 = parsers.parseMeasurement(part3) || parsers.parseKeyword(part3, keywords);
|
|
65
|
+
if (val1 && val2 && val3) {
|
|
66
|
+
let posX = "";
|
|
67
|
+
let offX = "";
|
|
68
|
+
let posY = "";
|
|
69
|
+
let offY = "";
|
|
70
|
+
if (keywordsX.includes(val1)) {
|
|
71
|
+
if (keyY.includes(val2)) {
|
|
72
|
+
if (!keywords.includes(val3)) {
|
|
73
|
+
posX = val1;
|
|
74
|
+
posY = val2;
|
|
75
|
+
offY = val3;
|
|
76
|
+
}
|
|
77
|
+
} else if (keyY.includes(val3)) {
|
|
78
|
+
if (!keywords.includes(val2)) {
|
|
79
|
+
posX = val1;
|
|
80
|
+
offX = val2;
|
|
81
|
+
posY = val3;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} else if (keywordsY.includes(val1)) {
|
|
85
|
+
if (keyX.includes(val2)) {
|
|
86
|
+
if (!keywords.includes(val3)) {
|
|
87
|
+
posX = val2;
|
|
88
|
+
offX = val3;
|
|
89
|
+
posY = val1;
|
|
90
|
+
}
|
|
91
|
+
} else if (keyX.includes(val3)) {
|
|
92
|
+
if (!keywords.includes(val2)) {
|
|
93
|
+
posX = val3;
|
|
94
|
+
posY = val1;
|
|
95
|
+
offY = val2;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (posX && posY) {
|
|
100
|
+
if (offX) {
|
|
101
|
+
parsedValue = `${posX} ${offX} ${posY}`;
|
|
102
|
+
} else if (offY) {
|
|
103
|
+
parsedValue = `${posX} ${posY} ${offY}`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 4:
|
|
110
|
+
default: {
|
|
111
|
+
const [part1, part2, part3, part4] = parts;
|
|
112
|
+
const val1 = parsers.parseKeyword(part1, keywords);
|
|
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
|
+
}
|
|
141
|
+
}
|
|
26
142
|
}
|
|
143
|
+
if (parsedValue) {
|
|
144
|
+
parsedValues.push(parsedValue);
|
|
145
|
+
} else {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (parsedValues.length) {
|
|
150
|
+
return parsedValues.join(", ");
|
|
27
151
|
}
|
|
28
152
|
};
|
|
29
153
|
|
|
@@ -3,8 +3,58 @@
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
5
|
module.exports.parse = function parse(v) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
if (v === "") {
|
|
7
|
+
return v;
|
|
8
|
+
}
|
|
9
|
+
const values = parsers.splitValue(v, {
|
|
10
|
+
delimiter: ","
|
|
11
|
+
});
|
|
12
|
+
const keywordsAxis = ["repeat-x", "repeat-y"];
|
|
13
|
+
const keywordsRepeat = ["repeat", "no-repeat", "space", "round"];
|
|
14
|
+
const keywords = [...keywordsAxis, ...keywordsRepeat];
|
|
15
|
+
const parsedValues = [];
|
|
16
|
+
for (const value of values) {
|
|
17
|
+
const parts = parsers.splitValue(value);
|
|
18
|
+
if (!parts.length || parts.length > 2) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let parsedValue = "";
|
|
22
|
+
switch (parts.length) {
|
|
23
|
+
case 1: {
|
|
24
|
+
const [part] = parts;
|
|
25
|
+
const val = parsers.parseKeyword(part, keywords);
|
|
26
|
+
if (val) {
|
|
27
|
+
parsedValue = val;
|
|
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) {
|
|
42
|
+
parsedValue = val1;
|
|
43
|
+
} else {
|
|
44
|
+
parsedValue = `${val1} ${val2}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (parsedValue) {
|
|
50
|
+
parsedValues.push(parsedValue);
|
|
51
|
+
} else {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (parsedValues.length) {
|
|
56
|
+
return parsedValues.join(", ");
|
|
57
|
+
}
|
|
8
58
|
};
|
|
9
59
|
|
|
10
60
|
module.exports.isValid = function isValid(v) {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const parsers = require("../parsers");
|
|
4
|
+
|
|
5
|
+
module.exports.parse = function parse(v) {
|
|
6
|
+
if (v === "") {
|
|
7
|
+
return v;
|
|
8
|
+
}
|
|
9
|
+
const values = parsers.splitValue(v, {
|
|
10
|
+
delimiter: ","
|
|
11
|
+
});
|
|
12
|
+
const keywordsRatio = ["contain", "cover"];
|
|
13
|
+
const keywordsRepeat = ["auto"];
|
|
14
|
+
const keywords = [...keywordsRatio, ...keywordsRepeat];
|
|
15
|
+
const parsedValues = [];
|
|
16
|
+
for (const value of values) {
|
|
17
|
+
const parts = parsers.splitValue(value);
|
|
18
|
+
if (!parts.length || parts.length > 2) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let parsedValue = "";
|
|
22
|
+
switch (parts.length) {
|
|
23
|
+
case 1: {
|
|
24
|
+
const [part] = parts;
|
|
25
|
+
const val = parsers.parseMeasurement(part, true) || parsers.parseKeyword(part, keywords);
|
|
26
|
+
if (val) {
|
|
27
|
+
parsedValue = val;
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case 2:
|
|
32
|
+
default: {
|
|
33
|
+
const [part1, part2] = parts;
|
|
34
|
+
const val1 =
|
|
35
|
+
parsers.parseMeasurement(part1, true) || parsers.parseKeyword(part1, keywordsRepeat);
|
|
36
|
+
const val2 =
|
|
37
|
+
parsers.parseMeasurement(part2, true) || parsers.parseKeyword(part2, keywordsRepeat);
|
|
38
|
+
if (val1 && val2) {
|
|
39
|
+
if (val2 === "auto") {
|
|
40
|
+
parsedValue = val1;
|
|
41
|
+
} else {
|
|
42
|
+
parsedValue = `${val1} ${val2}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (parsedValue) {
|
|
48
|
+
parsedValues.push(parsedValue);
|
|
49
|
+
} else {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (parsedValues.length) {
|
|
54
|
+
return parsedValues.join(", ");
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports.isValid = function isValid(v) {
|
|
59
|
+
if (v === "") {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return typeof module.exports.parse(v) === "string";
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
module.exports.definition = {
|
|
66
|
+
set(v) {
|
|
67
|
+
v = parsers.prepareValue(v, this._global);
|
|
68
|
+
if (parsers.hasVarFunc(v)) {
|
|
69
|
+
this._setProperty("background", "");
|
|
70
|
+
this._setProperty("background-size", v);
|
|
71
|
+
} else {
|
|
72
|
+
this._setProperty("background-size", module.exports.parse(v));
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
get() {
|
|
76
|
+
return this.getPropertyValue("background-size");
|
|
77
|
+
},
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true
|
|
80
|
+
};
|
package/lib/properties/border.js
CHANGED
|
@@ -5,7 +5,7 @@ const borderWidth = require("./borderWidth");
|
|
|
5
5
|
const borderStyle = require("./borderStyle");
|
|
6
6
|
const borderColor = require("./borderColor");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
module.exports.shorthandFor = new Map([
|
|
9
9
|
["border-width", borderWidth],
|
|
10
10
|
["border-style", borderStyle],
|
|
11
11
|
["border-color", borderColor]
|
|
@@ -18,12 +18,17 @@ module.exports.definition = {
|
|
|
18
18
|
v = "";
|
|
19
19
|
}
|
|
20
20
|
if (parsers.hasVarFunc(v)) {
|
|
21
|
-
for (const [key] of shorthandFor) {
|
|
21
|
+
for (const [key] of module.exports.shorthandFor) {
|
|
22
22
|
this._setProperty(key, "");
|
|
23
23
|
}
|
|
24
24
|
this._setProperty("border", v);
|
|
25
25
|
} else {
|
|
26
|
-
this._midShorthandSetter("border", v, shorthandFor, [
|
|
26
|
+
this._midShorthandSetter("border", v, module.exports.shorthandFor, [
|
|
27
|
+
"top",
|
|
28
|
+
"right",
|
|
29
|
+
"bottom",
|
|
30
|
+
"left"
|
|
31
|
+
]);
|
|
27
32
|
}
|
|
28
33
|
},
|
|
29
34
|
get() {
|
|
@@ -31,7 +36,7 @@ module.exports.definition = {
|
|
|
31
36
|
if (parsers.hasVarFunc(val)) {
|
|
32
37
|
return val;
|
|
33
38
|
}
|
|
34
|
-
val = this._shorthandGetter("border", shorthandFor);
|
|
39
|
+
val = this._shorthandGetter("border", module.exports.shorthandFor);
|
|
35
40
|
if (parsers.hasVarFunc(val)) {
|
|
36
41
|
return "";
|
|
37
42
|
}
|
|
@@ -5,7 +5,7 @@ const borderTopWidth = require("./borderTopWidth");
|
|
|
5
5
|
const borderTopStyle = require("./borderTopStyle");
|
|
6
6
|
const borderTopColor = require("./borderTopColor");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
module.exports.shorthandFor = new Map([
|
|
9
9
|
["border-bottom-width", borderTopWidth],
|
|
10
10
|
["border-bottom-style", borderTopStyle],
|
|
11
11
|
["border-bottom-color", borderTopColor]
|
|
@@ -15,13 +15,13 @@ module.exports.definition = {
|
|
|
15
15
|
set(v) {
|
|
16
16
|
v = parsers.prepareValue(v, this._global);
|
|
17
17
|
if (parsers.hasVarFunc(v)) {
|
|
18
|
-
for (const [key] of shorthandFor) {
|
|
18
|
+
for (const [key] of module.exports.shorthandFor) {
|
|
19
19
|
this._setProperty(key, "");
|
|
20
20
|
}
|
|
21
21
|
this._setProperty("border", "");
|
|
22
22
|
this._setProperty("border-bottom", v);
|
|
23
23
|
} else {
|
|
24
|
-
this._shorthandSetter("border-bottom", v, shorthandFor);
|
|
24
|
+
this._shorthandSetter("border-bottom", v, module.exports.shorthandFor);
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
get() {
|
|
@@ -29,7 +29,7 @@ module.exports.definition = {
|
|
|
29
29
|
if (parsers.hasVarFunc(val)) {
|
|
30
30
|
return val;
|
|
31
31
|
}
|
|
32
|
-
val = this._shorthandGetter("border-bottom", shorthandFor);
|
|
32
|
+
val = this._shorthandGetter("border-bottom", module.exports.shorthandFor);
|
|
33
33
|
if (parsers.hasVarFunc(val)) {
|
|
34
34
|
return "";
|
|
35
35
|
}
|
|
@@ -5,7 +5,7 @@ const borderTopWidth = require("./borderTopWidth");
|
|
|
5
5
|
const borderTopStyle = require("./borderTopStyle");
|
|
6
6
|
const borderTopColor = require("./borderTopColor");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
module.exports.shorthandFor = new Map([
|
|
9
9
|
["border-left-width", borderTopWidth],
|
|
10
10
|
["border-left-style", borderTopStyle],
|
|
11
11
|
["border-left-color", borderTopColor]
|
|
@@ -15,13 +15,13 @@ module.exports.definition = {
|
|
|
15
15
|
set(v) {
|
|
16
16
|
v = parsers.prepareValue(v, this._global);
|
|
17
17
|
if (parsers.hasVarFunc(v)) {
|
|
18
|
-
for (const [key] of shorthandFor) {
|
|
18
|
+
for (const [key] of module.exports.shorthandFor) {
|
|
19
19
|
this._setProperty(key, "");
|
|
20
20
|
}
|
|
21
21
|
this._setProperty("border", "");
|
|
22
22
|
this._setProperty("border-left", v);
|
|
23
23
|
} else {
|
|
24
|
-
this._shorthandSetter("border-left", v, shorthandFor);
|
|
24
|
+
this._shorthandSetter("border-left", v, module.exports.shorthandFor);
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
get() {
|
|
@@ -29,7 +29,7 @@ module.exports.definition = {
|
|
|
29
29
|
if (parsers.hasVarFunc(val)) {
|
|
30
30
|
return val;
|
|
31
31
|
}
|
|
32
|
-
val = this._shorthandGetter("border-left", shorthandFor);
|
|
32
|
+
val = this._shorthandGetter("border-left", module.exports.shorthandFor);
|
|
33
33
|
if (parsers.hasVarFunc(val)) {
|
|
34
34
|
return "";
|
|
35
35
|
}
|
|
@@ -5,7 +5,7 @@ const borderTopWidth = require("./borderTopWidth");
|
|
|
5
5
|
const borderTopStyle = require("./borderTopStyle");
|
|
6
6
|
const borderTopColor = require("./borderTopColor");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
module.exports.shorthandFor = new Map([
|
|
9
9
|
["border-right-width", borderTopWidth],
|
|
10
10
|
["border-right-style", borderTopStyle],
|
|
11
11
|
["border-right-color", borderTopColor]
|
|
@@ -15,13 +15,13 @@ module.exports.definition = {
|
|
|
15
15
|
set(v) {
|
|
16
16
|
v = parsers.prepareValue(v, this._global);
|
|
17
17
|
if (parsers.hasVarFunc(v)) {
|
|
18
|
-
for (const [key] of shorthandFor) {
|
|
18
|
+
for (const [key] of module.exports.shorthandFor) {
|
|
19
19
|
this._setProperty(key, "");
|
|
20
20
|
}
|
|
21
21
|
this._setProperty("border", "");
|
|
22
22
|
this._setProperty("border-right", v);
|
|
23
23
|
} else {
|
|
24
|
-
this._shorthandSetter("border-right", v, shorthandFor);
|
|
24
|
+
this._shorthandSetter("border-right", v, module.exports.shorthandFor);
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
get() {
|
|
@@ -29,7 +29,7 @@ module.exports.definition = {
|
|
|
29
29
|
if (parsers.hasVarFunc(val)) {
|
|
30
30
|
return val;
|
|
31
31
|
}
|
|
32
|
-
val = this._shorthandGetter("border-right", shorthandFor);
|
|
32
|
+
val = this._shorthandGetter("border-right", module.exports.shorthandFor);
|
|
33
33
|
if (parsers.hasVarFunc(val)) {
|
|
34
34
|
return "";
|
|
35
35
|
}
|
|
@@ -5,7 +5,7 @@ const borderTopWidth = require("./borderTopWidth");
|
|
|
5
5
|
const borderTopStyle = require("./borderTopStyle");
|
|
6
6
|
const borderTopColor = require("./borderTopColor");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
module.exports.shorthandFor = new Map([
|
|
9
9
|
["border-top-width", borderTopWidth],
|
|
10
10
|
["border-top-style", borderTopStyle],
|
|
11
11
|
["border-top-color", borderTopColor]
|
|
@@ -15,13 +15,13 @@ module.exports.definition = {
|
|
|
15
15
|
set(v) {
|
|
16
16
|
v = parsers.prepareValue(v, this._global);
|
|
17
17
|
if (parsers.hasVarFunc(v)) {
|
|
18
|
-
for (const [key] of shorthandFor) {
|
|
18
|
+
for (const [key] of module.exports.shorthandFor) {
|
|
19
19
|
this._setProperty(key, "");
|
|
20
20
|
}
|
|
21
21
|
this._setProperty("border", "");
|
|
22
22
|
this._setProperty("border-top", v);
|
|
23
23
|
} else {
|
|
24
|
-
this._shorthandSetter("border-top", v, shorthandFor);
|
|
24
|
+
this._shorthandSetter("border-top", v, module.exports.shorthandFor);
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
get() {
|
|
@@ -29,7 +29,7 @@ module.exports.definition = {
|
|
|
29
29
|
if (parsers.hasVarFunc(val)) {
|
|
30
30
|
return val;
|
|
31
31
|
}
|
|
32
|
-
val = this._shorthandGetter("border-top", shorthandFor);
|
|
32
|
+
val = this._shorthandGetter("border-top", module.exports.shorthandFor);
|
|
33
33
|
if (parsers.hasVarFunc(val)) {
|
|
34
34
|
return "";
|
|
35
35
|
}
|
package/lib/properties/flex.js
CHANGED
|
@@ -5,7 +5,7 @@ const flexGrow = require("./flexGrow");
|
|
|
5
5
|
const flexShrink = require("./flexShrink");
|
|
6
6
|
const flexBasis = require("./flexBasis");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
module.exports.shorthandFor = new Map([
|
|
9
9
|
["flex-grow", flexGrow],
|
|
10
10
|
["flex-shrink", flexShrink],
|
|
11
11
|
["flex-basis", flexBasis]
|
|
@@ -25,7 +25,7 @@ module.exports.parse = function parse(v) {
|
|
|
25
25
|
}
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const obj = parsers.parseShorthand(v, shorthandFor);
|
|
28
|
+
const obj = parsers.parseShorthand(v, module.exports.shorthandFor);
|
|
29
29
|
if (obj) {
|
|
30
30
|
const flex = {
|
|
31
31
|
"flex-grow": "1",
|
|
@@ -51,10 +51,10 @@ module.exports.definition = {
|
|
|
51
51
|
set(v) {
|
|
52
52
|
v = parsers.prepareValue(v, this._global);
|
|
53
53
|
if (parsers.hasVarFunc(v)) {
|
|
54
|
-
this._shorthandSetter("flex", "", shorthandFor);
|
|
54
|
+
this._shorthandSetter("flex", "", module.exports.shorthandFor);
|
|
55
55
|
this._setProperty("flex", v);
|
|
56
56
|
} else {
|
|
57
|
-
this._shorthandSetter("flex", module.exports.parse(v), shorthandFor);
|
|
57
|
+
this._shorthandSetter("flex", module.exports.parse(v), module.exports.shorthandFor);
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
get() {
|
|
@@ -62,7 +62,7 @@ module.exports.definition = {
|
|
|
62
62
|
if (parsers.hasVarFunc(val)) {
|
|
63
63
|
return val;
|
|
64
64
|
}
|
|
65
|
-
val = this._shorthandGetter("flex", shorthandFor);
|
|
65
|
+
val = this._shorthandGetter("flex", module.exports.shorthandFor);
|
|
66
66
|
if (parsers.hasVarFunc(val)) {
|
|
67
67
|
return "";
|
|
68
68
|
}
|
package/lib/properties/font.js
CHANGED
|
@@ -8,7 +8,7 @@ const fontSize = require("./fontSize");
|
|
|
8
8
|
const lineHeight = require("./lineHeight");
|
|
9
9
|
const fontFamily = require("./fontFamily");
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
module.exports.shorthandFor = new Map([
|
|
12
12
|
["font-style", fontStyle],
|
|
13
13
|
["font-variant", fontVariant],
|
|
14
14
|
["font-weight", fontWeight],
|
|
@@ -59,7 +59,7 @@ module.exports.parse = function parse(v) {
|
|
|
59
59
|
case "font-variant":
|
|
60
60
|
case "font-weight":
|
|
61
61
|
case "font-size": {
|
|
62
|
-
const value = shorthandFor.get(property);
|
|
62
|
+
const value = module.exports.shorthandFor.get(property);
|
|
63
63
|
if (value.isValid(part)) {
|
|
64
64
|
font[property] = value.parse(part);
|
|
65
65
|
}
|
|
@@ -76,8 +76,7 @@ module.exports.parse = function parse(v) {
|
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
} else {
|
|
79
|
-
|
|
80
|
-
const revParts = [...parsers.splitValue(fontBlockA.trim())].reverse();
|
|
79
|
+
const revParts = parsers.splitValue(fontBlockA.trim()).toReversed();
|
|
81
80
|
const revFontFamily = [];
|
|
82
81
|
const properties = ["font-style", "font-variant", "font-weight", "line-height"];
|
|
83
82
|
font["font-style"] = "normal";
|
|
@@ -96,7 +95,7 @@ module.exports.parse = function parse(v) {
|
|
|
96
95
|
case "font-variant":
|
|
97
96
|
case "font-weight":
|
|
98
97
|
case "line-height": {
|
|
99
|
-
const value = shorthandFor.get(property);
|
|
98
|
+
const value = module.exports.shorthandFor.get(property);
|
|
100
99
|
if (value.isValid(part)) {
|
|
101
100
|
font[property] = value.parse(part);
|
|
102
101
|
}
|
|
@@ -137,7 +136,7 @@ module.exports.definition = {
|
|
|
137
136
|
set(v) {
|
|
138
137
|
v = parsers.prepareValue(v, this._global);
|
|
139
138
|
if (v === "" || parsers.hasVarFunc(v)) {
|
|
140
|
-
for (const [key] of shorthandFor) {
|
|
139
|
+
for (const [key] of module.exports.shorthandFor) {
|
|
141
140
|
this._setProperty(key, "");
|
|
142
141
|
}
|
|
143
142
|
this._setProperty("font", v);
|
|
@@ -147,7 +146,7 @@ module.exports.definition = {
|
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
148
|
const str = new Set();
|
|
150
|
-
for (const [key] of shorthandFor) {
|
|
149
|
+
for (const [key] of module.exports.shorthandFor) {
|
|
151
150
|
const val = obj[key];
|
|
152
151
|
if (typeof val === "string") {
|
|
153
152
|
this._setProperty(key, val);
|
|
@@ -169,7 +168,7 @@ module.exports.definition = {
|
|
|
169
168
|
return val;
|
|
170
169
|
}
|
|
171
170
|
const str = new Set();
|
|
172
|
-
for (const [key] of shorthandFor) {
|
|
171
|
+
for (const [key] of module.exports.shorthandFor) {
|
|
173
172
|
const v = this.getPropertyValue(key);
|
|
174
173
|
if (parsers.hasVarFunc(v)) {
|
|
175
174
|
return "";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const background = require("./properties/background");
|
|
4
|
+
const border = require("./properties/border");
|
|
5
|
+
const borderTop = require("./properties/borderTop");
|
|
6
|
+
const borderRight = require("./properties/borderRight");
|
|
7
|
+
const borderBottom = require("./properties/borderBottom");
|
|
8
|
+
const borderLeft = require("./properties/borderLeft");
|
|
9
|
+
const flex = require("./properties/flex");
|
|
10
|
+
const font = require("./properties/font");
|
|
11
|
+
|
|
12
|
+
module.exports.shorthandProperties = new Map([
|
|
13
|
+
["background", background.shorthandFor],
|
|
14
|
+
["border", border.shorthandFor],
|
|
15
|
+
["border-top", borderTop.shorthandFor],
|
|
16
|
+
["border-right", borderRight.shorthandFor],
|
|
17
|
+
["border-bottom", borderBottom.shorthandFor],
|
|
18
|
+
["border-left", borderLeft.shorthandFor],
|
|
19
|
+
["flex", flex.shorthandFor],
|
|
20
|
+
["font", font.shorthandFor]
|
|
21
|
+
]);
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"CSSStyleDeclaration",
|
|
7
7
|
"StyleSheet"
|
|
8
8
|
],
|
|
9
|
-
"version": "
|
|
9
|
+
"version": "5.0.0",
|
|
10
10
|
"homepage": "https://github.com/jsdom/cssstyle",
|
|
11
11
|
"maintainers": [
|
|
12
12
|
{
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
},
|
|
68
68
|
"license": "MIT",
|
|
69
69
|
"engines": {
|
|
70
|
-
"node": ">=
|
|
70
|
+
"node": ">=20"
|
|
71
71
|
}
|
|
72
72
|
}
|