cssstyle 4.3.1 → 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 +382 -547
  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,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('-webkit-column-rule-color', parseColor(v));
21
+ set(v) {
22
+ v = parsers.prepareValue(v, this._global);
23
+ this._setProperty("-webkit-column-rule-color", module.exports.parse(v));
8
24
  },
9
- get: function () {
10
- return this.getPropertyValue('-webkit-column-rule-color');
25
+ get() {
26
+ return this.getPropertyValue("-webkit-column-rule-color");
11
27
  },
12
28
  enumerable: true,
13
- configurable: true,
29
+ configurable: true
14
30
  };
@@ -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('-webkit-tap-highlight-color', parseColor(v));
21
+ set(v) {
22
+ v = parsers.prepareValue(v, this._global);
23
+ this._setProperty("-webkit-tap-highlight-color", module.exports.parse(v));
8
24
  },
9
- get: function () {
10
- return this.getPropertyValue('-webkit-tap-highlight-color');
25
+ get() {
26
+ return this.getPropertyValue("-webkit-tap-highlight-color");
11
27
  },
12
28
  enumerable: true,
13
- configurable: true,
29
+ configurable: true
14
30
  };
@@ -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('-webkit-text-emphasis-color', parseColor(v));
21
+ set(v) {
22
+ v = parsers.prepareValue(v, this._global);
23
+ this._setProperty("-webkit-text-emphasis-color", module.exports.parse(v));
8
24
  },
9
- get: function () {
10
- return this.getPropertyValue('-webkit-text-emphasis-color');
25
+ get() {
26
+ return this.getPropertyValue("-webkit-text-emphasis-color");
11
27
  },
12
28
  enumerable: true,
13
- configurable: true,
29
+ configurable: true
14
30
  };
@@ -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('-webkit-text-fill-color', parseColor(v));
21
+ set(v) {
22
+ v = parsers.prepareValue(v, this._global);
23
+ this._setProperty("-webkit-text-fill-color", module.exports.parse(v));
8
24
  },
9
- get: function () {
10
- return this.getPropertyValue('-webkit-text-fill-color');
25
+ get() {
26
+ return this.getPropertyValue("-webkit-text-fill-color");
11
27
  },
12
28
  enumerable: true,
13
- configurable: true,
29
+ configurable: true
14
30
  };
@@ -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('-webkit-text-stroke-color', parseColor(v));
21
+ set(v) {
22
+ v = parsers.prepareValue(v, this._global);
23
+ this._setProperty("-webkit-text-stroke-color", module.exports.parse(v));
8
24
  },
9
- get: function () {
10
- return this.getPropertyValue('-webkit-text-stroke-color');
25
+ get() {
26
+ return this.getPropertyValue("-webkit-text-stroke-color");
11
27
  },
12
28
  enumerable: true,
13
- configurable: true,
29
+ configurable: true
14
30
  };
@@ -1,24 +1,31 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var parseMeasurement = require('../parsers').parseMeasurement;
3
+ const parsers = require("../parsers");
4
4
 
