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
|
@@ -1,57 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
|
+
const paddingTop = require("./paddingTop");
|
|
5
|
+
const paddingRight = require("./paddingRight");
|
|
6
|
+
const paddingBottom = require("./paddingBottom");
|
|
7
|
+
const paddingLeft = require("./paddingLeft");
|
|
4
8
|
|
|
5
|
-
const
|
|
9
|
+
const property = "padding";
|
|
6
10
|
|
|
7
|
-
module.exports.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
module.exports.position = "edges";
|
|
12
|
+
|
|
13
|
+
module.exports.shorthandFor = new Map([
|
|
14
|
+
["padding-top", paddingTop],
|
|
15
|
+
["padding-right", paddingRight],
|
|
16
|
+
["padding-bottom", paddingBottom],
|
|
17
|
+
["padding-left", paddingLeft]
|
|
18
|
+
]);
|
|
14
19
|
|
|
15
|
-
module.exports.
|
|
20
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
21
|
+
const { globalObject } = opt;
|
|
16
22
|
if (v === "") {
|
|
17
|
-
return
|
|
23
|
+
return v;
|
|
24
|
+
}
|
|
25
|
+
const values = parsers.parsePropertyValue(property, v, {
|
|
26
|
+
globalObject,
|
|
27
|
+
inArray: true
|
|
28
|
+
});
|
|
29
|
+
const parsedValues = [];
|
|
30
|
+
if (Array.isArray(values) && values.length) {
|
|
31
|
+
if (values.length > 4) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (const value of values) {
|
|
35
|
+
const { isNumber, name, type, value: itemValue } = value;
|
|
36
|
+
switch (type) {
|
|
37
|
+
case "Calc": {
|
|
38
|
+
if (isNumber) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
parsedValues.push(`${name}(${itemValue})`);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case "GlobalKeyword": {
|
|
45
|
+
if (values.length !== 1) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
parsedValues.push(name);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
default: {
|
|
52
|
+
const parsedValue = parsers.parseLengthPercentage([value], {
|
|
53
|
+
min: 0
|
|
54
|
+
});
|
|
55
|
+
if (!parsedValue) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
parsedValues.push(parsedValue);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} else if (typeof values === "string") {
|
|
63
|
+
parsedValues.push(values);
|
|
64
|
+
}
|
|
65
|
+
if (parsedValues.length) {
|
|
66
|
+
return parsedValues;
|
|
18
67
|
}
|
|
19
|
-
return typeof module.exports.parse(v) === "string";
|
|
20
68
|
};
|
|
21
69
|
|
|
22
70
|
module.exports.definition = {
|
|
23
71
|
set(v) {
|
|
24
72
|
v = parsers.prepareValue(v, this._global);
|
|
25
73
|
if (parsers.hasVarFunc(v)) {
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
module.exports.isValid,
|
|
31
|
-
module.exports.parse,
|
|
32
|
-
positions
|
|
33
|
-
);
|
|
34
|
-
this._setProperty("padding", v);
|
|
74
|
+
for (const [longhand] of module.exports.shorthandFor) {
|
|
75
|
+
this._setProperty(longhand, "");
|
|
76
|
+
}
|
|
77
|
+
this._setProperty(property, v);
|
|
35
78
|
} else {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
79
|
+
const val = module.exports.parse(v, {
|
|
80
|
+
globalObject: this._global
|
|
81
|
+
});
|
|
82
|
+
if (Array.isArray(val) || typeof val === "string") {
|
|
83
|
+
const priority = this._priorities.get(property) ?? "";
|
|
84
|
+
this._positionShorthandSetter(property, val, priority);
|
|
85
|
+
}
|
|
44
86
|
}
|
|
45
87
|
},
|
|
46
88
|
get() {
|
|
47
|
-
|
|
48
|
-
if (val === "") {
|
|
49
|
-
return this.getPropertyValue("padding");
|
|
50
|
-
}
|
|
51
|
-
if (parsers.hasVarFunc(val)) {
|
|
52
|
-
return "";
|
|
53
|
-
}
|
|
54
|
-
return val;
|
|
89
|
+
return this.getPropertyValue(property);
|
|
55
90
|
},
|
|
56
91
|
enumerable: true,
|
|
57
92
|
configurable: true
|
|
@@ -2,40 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return parsers.parseKeyword(v);
|
|
11
|
-
};
|
|
5
|
+
const property = "padding-bottom";
|
|
6
|
+
const shorthand = "padding";
|
|
7
|
+
|
|
8
|
+
module.exports.position = "bottom";
|
|
12
9
|
|
|
13
|
-
module.exports.
|
|
10
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
11
|
+
const { globalObject } = opt;
|
|
14
12
|
if (v === "") {
|
|
15
|
-
return
|
|
13
|
+
return v;
|
|
14
|
+
}
|
|
15
|
+
const value = parsers.parsePropertyValue(property, v, {
|
|
16
|
+
globalObject,
|
|
17
|
+
inArray: true
|
|
18
|
+
});
|
|
19
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
20
|
+
const [{ isNumber, name, type, value: itemValue }] = value;
|
|
21
|
+
switch (type) {
|
|
22
|
+
case "Calc": {
|
|
23
|
+
if (isNumber) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return `${name}(${itemValue})`;
|
|
27
|
+
}
|
|
28
|
+
case "GlobalKeyword": {
|
|
29
|
+
return name;
|
|
30
|
+
}
|
|
31
|
+
default: {
|
|
32
|
+
return parsers.parseLengthPercentage(value, {
|
|
33
|
+
min: 0
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} else if (typeof value === "string") {
|
|
38
|
+
return value;
|
|
16
39
|
}
|
|
17
|
-
return typeof module.exports.parse(v) === "string";
|
|
18
40
|
};
|
|
19
41
|
|
|
20
42
|
module.exports.definition = {
|
|
21
43
|
set(v) {
|
|
22
44
|
v = parsers.prepareValue(v, this._global);
|
|
23
45
|
if (parsers.hasVarFunc(v)) {
|
|
24
|
-
this._setProperty(
|
|
25
|
-
this._setProperty(
|
|
46
|
+
this._setProperty(shorthand, "");
|
|
47
|
+
this._setProperty(property, v);
|
|
26
48
|
} else {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
const val = module.exports.parse(v, {
|
|
50
|
+
globalObject: this._global
|
|
51
|
+
});
|
|
52
|
+
if (typeof val === "string") {
|
|
53
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
54
|
+
const prior = this._priorities.get(property) ?? "";
|
|
55
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
56
|
+
this._positionLonghandSetter(property, val, priority, shorthand);
|
|
57
|
+
}
|
|
35
58
|
}
|
|
36
59
|
},
|
|
37
60
|
get() {
|
|
38
|
-
return this.getPropertyValue(
|
|
61
|
+
return this.getPropertyValue(property);
|
|
39
62
|
},
|
|
40
63
|
enumerable: true,
|
|
41
64
|
configurable: true
|
|
@@ -2,38 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return parsers.parseKeyword(v);
|
|
11
|
-
};
|
|
5
|
+
const property = "padding-left";
|
|
6
|
+
const shorthand = "padding";
|
|
7
|
+
|
|
8
|
+
module.exports.position = "left";
|
|
12
9
|
|
|
13
|
-
module.exports.
|
|
10
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
11
|
+
const { globalObject } = opt;
|
|
14
12
|
if (v === "") {
|
|
15
|
-
return
|
|
13
|
+
return v;
|
|
14
|
+
}
|
|
15
|
+
const value = parsers.parsePropertyValue(property, v, {
|
|
16
|
+
globalObject,
|
|
17
|
+
inArray: true
|
|
18
|
+
});
|
|
19
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
20
|
+
const [{ isNumber, name, type, value: itemValue }] = value;
|
|
21
|
+
switch (type) {
|
|
22
|
+
case "Calc": {
|
|
23
|
+
if (isNumber) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return `${name}(${itemValue})`;
|
|
27
|
+
}
|
|
28
|
+
case "GlobalKeyword": {
|
|
29
|
+
return name;
|
|
30
|
+
}
|
|
31
|
+
default: {
|
|
32
|
+
return parsers.parseLengthPercentage(value, {
|
|
33
|
+
min: 0
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} else if (typeof value === "string") {
|
|
38
|
+
return value;
|
|
16
39
|
}
|
|
17
|
-
return typeof module.exports.parse(v) === "string";
|
|
18
40
|
};
|
|
19
41
|
|
|
20
42
|
module.exports.definition = {
|
|
21
43
|
set(v) {
|
|
22
44
|
v = parsers.prepareValue(v, this._global);
|
|
23
45
|
if (parsers.hasVarFunc(v)) {
|
|
24
|
-
this._setProperty(
|
|
25
|
-
this._setProperty(
|
|
46
|
+
this._setProperty(shorthand, "");
|
|
47
|
+
this._setProperty(property, v);
|
|
26
48
|
} else {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
const val = module.exports.parse(v, {
|
|
50
|
+
globalObject: this._global
|
|
51
|
+
});
|
|
52
|
+
if (typeof val === "string") {
|
|
53
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
54
|
+
const prior = this._priorities.get(property) ?? "";
|
|
55
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
56
|
+
this._positionLonghandSetter(property, val, priority, shorthand);
|
|
57
|
+
}
|
|
33
58
|
}
|
|
34
59
|
},
|
|
35
60
|
get() {
|
|
36
|
-
return this.getPropertyValue(
|
|
61
|
+
return this.getPropertyValue(property);
|
|
37
62
|
},
|
|
38
63
|
enumerable: true,
|
|
39
64
|
configurable: true
|
|
@@ -2,38 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return parsers.parseKeyword(v);
|
|
11
|
-
};
|
|
5
|
+
const property = "padding-right";
|
|
6
|
+
const shorthand = "padding";
|
|
7
|
+
|
|
8
|
+
module.exports.position = "right";
|
|
12
9
|
|
|
13
|
-
module.exports.
|
|
10
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
11
|
+
const { globalObject } = opt;
|
|
14
12
|
if (v === "") {
|
|
15
|
-
return
|
|
13
|
+
return v;
|
|
14
|
+
}
|
|
15
|
+
const value = parsers.parsePropertyValue(property, v, {
|
|
16
|
+
globalObject,
|
|
17
|
+
inArray: true
|
|
18
|
+
});
|
|
19
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
20
|
+
const [{ isNumber, name, type, value: itemValue }] = value;
|
|
21
|
+
switch (type) {
|
|
22
|
+
case "Calc": {
|
|
23
|
+
if (isNumber) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return `${name}(${itemValue})`;
|
|
27
|
+
}
|
|
28
|
+
case "GlobalKeyword": {
|
|
29
|
+
return name;
|
|
30
|
+
}
|
|
31
|
+
default: {
|
|
32
|
+
return parsers.parseLengthPercentage(value, {
|
|
33
|
+
min: 0
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} else if (typeof value === "string") {
|
|
38
|
+
return value;
|
|
16
39
|
}
|
|
17
|
-
return typeof module.exports.parse(v) === "string";
|
|
18
40
|
};
|
|
19
41
|
|
|
20
42
|
module.exports.definition = {
|
|
21
43
|
set(v) {
|
|
22
44
|
v = parsers.prepareValue(v, this._global);
|
|
23
45
|
if (parsers.hasVarFunc(v)) {
|
|
24
|
-
this._setProperty(
|
|
25
|
-
this._setProperty(
|
|
46
|
+
this._setProperty(shorthand, "");
|
|
47
|
+
this._setProperty(property, v);
|
|
26
48
|
} else {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
const val = module.exports.parse(v, {
|
|
50
|
+
globalObject: this._global
|
|
51
|
+
});
|
|
52
|
+
if (typeof val === "string") {
|
|
53
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
54
|
+
const prior = this._priorities.get(property) ?? "";
|
|
55
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
56
|
+
this._positionLonghandSetter(property, val, priority, shorthand);
|
|
57
|
+
}
|
|
33
58
|
}
|
|
34
59
|
},
|
|
35
60
|
get() {
|
|
36
|
-
return this.getPropertyValue(
|
|
61
|
+
return this.getPropertyValue(property);
|
|
37
62
|
},
|
|
38
63
|
enumerable: true,
|
|
39
64
|
configurable: true
|
|
@@ -2,38 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return parsers.parseKeyword(v);
|
|
11
|
-
};
|
|
5
|
+
const property = "padding-top";
|
|
6
|
+
const shorthand = "padding";
|
|
7
|
+
|
|
8
|
+
module.exports.position = "top";
|
|
12
9
|
|
|
13
|
-
module.exports.
|
|
10
|
+
module.exports.parse = function parse(v, opt = {}) {
|
|
11
|
+
const { globalObject } = opt;
|
|
14
12
|
if (v === "") {
|
|
15
|
-
return
|
|
13
|
+
return v;
|
|
14
|
+
}
|
|
15
|
+
const value = parsers.parsePropertyValue(property, v, {
|
|
16
|
+
globalObject,
|
|
17
|
+
inArray: true
|
|
18
|
+
});
|
|
19
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
20
|
+
const [{ isNumber, name, type, value: itemValue }] = value;
|
|
21
|
+
switch (type) {
|
|
22
|
+
case "Calc": {
|
|
23
|
+
if (isNumber) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return `${name}(${itemValue})`;
|
|
27
|
+
}
|
|
28
|
+
case "GlobalKeyword": {
|
|
29
|
+
return name;
|
|
30
|
+
}
|
|
31
|
+
default: {
|
|
32
|
+
return parsers.parseLengthPercentage(value, {
|
|
33
|
+
min: 0
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} else if (typeof value === "string") {
|
|
38
|
+
return value;
|
|
16
39
|
}
|
|
17
|
-
return typeof module.exports.parse(v) === "string";
|
|
18
40
|
};
|
|
19
41
|
|
|
20
42
|
module.exports.definition = {
|
|
21
43
|
set(v) {
|
|
22
44
|
v = parsers.prepareValue(v, this._global);
|
|
23
45
|
if (parsers.hasVarFunc(v)) {
|
|
24
|
-
this._setProperty(
|
|
25
|
-
this._setProperty(
|
|
46
|
+
this._setProperty(shorthand, "");
|
|
47
|
+
this._setProperty(property, v);
|
|
26
48
|
} else {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
const val = module.exports.parse(v, {
|
|
50
|
+
globalObject: this._global
|
|
51
|
+
});
|
|
52
|
+
if (typeof val === "string") {
|
|
53
|
+
const shorthandPriority = this._priorities.get(shorthand);
|
|
54
|
+
const prior = this._priorities.get(property) ?? "";
|
|
55
|
+
const priority = shorthandPriority && prior ? "" : prior;
|
|
56
|
+
this._positionLonghandSetter(property, val, priority, shorthand);
|
|
57
|
+
}
|
|
33
58
|
}
|
|
34
59
|
},
|
|
35
60
|
get() {
|
|
36
|
-
return this.getPropertyValue(
|
|
61
|
+
return this.getPropertyValue(property);
|
|
37
62
|
},
|
|
38
63
|
enumerable: true,
|
|
39
64
|
configurable: true
|
package/lib/properties/right.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 = "right";
|
|
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 = "stop-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/top.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 = "top";
|
|
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
|