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.
Files changed (94) hide show
  1. package/lib/CSSStyleDeclaration.js +545 -206
  2. package/lib/allExtraProperties.js +42 -60
  3. package/lib/allWebkitProperties.js +107 -187
  4. package/lib/generated/allProperties.js +615 -0
  5. package/lib/{implementedProperties.js → generated/implementedProperties.js} +11 -18
  6. package/lib/generated/properties.js +2574 -0
  7. package/lib/parsers.js +400 -544
  8. package/lib/properties/background.js +40 -13
  9. package/lib/properties/backgroundAttachment.js +23 -15
  10. package/lib/properties/backgroundColor.js +21 -19
  11. package/lib/properties/backgroundImage.js +19 -14
  12. package/lib/properties/backgroundPosition.js +35 -41
  13. package/lib/properties/backgroundRepeat.js +20 -20
  14. package/lib/properties/border.js +34 -25
  15. package/lib/properties/borderBottom.js +34 -11
  16. package/lib/properties/borderBottomColor.js +27 -8
  17. package/lib/properties/borderBottomStyle.js +42 -13
  18. package/lib/properties/borderBottomWidth.js +28 -8
  19. package/lib/properties/borderCollapse.js +16 -16
  20. package/lib/properties/borderColor.js +32 -18
  21. package/lib/properties/borderLeft.js +34 -11
  22. package/lib/properties/borderLeftColor.js +27 -8
  23. package/lib/properties/borderLeftStyle.js +42 -13
  24. package/lib/properties/borderLeftWidth.js +28 -8
  25. package/lib/properties/borderRight.js +34 -11
  26. package/lib/properties/borderRightColor.js +27 -8
  27. package/lib/properties/borderRightStyle.js +42 -13
  28. package/lib/properties/borderRightWidth.js +28 -8
  29. package/lib/properties/borderSpacing.js +31 -27
  30. package/lib/properties/borderStyle.js +43 -27
  31. package/lib/properties/borderTop.js +34 -11
  32. package/lib/properties/borderTopColor.js +27 -8
  33. package/lib/properties/borderTopStyle.js +42 -13
  34. package/lib/properties/borderTopWidth.js +28 -9
  35. package/lib/properties/borderWidth.js +32 -34
  36. package/lib/properties/bottom.js +23 -7
  37. package/lib/properties/clear.js +32 -8
  38. package/lib/properties/clip.js +33 -27
  39. package/lib/properties/color.js +23 -7
  40. package/lib/properties/flex.js +59 -29
  41. package/lib/properties/flexBasis.js +21 -16
  42. package/lib/properties/flexGrow.js +19 -10
  43. package/lib/properties/flexShrink.js +19 -10
  44. package/lib/properties/float.js +21 -6
  45. package/lib/properties/floodColor.js +23 -7
  46. package/lib/properties/font.js +120 -33
  47. package/lib/properties/fontFamily.js +59 -21
  48. package/lib/properties/fontSize.js +37 -28
  49. package/lib/properties/fontStyle.js +23 -9
  50. package/lib/properties/fontVariant.js +26 -8
  51. package/lib/properties/fontWeight.js +26 -23
  52. package/lib/properties/height.js +21 -14
  53. package/lib/properties/left.js +23 -7
  54. package/lib/properties/lightingColor.js +23 -7
  55. package/lib/properties/lineHeight.js +29 -16
  56. package/lib/properties/margin.js +42 -57
  57. package/lib/properties/marginBottom.js +34 -7
  58. package/lib/properties/marginLeft.js +34 -7
  59. package/lib/properties/marginRight.js +34 -7
  60. package/lib/properties/marginTop.js +34 -7
  61. package/lib/properties/opacity.js +39 -7
  62. package/lib/properties/outlineColor.js +23 -7
  63. package/lib/properties/padding.js +43 -51
  64. package/lib/properties/paddingBottom.js +36 -7
  65. package/lib/properties/paddingLeft.js +34 -7
  66. package/lib/properties/paddingRight.js +34 -7
  67. package/lib/properties/paddingTop.js +34 -7
  68. package/lib/properties/right.js +23 -7
  69. package/lib/properties/stopColor.js +23 -7
  70. package/lib/properties/top.js +23 -7
  71. package/lib/properties/webkitBorderAfterColor.js +23 -7
  72. package/lib/properties/webkitBorderBeforeColor.js +23 -7
  73. package/lib/properties/webkitBorderEndColor.js +23 -7
  74. package/lib/properties/webkitBorderStartColor.js +23 -7
  75. package/lib/properties/webkitColumnRuleColor.js +23 -7
  76. package/lib/properties/webkitTapHighlightColor.js +23 -7
  77. package/lib/properties/webkitTextEmphasisColor.js +23 -7
  78. package/lib/properties/webkitTextFillColor.js +23 -7
  79. package/lib/properties/webkitTextStrokeColor.js +23 -7
  80. package/lib/properties/width.js +21 -14
  81. package/lib/utils/camelize.js +35 -0
  82. package/lib/utils/propertyDescriptors.js +16 -0
  83. package/package.json +5 -4
  84. package/lib/allProperties.js +0 -529
  85. package/lib/constants.js +0 -6
  86. package/lib/named_colors.json +0 -152
  87. package/lib/properties/azimuth.js +0 -64
  88. package/lib/properties/cssFloat.js +0 -12
  89. package/lib/properties/textLineThroughColor.js +0 -14
  90. package/lib/properties/textOverlineColor.js +0 -14
  91. package/lib/properties/textUnderlineColor.js +0 -14
  92. package/lib/properties/webkitMatchNearestMailBlockquoteColor.js +0 -14
  93. package/lib/properties.js +0 -1672
  94. package/lib/utils/getBasicPropertyDescriptor.js +0 -14