5
- function parse(v) {
6
- if (String(v).toLowerCase() === 'auto') {
7
- return 'auto';
5
+ module.exports.parse = function parse(v) {
6
+ const dim = parsers.parseMeasurement(v, true);
7
+ if (dim) {
8
+ return dim;
8
9
  }
9
- if (String(v).toLowerCase() === 'inherit') {
10
- return 'inherit';
10
+ const keywords = ["auto", "min-content", "max-content", "fit-content"];
11
+ return parsers.parseKeyword(v, keywords);
12
+ };
13
+
14
+ module.exports.isValid = function isValid(v) {
15
+ if (v === "") {
16
+ return true;
11
17
  }
12
- return parseMeasurement(v);
13
- }
18
+ return typeof module.exports.parse(v) === "string";
19
+ };
14
20
 
15
21
  module.exports.definition = {
16
- set: function (v) {
17
- this._setProperty('width', parse(v));
22
+ set(v) {
23
+ v = parsers.prepareValue(v, this._global);
24
+ this._setProperty("width", module.exports.parse(v));
18
25
  },
19
- get: function () {
20
- return this.getPropertyValue('width');
26
+ get() {
27
+ return this.getPropertyValue("width");
21
28
  },
22
29
  enumerable: true,
23
- configurable: true,
30
+ configurable: true
24
31
  };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ // Utility to translate from `border-width` to `borderWidth`.
4
+ // NOTE: For values prefixed with webkit, e.g. `-webkit-foo`, we need to provide
5
+ // both `webkitFoo` and `WebkitFoo`. Here we only return `webkitFoo`.
6
+ exports.dashedToCamelCase = function (dashed) {
7
+ if (dashed.startsWith("--")) {
8
+ return dashed;
9
+ }
10
+ let camel = "";
11
+ let nextCap = false;
12
+ // skip leading hyphen in vendor prefixed value, e.g. -webkit-foo
13
+ let i = /^-webkit-/.test(dashed) ? 1 : 0;
14
+ for (; i < dashed.length; i++) {
15
+ if (dashed[i] !== "-") {
16
+ camel += nextCap ? dashed[i].toUpperCase() : dashed[i];
17
+ nextCap = false;
18
+ } else {
19
+ nextCap = true;
20
+ }
21
+ }
22
+ return camel;
23
+ };
24
+
25
+ // Utility to translate from `borderWidth` to `border-width`.
26
+ exports.camelCaseToDashed = function (camelCase) {
27
+ if (camelCase.startsWith("--")) {
28
+ return camelCase;
29
+ }
30
+ const dashed = camelCase.replace(/(?<=[a-z])[A-Z]/g, "-$&").toLowerCase();
31
+ if (/^webkit-/.test(dashed)) {
32
+ return `-${dashed}`;
33
+ }
34
+ return dashed;
35
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ const prepareValue = require("../parsers").prepareValue;
4
+
5
+ module.exports.getPropertyDescriptor = function getPropertyDescriptor(property) {
6
+ return {
7
+ set(v) {
8
+ this._setProperty(property, prepareValue(v));
9
+ },
10
+ get() {
11
+ return this.getPropertyValue(property);
12
+ },
13
+ enumerable: true,
14
+ configurable: true
15
+ };
16
+ };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "CSSStyleDeclaration",
7
7
  "StyleSheet"
8
8
  ],
9
- "version": "4.3.1",
9
+ "version": "4.4.0",
10
10
  "homepage": "https://github.com/jsdom/cssstyle",
11
11
  "maintainers": [
12
12
  {
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "main": "./lib/CSSStyleDeclaration.js",
39
39
  "dependencies": {
40
- "@asamuzakjp/css-color": "^3.1.2",
40
+ "@asamuzakjp/css-color": "^3.2.0",
41
41
  "rrweb-cssom": "^0.8.0"
42
42
  },
43
43
  "devDependencies": {
@@ -45,6 +45,7 @@
45
45
  "@babel/parser": "^7.26.9",
46
46
  "@babel/traverse": "^7.26.9",
47
47
  "@babel/types": "^7.26.9",
48
+ "@domenic/eslint-config": "^4.0.1",
48
49
  "eslint": "^9.22.0",
49
50
  "eslint-config-prettier": "^10.1.1",
50
51
  "eslint-plugin-prettier": "^5.2.3",
@@ -54,10 +55,10 @@
54
55
  "resolve": "^1.22.10"
55
56
  },
56
57
  "scripts": {
57
- "download": "node ./scripts/downloadLatestProperties.mjs && eslint lib/allProperties.js --fix",
58
+ "download": "node ./scripts/downloadLatestProperties.mjs",
58
59
  "generate": "run-p generate:*",
59
60
  "generate:implemented_properties": "node ./scripts/generateImplementedProperties.mjs",
60
- "generate:properties": "node ./scripts/generate_properties.js",
61
+ "generate:properties": "node ./scripts/generateProperties.js",
61
62
  "lint": "npm run generate && eslint --max-warnings 0",
62
63
  "lint:fix": "eslint --fix --max-warnings 0",
63
64
  "prepublishOnly": "npm run lint && npm run test",