cssstyle 2.3.0 → 4.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.
Files changed (86) hide show
  1. package/README.md +3 -3
  2. package/lib/CSSStyleDeclaration.js +31 -25
  3. package/lib/CSSStyleDeclaration.test.js +187 -6
  4. package/lib/allProperties.js +66 -9
  5. package/lib/allWebkitProperties.js +1 -1
  6. package/lib/implementedProperties.js +1 -1
  7. package/lib/parsers.js +43 -30
  8. package/lib/parsers.test.js +8 -1
  9. package/lib/properties/azimuth.js +3 -6
  10. package/lib/properties/backgroundAttachment.js +2 -2
  11. package/lib/properties/backgroundColor.js +2 -2
  12. package/lib/properties/backgroundImage.js +2 -2
  13. package/lib/properties/backgroundPosition.js +3 -3
  14. package/lib/properties/backgroundRepeat.js +2 -2
  15. package/lib/properties/border.js +1 -1
  16. package/lib/properties/borderBottomColor.js +2 -2
  17. package/lib/properties/borderBottomStyle.js +2 -2
  18. package/lib/properties/borderBottomWidth.js +2 -2
  19. package/lib/properties/borderCollapse.js +2 -2
  20. package/lib/properties/borderColor.js +2 -2
  21. package/lib/properties/borderLeftColor.js +2 -2
  22. package/lib/properties/borderLeftStyle.js +2 -2
  23. package/lib/properties/borderLeftWidth.js +2 -2
  24. package/lib/properties/borderRightColor.js +2 -2
  25. package/lib/properties/borderRightStyle.js +2 -2
  26. package/lib/properties/borderRightWidth.js +2 -2
  27. package/lib/properties/borderSpacing.js +3 -3
  28. package/lib/properties/borderStyle.js +2 -2
  29. package/lib/properties/borderTopColor.js +2 -2
  30. package/lib/properties/borderTopStyle.js +2 -2
  31. package/lib/properties/borderTopWidth.js +2 -2
  32. package/lib/properties/borderWidth.js +2 -2
  33. package/lib/properties/bottom.js +2 -2
  34. package/lib/properties/clear.js +2 -2
  35. package/lib/properties/clip.js +4 -4
  36. package/lib/properties/color.js +2 -2
  37. package/lib/properties/cssFloat.js +2 -2
  38. package/lib/properties/flex.js +2 -4
  39. package/lib/properties/flexBasis.js +2 -2
  40. package/lib/properties/flexGrow.js +2 -2
  41. package/lib/properties/flexShrink.js +2 -2
  42. package/lib/properties/float.js +2 -2
  43. package/lib/properties/floodColor.js +2 -2
  44. package/lib/properties/font.js +1 -1
  45. package/lib/properties/fontFamily.js +2 -2
  46. package/lib/properties/fontSize.js +4 -4
  47. package/lib/properties/fontStyle.js +3 -3
  48. package/lib/properties/fontVariant.js +2 -2
  49. package/lib/properties/fontWeight.js +2 -2
  50. package/lib/properties/height.js +2 -2
  51. package/lib/properties/left.js +2 -2
  52. package/lib/properties/lightingColor.js +2 -2
  53. package/lib/properties/lineHeight.js +2 -2
  54. package/lib/properties/margin.js +10 -6
  55. package/lib/properties/marginBottom.js +1 -1
  56. package/lib/properties/marginLeft.js +1 -1
  57. package/lib/properties/marginRight.js +1 -1
  58. package/lib/properties/marginTop.js +1 -1
  59. package/lib/properties/opacity.js +2 -2
  60. package/lib/properties/outlineColor.js +2 -2
  61. package/lib/properties/padding.js +10 -6
  62. package/lib/properties/paddingBottom.js +1 -1
  63. package/lib/properties/paddingLeft.js +1 -1
  64. package/lib/properties/paddingRight.js +1 -1
  65. package/lib/properties/paddingTop.js +1 -1
  66. package/lib/properties/right.js +2 -2
  67. package/lib/properties/stopColor.js +2 -2
  68. package/lib/properties/textLineThroughColor.js +2 -2
  69. package/lib/properties/textOverlineColor.js +2 -2
  70. package/lib/properties/textUnderlineColor.js +2 -2
  71. package/lib/properties/top.js +2 -2
  72. package/lib/properties/webkitBorderAfterColor.js +2 -2
  73. package/lib/properties/webkitBorderBeforeColor.js +2 -2
  74. package/lib/properties/webkitBorderEndColor.js +2 -2
  75. package/lib/properties/webkitBorderStartColor.js +2 -2
  76. package/lib/properties/webkitColumnRuleColor.js +2 -2
  77. package/lib/properties/webkitMatchNearestMailBlockquoteColor.js +2 -2
  78. package/lib/properties/webkitTapHighlightColor.js +2 -2
  79. package/lib/properties/webkitTextEmphasisColor.js +2 -2
  80. package/lib/properties/webkitTextFillColor.js +2 -2
  81. package/lib/properties/webkitTextStrokeColor.js +2 -2
  82. package/lib/properties/width.js +2 -2
  83. package/lib/properties.js +11 -3
  84. package/lib/utils/colorSpace.js +13 -15
  85. package/lib/utils/getBasicPropertyDescriptor.js +2 -2
  86. package/package.json +14 -15
