cssstyle 4.3.0 → 4.4.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 +545 -206
- package/lib/allExtraProperties.js +42 -60
- package/lib/allWebkitProperties.js +107 -187
- package/lib/generated/allProperties.js +615 -0
- package/lib/{implementedProperties.js → generated/implementedProperties.js} +11 -18
- package/lib/generated/properties.js +2574 -0
- package/lib/parsers.js +400 -544
- package/lib/properties/background.js +40 -13
- package/lib/properties/backgroundAttachment.js +23 -15
- package/lib/properties/backgroundColor.js +21 -19
- package/lib/properties/backgroundImage.js +19 -14
- package/lib/properties/backgroundPosition.js +35 -41
- package/lib/properties/backgroundRepeat.js +20 -20
- package/lib/properties/border.js +34 -25
- package/lib/properties/borderBottom.js +34 -11
- package/lib/properties/borderBottomColor.js +27 -8
- package/lib/properties/borderBottomStyle.js +42 -13
- package/lib/properties/borderBottomWidth.js +28 -8
- package/lib/properties/borderCollapse.js +16 -16
- package/lib/properties/borderColor.js +32 -18
- package/lib/properties/borderLeft.js +34 -11
- package/lib/properties/borderLeftColor.js +27 -8
- package/lib/properties/borderLeftStyle.js +42 -13
- package/lib/properties/borderLeftWidth.js +28 -8
- package/lib/properties/borderRight.js +34 -11
- package/lib/properties/borderRightColor.js +27 -8
- package/lib/properties/borderRightStyle.js +42 -13
- package/lib/properties/borderRightWidth.js +28 -8
- package/lib/properties/borderSpacing.js +31 -27
- package/lib/properties/borderStyle.js +43 -27
- package/lib/properties/borderTop.js +34 -11
- package/lib/properties/borderTopColor.js +27 -8
- package/lib/properties/borderTopStyle.js +42 -13
- package/lib/properties/borderTopWidth.js +28 -9
- package/lib/properties/borderWidth.js +32 -34
- package/lib/properties/bottom.js +23 -7
- package/lib/properties/clear.js +32 -8
- package/lib/properties/clip.js +33 -27
- package/lib/properties/color.js +23 -7
- package/lib/properties/flex.js +59 -29
- package/lib/properties/flexBasis.js +21 -16
- package/lib/properties/flexGrow.js +19 -10
- package/lib/properties/flexShrink.js +19 -10
- package/lib/properties/float.js +21 -6
- package/lib/properties/floodColor.js +23 -7
- package/lib/properties/font.js +120 -33
- package/lib/properties/fontFamily.js +59 -21
- package/lib/properties/fontSize.js +37 -28
- package/lib/properties/fontStyle.js +23 -9
- package/lib/properties/fontVariant.js +26 -8
- package/lib/properties/fontWeight.js +26 -23
- package/lib/properties/height.js +21 -14
- package/lib/properties/left.js +23 -7
- package/lib/properties/lightingColor.js +23 -7
- package/lib/properties/lineHeight.js +29 -16
- package/lib/properties/margin.js +42 -57
- package/lib/properties/marginBottom.js +34 -7
- package/lib/properties/marginLeft.js +34 -7
- package/lib/properties/marginRight.js +34 -7
- package/lib/properties/marginTop.js +34 -7
- package/lib/properties/opacity.js +39 -7
- package/lib/properties/outlineColor.js +23 -7
- package/lib/properties/padding.js +43 -51
- package/lib/properties/paddingBottom.js +36 -7
- package/lib/properties/paddingLeft.js +34 -7
- package/lib/properties/paddingRight.js +34 -7
- package/lib/properties/paddingTop.js +34 -7
- package/lib/properties/right.js +23 -7
- package/lib/properties/stopColor.js +23 -7
- package/lib/properties/top.js +23 -7
- package/lib/properties/webkitBorderAfterColor.js +23 -7
- package/lib/properties/webkitBorderBeforeColor.js +23 -7
- package/lib/properties/webkitBorderEndColor.js +23 -7
- package/lib/properties/webkitBorderStartColor.js +23 -7
- package/lib/properties/webkitColumnRuleColor.js +23 -7
- package/lib/properties/webkitTapHighlightColor.js +23 -7
- package/lib/properties/webkitTextEmphasisColor.js +23 -7
- package/lib/properties/webkitTextFillColor.js +23 -7
- package/lib/properties/webkitTextStrokeColor.js +23 -7
- package/lib/properties/width.js +21 -14
- package/lib/utils/camelize.js +35 -0
- package/lib/utils/propertyDescriptors.js +16 -0
- package/package.json +5 -4
- package/lib/allProperties.js +0 -529
- package/lib/constants.js +0 -6
- package/lib/named_colors.json +0 -152
- package/lib/properties/azimuth.js +0 -64
- package/lib/properties/cssFloat.js +0 -12
- package/lib/properties/textLineThroughColor.js +0 -14
- package/lib/properties/textOverlineColor.js +0 -14
- package/lib/properties/textUnderlineColor.js +0 -14
- package/lib/properties/webkitMatchNearestMailBlockquoteColor.js +0 -14
- package/lib/properties.js +0 -1672
- package/lib/utils/getBasicPropertyDescriptor.js +0 -14
|
@@ -1,38 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
module.exports.isValid = function parse(v) {
|
|
20
|
-
return typeof v === 'string' && (v === '' || styles.indexOf(v) !== -1);
|
|
5
|
+
module.exports.parse = function parse(v) {
|
|
6
|
+
const keywords = [
|
|
7
|
+
"none",
|
|
8
|
+
"hidden",
|
|
9
|
+
"dotted",
|
|
10
|
+
"dashed",
|
|
11
|
+
"solid",
|
|
12
|
+
"double",
|
|
13
|
+
"groove",
|
|
14
|
+
"ridge",
|
|
15
|
+
"inset",
|
|
16
|
+
"outset"
|
|
17
|
+
];
|
|
18
|
+
return parsers.parseKeyword(v, keywords);
|
|
21
19
|
};
|
|
22
|
-
var isValid = module.exports.isValid;
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
return
|
|
21
|
+
module.exports.isValid = function isValid(v) {
|
|
22
|
+
if (v === "") {
|
|
23
|
+
return true;
|
|
27
24
|
}
|
|
28
|
-
return
|
|
25
|
+
return typeof module.exports.parse(v) === "string";
|
|
29
26
|
};
|
|
30
27
|
|
|
31
28
|
module.exports.definition = {
|
|
32
|
-
set
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
set(v) {
|
|
30
|
+
v = parsers.prepareValue(v, this._global);
|
|
31
|
+
if (v.toLowerCase() === "none") {
|
|
32
|
+
v = "";
|
|
33
|
+
}
|
|
34
|
+
if (parsers.hasVarFunc(v)) {
|
|
35
|
+
this._setProperty("border", "");
|
|
36
|
+
this._setProperty("border-style", v);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const positions = ["top", "right", "bottom", "left"];
|
|
40
|
+
this._implicitSetter(
|
|
41
|
+
"border",
|
|
42
|
+
"style",
|
|
43
|
+
v,
|
|
44
|
+
module.exports.isValid,
|
|
45
|
+
module.exports.parse,
|
|
46
|
+
positions
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
get() {
|
|
50
|
+
return this.getPropertyValue("border-style");
|
|
35
51
|
},
|
|
36
52
|
enumerable: true,
|
|
37
|
-
configurable: true
|
|
53
|
+
configurable: true
|
|
38
54
|
};
|
|
@@ -1,17 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const parsers = require("../parsers");
|
|
4
|
+
const borderTopWidth = require("./borderTopWidth");
|
|
5
|
+
const borderTopStyle = require("./borderTopStyle");
|
|
6
|
+
const borderTopColor = require("./borderTopColor");
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const shorthandFor = new Map([
|
|
9
|
+
["border-top-width", borderTopWidth],
|
|
10
|
+
["border-top-style", borderTopStyle],
|
|
11
|
+
["border-top-color", borderTopColor]
|
|
12
|
+
]);
|
|
11
13
|
|
|
12
14
|
module.exports.definition = {
|
|
13
|
-
set
|
|
14
|
-
|
|
15
|
+
set(v) {
|
|
16
|
+
v = parsers.prepareValue(v, this._global);
|
|
17
|
+
if (parsers.hasVarFunc(v)) {
|
|
18
|
+
for (const [key] of shorthandFor) {
|
|
19
|
+
this._setProperty(key, "");
|
|
20
|
+
}
|
|
21
|
+
this._setProperty("border", "");
|
|
22
|
+
this._setProperty("border-top", v);
|
|
23
|
+
} else {
|
|
24
|
+
this._shorthandSetter("border-top", v, shorthandFor);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
get() {
|
|
28
|
+
let val = this.getPropertyValue("border-top");
|
|
29
|
+
if (parsers.hasVarFunc(val)) {
|
|
30
|
+
return val;
|
|
31
|
+
}
|
|
32
|
+
val = this._shorthandGetter("border-top", shorthandFor);
|
|
33
|
+
if (parsers.hasVarFunc(val)) {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
return val;
|
|
37
|
+
},
|
|
15
38
|
enumerable: true,
|
|
16
|
-
configurable: true
|
|
39
|
+
configurable: true
|
|
17
40
|
};
|
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const parsers = require("../parsers");
|
|
4
|
+
|
|
5
|
+
module.exports.parse = function parse(v) {
|
|
6
|
+
const val = parsers.parseColor(v);
|
|
7
|
+
if (val) {
|
|
8
|
+
return val;
|
|
9
|
+
}
|
|
10
|
+
return parsers.parseKeyword(v);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports.isValid = function isValid(v) {
|
|
14
|
+
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return parsers.isValidColor(v);
|
|
18
|
+
};
|
|
4
19
|
|
|
5
20
|
module.exports.definition = {
|
|
6
|
-
set
|
|
7
|
-
|
|
8
|
-
|
|
21
|
+
set(v) {
|
|
22
|
+
v = parsers.prepareValue(v, this._global);
|
|
23
|
+
if (parsers.hasVarFunc(v)) {
|
|
24
|
+
this._setProperty("border", "");
|
|
25
|
+
this._setProperty("border-top", "");
|
|
26
|
+
this._setProperty("border-color", "");
|
|
9
27
|
}
|
|
28
|
+
this._setProperty("border-top-color", module.exports.parse(v));
|
|
10
29
|
},
|
|
11
|
-
get
|
|
12
|
-
return this.getPropertyValue(
|
|
30
|
+
get() {
|
|
31
|
+
return this.getPropertyValue("border-top-color");
|
|
13
32
|
},
|
|
14
33
|
enumerable: true,
|
|
15
|
-
configurable: true
|
|
34
|
+
configurable: true
|
|
16
35
|
};
|
|
@@ -1,21 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const parsers = require("../parsers");
|
|
4
|
+
|
|
5
|
+
module.exports.parse = function parse(v) {
|
|
6
|
+
const keywords = [
|
|
7
|
+
"none",
|
|
8
|
+
"hidden",
|
|
9
|
+
"dotted",
|
|
10
|
+
"dashed",
|
|
11
|
+
"solid",
|
|
12
|
+
"double",
|
|
13
|
+
"groove",
|
|
14
|
+
"ridge",
|
|
15
|
+
"inset",
|
|
16
|
+
"outset"
|
|
17
|
+
];
|
|
18
|
+
return parsers.parseKeyword(v, keywords);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports.isValid = function isValid(v) {
|
|
22
|
+
if (v === "") {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return typeof module.exports.parse(v) === "string";
|
|
26
|
+
};
|
|
5
27
|
|
|
6
28
|
module.exports.definition = {
|
|
7
|
-
set
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this._setProperty(
|
|
29
|
+
set(v) {
|
|
30
|
+
v = parsers.prepareValue(v, this._global);
|
|
31
|
+
const val = module.exports.parse(v);
|
|
32
|
+
if (val === "none" || val === "hidden" || v === "") {
|
|
33
|
+
this._setProperty("border-top-style", "");
|
|
34
|
+
this._setProperty("border-top-color", "");
|
|
35
|
+
this._setProperty("border-top-width", "");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (parsers.hasVarFunc(v)) {
|
|
39
|
+
this._setProperty("border", "");
|
|
40
|
+
this._setProperty("border-top", "");
|
|
41
|
+
this._setProperty("border-style", "");
|
|
14
42
|
}
|
|
43
|
+
this._setProperty("border-top-style", val);
|
|
15
44
|
},
|
|
16
|
-
get
|
|
17
|
-
return this.getPropertyValue(
|
|
45
|
+
get() {
|
|
46
|
+
return this.getPropertyValue("border-top-style");
|
|
18
47
|
},
|
|
19
48
|
enumerable: true,
|
|
20
|
-
configurable: true
|
|
49
|
+
configurable: true
|
|
21
50
|
};
|
|
@@ -1,17 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const parsers = require("../parsers");
|
|
4
|
+
|
|
5
|
+
module.exports.parse = function parse(v) {
|
|
6
|
+
const keywords = ["thin", "medium", "thick"];
|
|
7
|
+
const key = parsers.parseKeyword(v, keywords);
|
|
8
|
+
if (key) {
|
|
9
|
+
return key;
|
|
10
|
+
}
|
|
11
|
+
return parsers.parseLength(v, true);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports.isValid = function isValid(v) {
|
|
15
|
+
if (v === "") {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return typeof module.exports.parse(v) === "string";
|
|
19
|
+
};
|
|
5
20
|
|
|
6
21
|
module.exports.definition = {
|
|
7
|
-
set
|
|
8
|
-
|
|
9
|
-
|
|
22
|
+
set(v) {
|
|
23
|
+
v = parsers.prepareValue(v, this._global);
|
|
24
|
+
if (parsers.hasVarFunc(v)) {
|
|
25
|
+
this._setProperty("border", "");
|
|
26
|
+
this._setProperty("border-top", "");
|
|
27
|
+
this._setProperty("border-width", "");
|
|
10
28
|
}
|
|
29
|
+
this._setProperty("border-top-width", module.exports.parse(v));
|
|
11
30
|
},
|
|
12
|
-
get
|
|
13
|
-
return this.getPropertyValue(
|
|
31
|
+
get() {
|
|
32
|
+
return this.getPropertyValue("border-top-width");
|
|
14
33
|
},
|
|
15
34
|
enumerable: true,
|
|
16
|
-
configurable: true
|
|
35
|
+
configurable: true
|
|
17
36
|
};
|
|
@@ -1,46 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var implicitSetter = require('../parsers').implicitSetter;
|
|
3
|
+
const parsers = require("../parsers");
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (length !== undefined) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
if (typeof v !== 'string') {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
if (v === '') {
|
|
18
|
-
return true;
|
|
5
|
+
module.exports.parse = function parse(v) {
|
|
6
|
+
const keywords = ["thin", "medium", "thick"];
|
|
7
|
+
const key = parsers.parseKeyword(v, keywords);
|
|
8
|
+
if (key) {
|
|
9
|
+
return key;
|
|
19
10
|
}
|
|
20
|
-
|
|
21
|
-
if (widths.indexOf(v) === -1) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
11
|
+
return parsers.parseLength(v, true);
|
|
25
12
|
};
|
|
26
|
-
var isValid = module.exports.isValid;
|
|
27
13
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return length;
|
|
32
|
-
}
|
|
33
|
-
if (isValid(v)) {
|
|
34
|
-
return v.toLowerCase();
|
|
14
|
+
module.exports.isValid = function isValid(v) {
|
|
15
|
+
if (v === "") {
|
|
16
|
+
return true;
|
|
35
17
|
}
|
|
36
|
-
return
|
|
18
|
+
return typeof module.exports.parse(v) === "string";
|
|
37
19
|
};
|
|
38
20
|
|
|
39
21
|
module.exports.definition = {
|
|
40
|
-
set
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
set(v) {
|
|
23
|
+
v = parsers.prepareValue(v, this._global);
|
|
24
|
+
if (parsers.hasVarFunc(v)) {
|
|
25
|
+
this._setProperty("border", "");
|
|
26
|
+
this._setProperty("border-width", v);
|
|
27
|
+
} else {
|
|
28
|
+
const positions = ["top", "right", "bottom", "left"];
|
|
29
|
+
this._implicitSetter(
|
|
30
|
+
"border",
|
|
31
|
+
"width",
|
|
32
|
+
v,
|
|
33
|
+
module.exports.isValid,
|
|
34
|
+
module.exports.parse,
|
|
35
|
+
positions
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
get() {
|
|
40
|
+
return this.getPropertyValue("border-width");
|
|
43
41
|
},
|
|
44
42
|
enumerable: true,
|
|
45
|
-
configurable: true
|
|
43
|
+
configurable: true
|
|
46
44
|
};
|
package/lib/properties/bottom.js
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const parsers = require("../parsers");
|
|
4
|
+
|
|
5
|
+
module.exports.parse = function parse(v) {
|
|
6
|
+
const dim = parsers.parseMeasurement(v);
|
|
7
|
+
if (dim) {
|
|
8
|
+
return dim;
|
|
9
|
+
}
|
|
10
|
+
return parsers.parseKeyword(v, ["auto"]);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports.isValid = function isValid(v) {
|
|
14
|
+
if (v === "") {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return typeof module.exports.parse(v) === "string";
|
|
18
|
+
};
|
|
4
19
|
|
|
5
20
|
module.exports.definition = {
|
|
6
|
-
set
|
|
7
|
-
|
|
21
|
+
set(v) {
|
|
22
|
+
v = parsers.prepareValue(v, this._global);
|
|
23
|
+
this._setProperty("bottom", module.exports.parse(v));
|
|
8
24
|
},
|
|
9
|
-
get
|
|
10
|
-
return this.getPropertyValue(
|
|
25
|
+
get() {
|
|
26
|
+
return this.getPropertyValue("bottom");
|
|
11
27
|
},
|
|
12
28
|
enumerable: true,
|
|
13
|
-
configurable: true
|
|
29
|
+
configurable: true
|
|
14
30
|
};
|
package/lib/properties/clear.js
CHANGED
|
@@ -1,16 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const parsers = require("../parsers");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
module.exports.parse = function parse(v) {
|
|
6
|
+
const keywords = [
|
|
7
|
+
"inline-start",
|
|
8
|
+
"inline-end",
|
|
9
|
+
"block-start",
|
|
10
|
+
"block-end",
|
|
11
|
+
"left",
|
|
12
|
+
"right",
|
|
13
|
+
"top",
|
|
14
|
+
"bottom",
|
|
15
|
+
"both-inline",
|
|
16
|
+
"both-block",
|
|
17
|
+
"both",
|
|
18
|
+
"none"
|
|
19
|
+
];
|
|
20
|
+
return parsers.parseKeyword(v, keywords);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports.isValid = function isValid(v) {
|
|
24
|
+
if (v === "") {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return typeof module.exports.parse(v) === "string";
|
|
28
|
+
};
|
|
6
29
|
|
|
7
30
|
module.exports.definition = {
|
|
8
|
-
set
|
|
9
|
-
|
|
31
|
+
set(v) {
|
|
32
|
+
v = parsers.prepareValue(v, this._global);
|
|
33
|
+
this._setProperty("clear", module.exports.parse(v));
|
|
10
34
|
},
|
|
11
|
-
get
|
|
12
|
-
return this.getPropertyValue(
|
|
35
|
+
get() {
|
|
36
|
+
return this.getPropertyValue("clear");
|
|
13
37
|
},
|
|
14
38
|
enumerable: true,
|
|
15
|
-
configurable: true
|
|
39
|
+
configurable: true
|
|
16
40
|
};
|
package/lib/properties/clip.js
CHANGED
|
@@ -1,47 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// deprecated
|
|
3
|
+
// @see https://drafts.fxtf.org/css-masking/#clip-property
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
const parsers = require("../parsers");
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (val === '' || val === null) {
|
|
9
|
-
return val;
|
|
10
|
-
}
|
|
11
|
-
if (typeof val !== 'string') {
|
|
12
|
-
return undefined;
|
|
7
|
+
module.exports.parse = function parse(v) {
|
|
8
|
+
if (v === "") {
|
|
9
|
+
return v;
|
|
13
10
|
}
|
|
14
|
-
val =
|
|
15
|
-
if (val
|
|
11
|
+
const val = parsers.parseKeyword(v, ["auto"]);
|
|
12
|
+
if (val) {
|
|
16
13
|
return val;
|
|
17
14
|
}
|
|
18
|
-
|
|
15
|
+
// parse legacy <shape>
|
|
16
|
+
v = v.toLowerCase();
|
|
17
|
+
const matches = v.match(/^rect\(\s*(.*)\s*\)$/);
|
|
19
18
|
if (!matches) {
|
|
20
|
-
return
|
|
19
|
+
return;
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
const parts = matches[1].split(/\s*,\s*/);
|
|
23
22
|
if (parts.length !== 4) {
|
|
24
|
-
return
|
|
23
|
+
return;
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const valid = parts.every(function (part, index) {
|
|
26
|
+
const measurement = parsers.parseMeasurement(part.trim());
|
|
28
27
|
parts[index] = measurement;
|
|
29
|
-
return measurement
|
|
28
|
+
return typeof measurement === "string";
|
|
30
29
|
});
|
|
31
30
|
if (!valid) {
|
|
32
|
-
return
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
return `rect(${parts.join(", ")})`;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
module.exports.isValid = function isValid(v) {
|
|
37
|
+
if (v === "") {
|
|
38
|
+
return true;
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
return val.replace(matches[1], parts);
|
|
40
|
+
return typeof module.exports.parse(v) === "string";
|
|
36
41
|
};
|
|
37
42
|
|
|
38
43
|
module.exports.definition = {
|
|
39
|
-
set
|
|
40
|
-
|
|
44
|
+
set(v) {
|
|
45
|
+
v = parsers.prepareValue(v, this._global);
|
|
46
|
+
this._setProperty("clip", module.exports.parse(v));
|
|
41
47
|
},
|
|
42
|
-
get
|
|
43
|
-
return this.getPropertyValue(
|
|
48
|
+
get() {
|
|
49
|
+
return this.getPropertyValue("clip");
|
|
44
50
|
},
|
|
45
51
|
enumerable: true,
|
|
46
|
-
configurable: true
|
|
52
|
+
configurable: true
|
|
47
53
|
};
|
package/lib/properties/color.js
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const parsers = require("../parsers");
|
|
4
|
+
|
|
5
|
+
module.exports.parse = function parse(v) {
|
|
6
|
+
const val = parsers.parseColor(v);
|
|
7
|
+
if (val) {
|
|
8
|
+
return val;
|
|
9
|
+
}
|
|
10
|
+
return parsers.parseKeyword(v);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports.isValid = function isValid(v) {
|
|
14
|
+
if (v === "" || typeof parsers.parseKeyword(v) === "string") {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return parsers.isValidColor(v);
|
|
18
|
+
};
|
|
4
19
|
|
|
5
20
|
module.exports.definition = {
|
|
6
|
-
set
|
|
7
|
-
|
|
21
|
+
set(v) {
|
|
22
|
+
v = parsers.prepareValue(v, this._global);
|
|
23
|
+
this._setProperty("color", module.exports.parse(v));
|
|
8
24
|
},
|
|
9
|
-
get
|
|
10
|
-
return this.getPropertyValue(
|
|
25
|
+
get() {
|
|
26
|
+
return this.getPropertyValue("color");
|
|
11
27
|
},
|
|
12
28
|
enumerable: true,
|
|
13
|
-
configurable: true
|
|
29
|
+
configurable: true
|
|
14
30
|
};
|