@@ -1,38 +1,54 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var implicitSetter = require('../parsers').implicitSetter;
3
+ const parsers = require("../parsers");
4
4
 
5
- // the valid border-styles:
6
- var styles = [
7
- 'none',
8
- 'hidden',
9
- 'dotted',
10
- 'dashed',
11
- 'solid',
12
- 'double',
13
- 'groove',
14
- 'ridge',
15
- 'inset',
16
- 'outset',
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
- var parser = function (v) {
25
- if (isValid(v)) {
26
- return v.toLowerCase();
21
+ module.exports.isValid = function isValid(v) {
22
+ if (v === "") {
23
+ return true;
27
24
  }
28
- return undefined;
25
+ return typeof module.exports.parse(v) === "string";
29
26
  };
30
27
 
31
28
  module.exports.definition = {
32
- set: implicitSetter('border', 'style', isValid, parser),
33
- get: function () {
34
- return this.getPropertyValue('border-style');
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
- 'use strict';
1
+ "use strict";
2
2
 
3
- var shorthandSetter = require('../parsers').shorthandSetter;
4
- var shorthandGetter = require('../parsers').shorthandGetter;
3
+ const parsers = require("../parsers");
4
+ const borderTopWidth = require("./borderTopWidth");
5
+ const borderTopStyle = require("./borderTopStyle");
6
+ const borderTopColor = require("./borderTopColor");
5
7
 
6
- var shorthand_for = {
7
- 'border-top-width': require('./borderTopWidth'),
8
- 'border-top-style': require('./borderTopStyle'),
9
- 'border-top-color': require('./borderTopColor'),
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: shorthandSetter('border-top', shorthand_for),
14
- get: shorthandGetter('border-top', shorthand_for),
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
- 'use strict';
1
+ "use strict";
2
2
 
3
- var isValid = (module.exports.isValid = require('./borderColor').isValid);
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: function (v) {
7
- if (isValid(v)) {
8
- this._setProperty('border-top-color', v);
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: function () {
12
- return this.getPropertyValue('border-top-color');
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
- 'use strict';
1
+ "use strict";
2
2
 
3
- var isValid = require('./borderStyle').isValid;
4
- module.exports.isValid = isValid;
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: function (v) {
8
- if (isValid(v)) {
9
- if (v.toLowerCase() === 'none') {
10
- v = '';
11
- this.removeProperty('border-top-width');
12
- }
13
- this._setProperty('border-top-style', v);
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: function () {
17
- return this.getPropertyValue('border-top-style');
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
- 'use strict';
1
+ "use strict";
2
2
 
3
- var isValid = require('./borderWidth').isValid;
4
- module.exports.isValid = isValid;
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: function (v) {
8
- if (isValid(v)) {
9
- this._setProperty('border-top-width', v);
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: function () {
13
- return this.getPropertyValue('border-top-width');
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
- 'use strict';
1
+ "use strict";
2
2
 
3
- var parsers = require('../parsers');
4
- var implicitSetter = require('../parsers').implicitSetter;
3
+ const parsers = require("../parsers");
5
4
 
6
- // the valid border-widths:
7
- var widths = ['thin', 'medium', 'thick'];
8
-
9
- module.exports.isValid = function parse(v) {
10
- var length = parsers.parseLength(v);
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
- v = v.toLowerCase();
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
- var parser = function (v) {
29
- var length = parsers.parseLength(v);
30
- if (length !== undefined) {
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 undefined;
18
+ return typeof module.exports.parse(v) === "string";
37
19
  };
38
20
 
39
21
  module.exports.definition = {
40
- set: implicitSetter('border', 'width', isValid, parser),
41
- get: function () {
42
- return this.getPropertyValue('border-width');
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
  };
@@ -1,14 +1,30 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var parseMeasurement = require('../parsers').parseInheritingMeasurement;
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: function (v) {
7
- this._setProperty('bottom', parseMeasurement(v));
21
+ set(v) {
22
+ v = parsers.prepareValue(v, this._global);
23
+ this._setProperty("bottom", module.exports.parse(v));
8
24
  },
9
- get: function () {
10
- return this.getPropertyValue('bottom');
25
+ get() {
26
+ return this.getPropertyValue("bottom");
11
27
  },
12
28
  enumerable: true,
13
- configurable: true,
29
+ configurable: true
14
30
  };
@@ -1,16 +1,40 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var parseKeyword = require('../parsers').parseKeyword;
3
+ const parsers = require("../parsers");
4
4
 
5
- var clear_keywords = ['none', 'left', 'right', 'both', 'inherit'];
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: function (v) {
9
- this._setProperty('clear', parseKeyword(v, clear_keywords));
31
+ set(v) {
32
+ v = parsers.prepareValue(v, this._global);
33
+ this._setProperty("clear", module.exports.parse(v));
10
34
  },
11
- get: function () {
12
- return this.getPropertyValue('clear');
35
+ get() {
36
+ return this.getPropertyValue("clear");
13
37
  },
14
38
  enumerable: true,
15
- configurable: true,
39
+ configurable: true
16
40
  };
@@ -1,47 +1,53 @@
1
- 'use strict';
1
+ "use strict";
2
+ // deprecated
3
+ // @see https://drafts.fxtf.org/css-masking/#clip-property
2
4
 
3
- var parseMeasurement = require('../parsers').parseMeasurement;
5
+ const parsers = require("../parsers");
4
6
 
5
- var shape_regex = /^rect\((.*)\)$/i;
6
-
7
- var parse = function (val) {
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 = val.toLowerCase();
15
- if (val === 'auto' || val === 'inherit') {
11
+ const val = parsers.parseKeyword(v, ["auto"]);
12
+ if (val) {
16
13
  return val;
17
14
  }
18
- var matches = val.match(shape_regex);
15
+ // parse legacy <shape>
16
+ v = v.toLowerCase();
17
+ const matches = v.match(/^rect\(\s*(.*)\s*\)$/);
19
18
  if (!matches) {
20
- return undefined;
19
+ return;
21
20
  }
22
- var parts = matches[1].split(/\s*,\s*/);
21
+ const parts = matches[1].split(/\s*,\s*/);
23
22
  if (parts.length !== 4) {
24
- return undefined;
23
+ return;
25
24
  }
26
- var valid = parts.every(function (part, index) {
27
- var measurement = parseMeasurement(part);
25
+ const valid = parts.every(function (part, index) {
26
+ const measurement = parsers.parseMeasurement(part.trim());
28
27
  parts[index] = measurement;
29
- return measurement !== undefined;
28
+ return typeof measurement === "string";
30
29
  });
31
30
  if (!valid) {
32
- return undefined;
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
- parts = parts.join(', ');
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: function (v) {
40
- this._setProperty('clip', parse(v));
44
+ set(v) {
45
+ v = parsers.prepareValue(v, this._global);
46
+ this._setProperty("clip", module.exports.parse(v));
41
47
  },
42
- get: function () {
43
- return this.getPropertyValue('clip');
48
+ get() {
49
+ return this.getPropertyValue("clip");
44
50
  },
45
51
  enumerable: true,
46
- configurable: true,
52
+ configurable: true
47
53
  };
@@ -1,14 +1,30 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var parseColor = require('../parsers').parseColor;
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: function (v) {
7
- this._setProperty('color', parseColor(v));
21
+ set(v) {
22
+ v = parsers.prepareValue(v, this._global);
23
+ this._setProperty("color", module.exports.parse(v));
8
24
  },
9
- get: function () {
10
- return this.getPropertyValue('color');
25
+ get() {
26
+ return this.getPropertyValue("color");
11
27
  },
12
28
  enumerable: true,
13
- configurable: true,
29
+ configurable: true
14
30
  };