@@ -3,10 +3,10 @@
3
3
  var parseColor = require('../parsers').parseColor;
4
4
 
5
5
  module.exports.definition = {
6
- set: function(v) {
6
+ set: function (v) {
7
7
  this._setProperty('-webkit-column-rule-color', parseColor(v));
8
8
  },
9
- get: function() {
9
+ get: function () {
10
10
  return this.getPropertyValue('-webkit-column-rule-color');
11
11
  },
12
12
  enumerable: true,
@@ -3,10 +3,10 @@
3
3
  var parseColor = require('../parsers').parseColor;
4
4
 
5
5
  module.exports.definition = {
6
- set: function(v) {
6
+ set: function (v) {
7
7
  this._setProperty('-webkit-match-nearest-mail-blockquote-color', parseColor(v));
8
8
  },
9
- get: function() {
9
+ get: function () {
10
10
  return this.getPropertyValue('-webkit-match-nearest-mail-blockquote-color');
11
11
  },
12
12
  enumerable: true,
@@ -3,10 +3,10 @@
3
3
  var parseColor = require('../parsers').parseColor;
4
4
 
5
5
  module.exports.definition = {
6
- set: function(v) {
6
+ set: function (v) {
7
7
  this._setProperty('-webkit-tap-highlight-color', parseColor(v));
8
8
  },
9
- get: function() {
9
+ get: function () {
10
10
  return this.getPropertyValue('-webkit-tap-highlight-color');
11
11
  },
12
12
  enumerable: true,
@@ -3,10 +3,10 @@
3
3
  var parseColor = require('../parsers').parseColor;
4
4
 
5
5
  module.exports.definition = {
6
- set: function(v) {
6
+ set: function (v) {
7
7
  this._setProperty('-webkit-text-emphasis-color', parseColor(v));
8
8
  },
9
- get: function() {
9
+ get: function () {
10
10
  return this.getPropertyValue('-webkit-text-emphasis-color');
11
11
  },
12
12
  enumerable: true,
@@ -3,10 +3,10 @@
3
3
  var parseColor = require('../parsers').parseColor;
4
4
 
5
5
  module.exports.definition = {
6
- set: function(v) {
6
+ set: function (v) {
7
7
  this._setProperty('-webkit-text-fill-color', parseColor(v));
8
8
  },
9
- get: function() {
9
+ get: function () {
10
10
  return this.getPropertyValue('-webkit-text-fill-color');
11
11
  },
12
12
  enumerable: true,
@@ -3,10 +3,10 @@
3
3
  var parseColor = require('../parsers').parseColor;
4
4
 
5
5
  module.exports.definition = {
6
- set: function(v) {
6
+ set: function (v) {
7
7
  this._setProperty('-webkit-text-stroke-color', parseColor(v));
8
8
  },
9
- get: function() {
9
+ get: function () {
10
10
  return this.getPropertyValue('-webkit-text-stroke-color');
11
11
  },
12
12
  enumerable: true,
@@ -13,10 +13,10 @@ function parse(v) {
13
13
  }
14
14
 
15
15
  module.exports.definition = {
16
- set: function(v) {
16
+ set: function (v) {
17
17
  this._setProperty('width', parse(v));
18
18
  },
19
- get: function() {
19
+ get: function () {
20
20
  return this.getPropertyValue('width');
21
21
  },
22
22
  enumerable: true,
package/lib/properties.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- // autogenerated - 4/29/2020
3
+ // autogenerated - 12/28/2023
4
4
 
5
5
  /*
6
6
  *
@@ -1225,7 +1225,7 @@ var margin_local_var_isValid = function (v) {
1225
1225
  }
1226
1226
 
1227
1227
  var type = external_dependency_parsers_0.valueType(v);
1228
- return type === margin_local_var_TYPES.LENGTH || type === margin_local_var_TYPES.PERCENT || type === margin_local_var_TYPES.INTEGER && (v === '0' || v === 0);
1228
+ return type === margin_local_var_TYPES.NULL_OR_EMPTY_STR || type === margin_local_var_TYPES.LENGTH || type === margin_local_var_TYPES.PERCENT || type === margin_local_var_TYPES.INTEGER && (v === '0' || v === 0);
1229
1229
  };
1230
1230
 
1231
1231
  var margin_local_var_parser = function (v) {
@@ -1250,6 +1250,10 @@ margin_export_definition = {
1250
1250
  v = String(v);
1251
1251
  }
1252
1252
 
1253
+ if (v === null) {
1254
+ v = '';
1255
+ }
1256
+
1253
1257
  if (typeof v !== 'string') {
1254
1258
  return;
1255
1259
  }
@@ -1372,7 +1376,7 @@ var padding_local_var_TYPES = external_dependency_parsers_0.TYPES;
1372
1376
 
1373
1377
  var padding_local_var_isValid = function (v) {
1374
1378
  var type = external_dependency_parsers_0.valueType(v);
1375
- return type === padding_local_var_TYPES.LENGTH || type === padding_local_var_TYPES.PERCENT || type === padding_local_var_TYPES.INTEGER && (v === '0' || v === 0);
1379
+ return type === padding_local_var_TYPES.NULL_OR_EMPTY_STR || type === padding_local_var_TYPES.LENGTH || type === padding_local_var_TYPES.PERCENT || type === padding_local_var_TYPES.INTEGER && (v === '0' || v === 0);
1376
1380
  };
1377
1381
 
1378
1382
  var padding_local_var_parser = function (v) {
@@ -1391,6 +1395,10 @@ padding_export_definition = {
1391
1395
  v = String(v);
1392
1396
  }
1393
1397
 
1398
+ if (v === null) {
1399
+ v = '';
1400
+ }
1401
+
1394
1402
  if (typeof v !== 'string') {
1395
1403
  return;
1396
1404
  }
@@ -1,21 +1,19 @@
1
1
  'use strict';
2
2
 
3
- const hueToRgb = (t1, t2, hue) => {
4
- if (hue < 0) hue += 6;
5
- if (hue >= 6) hue -= 6;
6
-
7
- if (hue < 1) return (t2 - t1) * hue + t1;
8
- else if (hue < 3) return t2;
9
- else if (hue < 4) return (t2 - t1) * (4 - hue) + t1;
10
- else return t1;
11
- };
3
+ const MAX_HUE = 360;
4
+ const COLOR_NB = 12;
5
+ const MAX_RGB_VALUE = 255;
12
6
 
13
7
  // https://www.w3.org/TR/css-color-4/#hsl-to-rgb
14
8
  exports.hslToRgb = (hue, sat, light) => {
15
- const t2 = light <= 0.5 ? light * (sat + 1) : light + sat - light * sat;
16
- const t1 = light * 2 - t2;
17
- const r = hueToRgb(t1, t2, hue + 2);
18
- const g = hueToRgb(t1, t2, hue);
19
- const b = hueToRgb(t1, t2, hue - 2);
20
- return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
9
+ hue = hue % MAX_HUE;
10
+ if (hue < 0) {
11
+ hue += MAX_HUE;
12
+ }
13
+ function f(n) {
14
+ const k = (n + hue / (MAX_HUE / COLOR_NB)) % COLOR_NB;
15
+ const a = sat * Math.min(light, 1 - light);
16
+ return light - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
17
+ }
18
+ return [f(0), f(8), f(4)].map((value) => Math.round(value * MAX_RGB_VALUE));
21
19
  };
@@ -2,10 +2,10 @@
2
2
 
3
3
  module.exports = function getBasicPropertyDescriptor(name) {
4
4
  return {
5
- set: function(v) {
5
+ set: function (v) {
6
6
  this._setProperty(name, v);
7
7
  },
8
- get: function() {
8
+ get: function () {
9
9
  return this.getPropertyValue(name);
10
10
  },
11
11
  enumerable: true,
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "CSSStyleDeclaration",
7
7
  "StyleSheet"
8
8
  ],
9
- "version": "2.3.0",
9
+ "version": "4.0.0",
10
10
  "homepage": "https://github.com/jsdom/cssstyle",
11
11
  "maintainers": [
12
12
  {
@@ -37,21 +37,20 @@
37
37
  ],
38
38
  "main": "./lib/CSSStyleDeclaration.js",
39
39
  "dependencies": {
40
- "cssom": "~0.3.6"
40
+ "rrweb-cssom": "^0.6.0"
41
41
  },
42
42
  "devDependencies": {
43
- "babel-generator": "~6.26.1",
44
- "babel-traverse": "~6.26.0",
45
- "babel-types": "~6.26.0",
46
- "babylon": "~6.18.0",
47
- "eslint": "~6.0.0",
48
- "eslint-config-prettier": "~6.0.0",
49
- "eslint-plugin-prettier": "~3.1.0",
50
- "jest": "^24.8.0",
43
+ "babel-generator": "^6.26.1",
44
+ "babel-traverse": "^6.26.0",
45
+ "babel-types": "^6.26.0",
46
+ "babylon": "^6.18.0",
47
+ "eslint": "^8.56.0",
48
+ "eslint-config-prettier": "^9.1.0",
49
+ "eslint-plugin-prettier": "^5.1.2",
50
+ "jest": "^29.7.0",
51
51
  "npm-run-all": "^4.1.5",
52
- "prettier": "~1.18.0",
53
- "request": "^2.88.0",
54
- "resolve": "~1.11.1"
52
+ "prettier": "^3.1.1",
53
+ "resolve": "^1.22.1"
55
54
  },
56
55
  "scripts": {
57
56
  "download": "node ./scripts/download_latest_properties.js && eslint lib/allProperties.js --fix",
@@ -62,11 +61,11 @@
62
61
  "lint:fix": "eslint . --fix --max-warnings 0",
63
62
  "prepublishOnly": "npm run lint && npm run test",
64
63
  "test": "npm run generate && jest",
65
- "test-ci": "npm run lint && npm run test && codecov",
64
+ "test-ci": "npm run lint && npm run test",
66
65
  "update-authors": "git log --format=\"%aN <%aE>\" | sort -f | uniq > AUTHORS"
67
66
  },
68
67
  "license": "MIT",
69
68
  "engines": {
70
- "node": ">=8"
69
+ "node": ">=18"
71
70
  }
72
71
  }