cssstyle 4.5.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 +16 -6
- package/lib/generated/implementedProperties.js +13 -10
- package/lib/generated/properties.js +822 -94
- package/lib/parsers.js +59 -42
- package/lib/properties/background.js +350 -13
- 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 +10 -5
- package/lib/properties/borderBottom.js +4 -4
- package/lib/properties/borderLeft.js +4 -4
- package/lib/properties/borderRight.js +4 -4
- package/lib/properties/borderStyle.js +1 -1
- package/lib/properties/borderTop.js +4 -4
- package/lib/properties/clip.js +2 -1
- package/lib/properties/flex.js +5 -5
- package/lib/properties/font.js +8 -15
- package/lib/properties/fontFamily.js +10 -0
- package/lib/properties/margin.js +1 -1
- package/lib/properties/marginBottom.js +1 -1
- package/lib/properties/marginLeft.js +1 -1
- package/lib/properties/marginRight.js +1 -1
- package/lib/properties/marginTop.js +1 -1
- package/lib/shorthandProperties.js +21 -0
- package/lib/utils/camelize.js +3 -1
- package/lib/utils/strings.js +167 -0
- package/package.json +2 -2
|
@@ -3,11 +3,28 @@
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
5
|
module.exports.parse = function parse(v) {
|
|
6
|
-
|
|
6
|
+
if (v === "") {
|
|
7
|
+
return v;
|
|
8
|
+
}
|
|
9
|
+
const values = parsers.splitValue(v, {
|
|
10
|
+
delimiter: ","
|
|
11
|
+
});
|
|
12
|
+
const parsedValues = [];
|
|
13
|
+
for (const value of values) {
|
|
14
|
+
const parsedValue = parsers.parseImage(value);
|
|
15
|
+
if (parsedValue) {
|
|
16
|
+
parsedValues.push(parsedValue);
|
|
17
|
+
} else {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (parsedValues.length) {
|
|
22
|
+
return parsedValues.join(", ");
|
|
23
|
+
}
|
|
7
24
|
};
|
|
8
25
|
|
|
9
26
|
module.exports.isValid = function isValid(v) {
|
|
10
|
-
if (v === ""
|
|
27
|
+
if (v === "") {
|
|
11
28
|
return true;
|
|
12
29
|
}
|
|
13
30
|
return typeof module.exports.parse(v) === "string";
|
|
@@ -0,0 +1,49 @@
|
|
|
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 keywords = ["border-box", "padding-box", "content-box"];
|
|
13
|
+
const parsedValues = [];
|
|
14
|
+
for (const value of values) {
|
|
15
|
+
const parsedValue = parsers.parseKeyword(value, keywords);
|
|
16
|
+
if (parsedValue) {
|
|
17
|
+
parsedValues.push(parsedValue);
|
|
18
|
+
} else {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (parsedValues.length) {
|
|
23
|
+
return parsedValues.join(", ");
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports.isValid = function isValid(v) {
|
|
28
|
+
if (v === "") {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return typeof module.exports.parse(v) === "string";
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports.definition = {
|
|
35
|
+
set(v) {
|
|
36
|
+
v = parsers.prepareValue(v, this._global);
|
|
37
|
+
if (parsers.hasVarFunc(v)) {
|
|
38
|
+
this._setProperty("background", "");
|
|
39
|
+
this._setProperty("background-origin", v);
|
|
40
|
+
} else {
|
|
41
|
+
this._setProperty("background-origin", module.exports.parse(v));
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
get() {
|
|
45
|
+
return this.getPropertyValue("background-origin");
|
|
46
|
+
},
|
|
47
|
+
enumerable: true,
|
|
48
|
+
configurable: true
|
|
49
|
+
};
|
|
@@ -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]
|
|
@@ -14,16 +14,21 @@ const shorthandFor = new Map([
|
|
|
14
14
|
module.exports.definition = {
|
|
15
15
|
set(v) {
|
|
16
16
|
v = parsers.prepareValue(v, this._global);
|
|
17
|
-
if (
|
|
17
|
+
if (/^none$/i.test(v)) {
|
|
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/clip.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// @see https://drafts.fxtf.org/css-masking/#clip-property
|
|
4
4
|
|
|
5
5
|
const parsers = require("../parsers");
|
|
6
|
+
const strings = require("../utils/strings");
|
|
6
7
|
|
|
7
8
|
module.exports.parse = function parse(v) {
|
|
8
9
|
if (v === "") {
|
|
@@ -13,7 +14,7 @@ module.exports.parse = function parse(v) {
|
|
|
13
14
|
return val;
|
|
14
15
|
}
|
|
15
16
|
// parse legacy <shape>
|
|
16
|
-
v =
|
|
17
|
+
v = strings.asciiLowercase(v);
|
|
17
18
|
const matches = v.match(/^rect\(\s*(.*)\s*\)$/);
|
|
18
19
|
if (!matches) {
|
|
19
20
|
return;
|
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
|
}
|