cssstyle 5.3.7 → 6.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 (93) hide show
  1. package/lib/CSSStyleDeclaration.js +359 -395
  2. package/lib/generated/.gitkeep +0 -0
  3. package/lib/generated/propertyDefinitions.js +3685 -1498
  4. package/lib/generated/propertyDescriptors.js +1705 -0
  5. package/lib/index.js +9 -0
  6. package/lib/normalize.js +127 -253
  7. package/lib/parsers.js +152 -164
  8. package/lib/properties/background.js +201 -202
  9. package/lib/properties/backgroundAttachment.js +35 -33
  10. package/lib/properties/backgroundClip.js +35 -33
  11. package/lib/properties/backgroundColor.js +26 -24
  12. package/lib/properties/backgroundImage.js +36 -34
  13. package/lib/properties/backgroundOrigin.js +35 -33
  14. package/lib/properties/backgroundPosition.js +57 -57
  15. package/lib/properties/backgroundRepeat.js +40 -37
  16. package/lib/properties/backgroundSize.js +38 -34
  17. package/lib/properties/border.js +41 -34
  18. package/lib/properties/{webkitBorderEndColor.js → borderBlockEndColor.js} +26 -22
  19. package/lib/properties/{webkitBorderAfterColor.js → borderBlockStartColor.js} +26 -22
  20. package/lib/properties/borderBottom.js +40 -36
  21. package/lib/properties/borderBottomColor.js +25 -21
  22. package/lib/properties/borderBottomStyle.js +25 -21
  23. package/lib/properties/borderBottomWidth.js +28 -24
  24. package/lib/properties/borderCollapse.js +25 -21
  25. package/lib/properties/borderColor.js +36 -33
  26. package/lib/properties/{webkitBorderStartColor.js → borderInlineEndColor.js} +26 -22
  27. package/lib/properties/borderInlineStartColor.js +49 -0
  28. package/lib/properties/borderLeft.js +40 -36
  29. package/lib/properties/borderLeftColor.js +25 -21
  30. package/lib/properties/borderLeftStyle.js +25 -21
  31. package/lib/properties/borderLeftWidth.js +28 -24
  32. package/lib/properties/borderRight.js +40 -36
  33. package/lib/properties/borderRightColor.js +25 -21
  34. package/lib/properties/borderRightStyle.js +25 -21
  35. package/lib/properties/borderRightWidth.js +28 -24
  36. package/lib/properties/borderSpacing.js +33 -29
  37. package/lib/properties/borderStyle.js +36 -33
  38. package/lib/properties/borderTop.js +40 -36
  39. package/lib/properties/borderTopColor.js +25 -21
  40. package/lib/properties/borderTopStyle.js +25 -21
  41. package/lib/properties/borderTopWidth.js +28 -24
  42. package/lib/properties/borderWidth.js +36 -33
  43. package/lib/properties/bottom.js +27 -23
  44. package/lib/properties/clear.js +25 -21
  45. package/lib/properties/clip.js +37 -31
  46. package/lib/properties/color.js +25 -21
  47. package/lib/properties/display.js +36 -30
  48. package/lib/properties/flex.js +53 -45
  49. package/lib/properties/flexBasis.js +28 -26
  50. package/lib/properties/flexGrow.js +28 -26
  51. package/lib/properties/flexShrink.js +28 -26
  52. package/lib/properties/float.js +25 -21
  53. package/lib/properties/floodColor.js +25 -21
  54. package/lib/properties/font.js +89 -118
  55. package/lib/properties/fontFamily.js +38 -33
  56. package/lib/properties/fontSize.js +29 -27
  57. package/lib/properties/fontStyle.js +38 -34
  58. package/lib/properties/fontVariant.js +35 -33
  59. package/lib/properties/fontWeight.js +33 -31
  60. package/lib/properties/height.js +28 -24
  61. package/lib/properties/left.js +27 -23
  62. package/lib/properties/lightingColor.js +25 -21
  63. package/lib/properties/lineHeight.js +28 -26
  64. package/lib/properties/margin.js +40 -34
  65. package/lib/properties/marginBottom.js +30 -27
  66. package/lib/properties/marginLeft.js +30 -27
  67. package/lib/properties/marginRight.js +30 -27
  68. package/lib/properties/marginTop.js +30 -27
  69. package/lib/properties/opacity.js +27 -23
  70. package/lib/properties/outlineColor.js +25 -21
  71. package/lib/properties/padding.js +40 -34
  72. package/lib/properties/paddingBottom.js +31 -28
  73. package/lib/properties/paddingLeft.js +31 -28
  74. package/lib/properties/paddingRight.js +31 -28
  75. package/lib/properties/paddingTop.js +31 -28
  76. package/lib/properties/right.js +27 -23
  77. package/lib/properties/stopColor.js +25 -21
  78. package/lib/properties/{webkitBorderBeforeColor.js → textEmphasisColor.js} +26 -22
  79. package/lib/properties/top.js +27 -23
  80. package/lib/properties/webkitTextFillColor.js +25 -21
  81. package/lib/properties/webkitTextStrokeColor.js +25 -21
  82. package/lib/properties/width.js +28 -24
  83. package/lib/utils/propertyDescriptors.js +129 -42
  84. package/lib/utils/strings.js +11 -156
  85. package/package.json +11 -21
  86. package/lib/generated/allProperties.js +0 -653
  87. package/lib/generated/implementedProperties.js +0 -1466
  88. package/lib/generated/properties.js +0 -6637
  89. package/lib/properties/webkitColumnRuleColor.js +0 -45
  90. package/lib/properties/webkitTapHighlightColor.js +0 -45
  91. package/lib/properties/webkitTextEmphasisColor.js +0 -45
  92. package/lib/utils/allExtraProperties.js +0 -155
  93. package/lib/utils/camelize.js +0 -37
@@ -7,31 +7,13 @@ const lineShorthand = "border-style";
7
7
  const positionShorthand = "border-right";
8
8
  const shorthand = "border";
9
9
 
10
- module.exports.parse = (v, opt = {}) => {
11
- const { globalObject } = opt;
12
- if (v === "") {
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
- return parsers.resolveKeywordValue(value);
21
- } else if (typeof value === "string") {
22
- return value;
23
- }
24
- };
25
-
26
- module.exports.definition = {
10
+ const descriptor = {
27
11
  set(v) {
28
12
  v = parsers.prepareValue(v);
29
13
  if (parsers.hasVarFunc(v)) {
30
14
  this._borderSetter(property, v, "");
31
15
  } else {
32
- const val = module.exports.parse(v, {
33
- globalObject: this._global
34
- });
16
+ const val = parse(v);
35
17
  if (typeof val === "string") {
36
18
  const shorthandPriority = this._priorities.get(shorthand);
37
19
  const linePriority = this._priorities.get(lineShorthand);
@@ -51,4 +33,26 @@ module.exports.definition = {
51
33
  configurable: true
52
34
  };
53
35
 
54
- module.exports.property = property;
36
+ /**
37
+ * Parses the border-right-style property value.
38
+ *
39
+ * @param {string} v - The value to parse.
40
+ * @returns {string|undefined} The parsed value or undefined if invalid.
41
+ */
42
+ function parse(v) {
43
+ if (v === "") {
44
+ return v;
45
+ }
46
+ const value = parsers.parsePropertyValue(property, v);
47
+ if (Array.isArray(value) && value.length === 1) {
48
+ return parsers.resolveKeywordValue(value);
49
+ } else if (typeof value === "string") {
50
+ return value;
51
+ }
52
+ }
53
+
54
+ module.exports = {
55
+ descriptor,
56
+ parse,
57
+ property
58
+ };
@@ -7,34 +7,13 @@ const lineShorthand = "border-width";
7
7
  const positionShorthand = "border-right";
8
8
  const shorthand = "border";
9
9
 
10
- module.exports.parse = (v, opt = {}) => {
11
- const { globalObject } = opt;
12
- if (v === "") {
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
- return parsers.resolveNumericValue(value, {
21
- min: 0,
22
- type: "length"
23
- });
24
- } else if (typeof value === "string") {
25
- return value;
26
- }
27
- };
28
-
29
- module.exports.definition = {
10
+ const descriptor = {
30
11
  set(v) {
31
12
  v = parsers.prepareValue(v);
32
13
  if (parsers.hasVarFunc(v)) {
33
14
  this._borderSetter(property, v, "");
34
15
  } else {
35
- const val = module.exports.parse(v, {
36
- globalObject: this._global
37
- });
16
+ const val = parse(v);
38
17
  if (typeof val === "string") {
39
18
  const shorthandPriority = this._priorities.get(shorthand);
40
19
  const linePriority = this._priorities.get(lineShorthand);
@@ -54,4 +33,29 @@ module.exports.definition = {
54
33
  configurable: true
55
34
  };
56
35
 
57
- module.exports.property = property;
36
+ /**
37
+ * Parses the border-right-width property value.
38
+ *
39
+ * @param {string} v - The value to parse.
40
+ * @returns {string|undefined} The parsed value or undefined if invalid.
41
+ */
42
+ function parse(v) {
43
+ if (v === "") {
44
+ return v;
45
+ }
46
+ const value = parsers.parsePropertyValue(property, v);
47
+ if (Array.isArray(value) && value.length === 1) {
48
+ return parsers.resolveNumericValue(value, {
49
+ min: 0,
50
+ type: "length"
51
+ });
52
+ } else if (typeof value === "string") {
53
+ return value;
54
+ }
55
+ }
56
+
57
+ module.exports = {
58
+ descriptor,
59
+ parse,
60
+ property
61
+ };
@@ -4,15 +4,37 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "border-spacing";
6
6
 
7
- module.exports.parse = (v, opt = {}) => {
8
- const { globalObject } = opt;
7
+ const descriptor = {
8
+ set(v) {
9
+ v = parsers.prepareValue(v);
10
+ if (parsers.hasVarFunc(v)) {
11
+ this._setProperty(property, v);
12
+ } else {
13
+ const val = parse(v);
14
+ if (typeof val === "string") {
15
+ const priority = this._priorities.get(property) ?? "";
16
+ this._setProperty(property, val, priority);
17
+ }
18
+ }
19
+ },
20
+ get() {
21
+ return this.getPropertyValue(property);
22
+ },
23
+ enumerable: true,
24
+ configurable: true
25
+ };
26
+
27
+ /**
28
+ * Parses the border-spacing property value.
29
+ *
30
+ * @param {string} v - The value to parse.
31
+ * @returns {string|undefined} The parsed value or undefined if invalid.
32
+ */
33
+ function parse(v) {
9
34
  if (v === "") {
10
35
  return v;
11
36
  }
12
- const value = parsers.parsePropertyValue(property, v, {
13
- globalObject,
14
- inArray: true
15
- });
37
+ const value = parsers.parsePropertyValue(property, v);
16
38
  if (Array.isArray(value) && value.length) {
17
39
  switch (value.length) {
18
40
  case 1: {
@@ -38,28 +60,10 @@ module.exports.parse = (v, opt = {}) => {
38
60
  } else if (typeof value === "string") {
39
61
  return value;
40
62
  }
41
- };
63
+ }
42
64
 
43
- module.exports.definition = {
44
- set(v) {
45
- v = parsers.prepareValue(v);
46
- if (parsers.hasVarFunc(v)) {
47
- this._setProperty(property, v);
48
- } else {
49
- const val = module.exports.parse(v, {
50
- globalObject: this._global
51
- });
52
- if (typeof val === "string") {
53
- const priority = this._priorities.get(property) ?? "";
54
- this._setProperty(property, val, priority);
55
- }
56
- }
57
- },
58
- get() {
59
- return this.getPropertyValue(property);
60
- },
61
- enumerable: true,
62
- configurable: true
65
+ module.exports = {
66
+ descriptor,
67
+ parse,
68
+ property
63
69
  };
64
-
65
- module.exports.property = property;
@@ -9,22 +9,45 @@ const borderLeftStyle = require("./borderLeftStyle");
9
9
  const property = "border-style";
10
10
  const shorthand = "border";
11
11
 
12
- module.exports.shorthandFor = new Map([
12
+ const shorthandFor = new Map([
13
13
  [borderTopStyle.property, borderTopStyle],
14
14
  [borderRightStyle.property, borderRightStyle],
15
15
  [borderBottomStyle.property, borderBottomStyle],
16
16
  [borderLeftStyle.property, borderLeftStyle]
17
17
  ]);
18
18
 
19
- module.exports.parse = (v, opt = {}) => {
20
- const { globalObject } = opt;
19
+ const descriptor = {
20
+ set(v) {
21
+ v = parsers.prepareValue(v);
22
+ if (parsers.hasVarFunc(v)) {
23
+ this._borderSetter(property, v, "");
24
+ } else {
25
+ const val = parse(v);
26
+ if (Array.isArray(val) || typeof val === "string") {
27
+ const priority =
28
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
29
+ this._borderSetter(property, val, priority);
30
+ }
31
+ }
32
+ },
33
+ get() {
34
+ return this.getPropertyValue(property);
35
+ },
36
+ enumerable: true,
37
+ configurable: true
38
+ };
39
+
40
+ /**
41
+ * Parses the border-style property value.
42
+ *
43
+ * @param {string} v - The value to parse.
44
+ * @returns {Array<string>|undefined} The parsed value or undefined if invalid.
45
+ */
46
+ function parse(v) {
21
47
  if (v === "") {
22
48
  return v;
23
49
  }
24
- const values = parsers.parsePropertyValue(property, v, {
25
- globalObject,
26
- inArray: true
27
- });
50
+ const values = parsers.parsePropertyValue(property, v);
28
51
  const parsedValues = [];
29
52
  if (Array.isArray(values) && values.length) {
30
53
  if (values.length > 4) {
@@ -80,31 +103,11 @@ module.exports.parse = (v, opt = {}) => {
80
103
  default:
81
104
  }
82
105
  }
83
- };
106
+ }
84
107
 
85
- module.exports.definition = {
86
- set(v) {
87
- v = parsers.prepareValue(v);
88
- if (parsers.hasVarFunc(v)) {
89
- this._borderSetter(property, v, "");
90
- } else {
91
- const val = module.exports.parse(v, {
92
- globalObject: this._global
93
- });
94
- if (Array.isArray(val) || typeof val === "string") {
95
- const priority =
96
- !this._priorities.get(shorthand) && this._priorities.has(property)
97
- ? this._priorities.get(property)
98
- : "";
99
- this._borderSetter(property, val, priority);
100
- }
101
- }
102
- },
103
- get() {
104
- return this.getPropertyValue(property);
105
- },
106
- enumerable: true,
107
- configurable: true
108
+ module.exports = {
109
+ descriptor,
110
+ parse,
111
+ property,
112
+ shorthandFor
108
113
  };
109
-
110
- module.exports.property = property;
@@ -14,30 +14,53 @@ const subProps = {
14
14
  color: borderTopColor.property
15
15
  };
16
16
 
17
- module.exports.initialValues = new Map([
17
+ const initialValues = new Map([
18
18
  [borderTopWidth.property, "medium"],
19
19
  [borderTopStyle.property, "none"],
20
20
  [borderTopColor.property, "currentcolor"]
21
21
  ]);
22
22
 
23
- module.exports.shorthandFor = new Map([
23
+ const shorthandFor = new Map([
24
24
  [borderTopWidth.property, borderTopWidth],
25
25
  [borderTopStyle.property, borderTopStyle],
26
26
  [borderTopColor.property, borderTopColor]
27
27
  ]);
28
28
 
29
- module.exports.parse = (v, opt = {}) => {
30
- const { globalObject } = opt;
29
+ const descriptor = {
30
+ set(v) {
31
+ v = parsers.prepareValue(v);
32
+ if (parsers.hasVarFunc(v)) {
33
+ this._borderSetter(property, v, "");
34
+ } else {
35
+ const val = parse(v);
36
+ if (val || typeof val === "string") {
37
+ const priority =
38
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
39
+ this._borderSetter(property, val, priority);
40
+ }
41
+ }
42
+ },
43
+ get() {
44
+ return this.getPropertyValue(property);
45
+ },
46
+ enumerable: true,
47
+ configurable: true
48
+ };
49
+
50
+ /**
51
+ * Parses the border-top property value.
52
+ *
53
+ * @param {string} v - The value to parse.
54
+ * @returns {object|string|undefined} The parsed value or undefined if invalid.
55
+ */
56
+ function parse(v) {
31
57
  if (v === "") {
32
58
  return v;
33
59
  }
34
60
  const values = parsers.splitValue(v);
35
61
  const parsedValues = new Map();
36
62
  for (const val of values) {
37
- const value = parsers.parsePropertyValue(property, val, {
38
- globalObject,
39
- inArray: true
40
- });
63
+ const value = parsers.parsePropertyValue(property, val);
41
64
  if (Array.isArray(value) && value.length === 1) {
42
65
  const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues);
43
66
  if (typeof parsedValue === "string") {
@@ -53,14 +76,14 @@ module.exports.parse = (v, opt = {}) => {
53
76
  }
54
77
  }
55
78
  if (parsedValues.size) {
56
- const keys = module.exports.shorthandFor.keys();
79
+ const keys = shorthandFor.keys();
57
80
  const obj = {
58
81
  [borderTopWidth.property]: "medium"
59
82
  };
60
83
  for (const key of keys) {
61
84
  if (parsedValues.has(key)) {
62
85
  const parsedValue = parsedValues.get(key);
63
- if (parsedValue !== module.exports.initialValues.get(key)) {
86
+ if (parsedValue !== initialValues.get(key)) {
64
87
  obj[key] = parsedValues.get(key);
65
88
  if (obj[borderTopWidth.property] && obj[borderTopWidth.property] === "medium") {
66
89
  delete obj[borderTopWidth.property];
@@ -70,31 +93,12 @@ module.exports.parse = (v, opt = {}) => {
70
93
  }
71
94
  return obj;
72
95
  }
73
- };
96
+ }
74
97
 
75
- module.exports.definition = {
76
- set(v) {
77
- v = parsers.prepareValue(v);
78
- if (parsers.hasVarFunc(v)) {
79
- this._borderSetter(property, v, "");
80
- } else {
81
- const val = module.exports.parse(v, {
82
- globalObject: this._global
83
- });
84
- if (val || typeof val === "string") {
85
- const priority =
86
- !this._priorities.get(shorthand) && this._priorities.has(property)
87
- ? this._priorities.get(property)
88
- : "";
89
- this._borderSetter(property, val, priority);
90
- }
91
- }
92
- },
93
- get() {
94
- return this.getPropertyValue(property);
95
- },
96
- enumerable: true,
97
- configurable: true
98
+ module.exports = {
99
+ descriptor,
100
+ initialValues,
101
+ parse,
102
+ property,
103
+ shorthandFor
98
104
  };
99
-
100
- module.exports.property = property;
@@ -7,31 +7,13 @@ const lineShorthand = "border-color";
7
7
  const positionShorthand = "border-top";
8
8
  const shorthand = "border";
9
9
 
10
- module.exports.parse = (v, opt = {}) => {
11
- const { globalObject } = opt;
12
- if (v === "") {
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
- return parsers.resolveColorValue(value);
21
- } else if (typeof value === "string") {
22
- return value;
23
- }
24
- };
25
-
26
- module.exports.definition = {
10
+ const descriptor = {
27
11
  set(v) {
28
12
  v = parsers.prepareValue(v);
29
13
  if (parsers.hasVarFunc(v)) {
30
14
  this._borderSetter(property, v, "");
31
15
  } else {
32
- const val = module.exports.parse(v, {
33
- globalObject: this._global
34
- });
16
+ const val = parse(v);
35
17
  if (typeof val === "string") {
36
18
  const shorthandPriority = this._priorities.get(shorthand);
37
19
  const linePriority = this._priorities.get(lineShorthand);
@@ -51,4 +33,26 @@ module.exports.definition = {
51
33
  configurable: true
52
34
  };
53
35
 
54
- module.exports.property = property;
36
+ /**
37
+ * Parses the border-top-color property value.
38
+ *
39
+ * @param {string} v - The value to parse.
40
+ * @returns {string|undefined} The parsed value or undefined if invalid.
41
+ */
42
+ function parse(v) {
43
+ if (v === "") {
44
+ return v;
45
+ }
46
+ const value = parsers.parsePropertyValue(property, v);
47
+ if (Array.isArray(value) && value.length === 1) {
48
+ return parsers.resolveColorValue(value);
49
+ } else if (typeof value === "string") {
50
+ return value;
51
+ }
52
+ }
53
+
54
+ module.exports = {
55
+ descriptor,
56
+ parse,
57
+ property
58
+ };
@@ -7,31 +7,13 @@ const lineShorthand = "border-style";
7
7
  const positionShorthand = "border-top";
8
8
  const shorthand = "border";
9
9
 
10
- module.exports.parse = (v, opt = {}) => {
11
- const { globalObject } = opt;
12
- if (v === "") {
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
- return parsers.resolveKeywordValue(value);
21
- } else if (typeof value === "string") {
22
- return value;
23
- }
24
- };
25
-
26
- module.exports.definition = {
10
+ const descriptor = {
27
11
  set(v) {
28
12
  v = parsers.prepareValue(v);
29
13
  if (parsers.hasVarFunc(v)) {
30
14
  this._borderSetter(property, v, "");
31
15
  } else {
32
- const val = module.exports.parse(v, {
33
- globalObject: this._global
34
- });
16
+ const val = parse(v);
35
17
  if (typeof val === "string") {
36
18
  const shorthandPriority = this._priorities.get(shorthand);
37
19
  const linePriority = this._priorities.get(lineShorthand);
@@ -51,4 +33,26 @@ module.exports.definition = {
51
33
  configurable: true
52
34
  };
53
35
 
54
- module.exports.property = property;
36
+ /**
37
+ * Parses the border-top-style property value.
38
+ *
39
+ * @param {string} v - The value to parse.
40
+ * @returns {string|undefined} The parsed value or undefined if invalid.
41
+ */
42
+ function parse(v) {
43
+ if (v === "") {
44
+ return v;
45
+ }
46
+ const value = parsers.parsePropertyValue(property, v);
47
+ if (Array.isArray(value) && value.length === 1) {
48
+ return parsers.resolveKeywordValue(value);
49
+ } else if (typeof value === "string") {
50
+ return value;
51
+ }
52
+ }
53
+
54
+ module.exports = {
55
+ descriptor,
56
+ parse,
57
+ property
58
+ };
@@ -7,34 +7,13 @@ const lineShorthand = "border-width";
7
7
  const positionShorthand = "border-top";
8
8
  const shorthand = "border";
9
9
 
10
- module.exports.parse = (v, opt = {}) => {
11
- const { globalObject } = opt;
12
- if (v === "") {
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
- return parsers.resolveNumericValue(value, {
21
- min: 0,
22
- type: "length"
23
- });
24
- } else if (typeof value === "string") {
25
- return value;
26
- }
27
- };
28
-
29
- module.exports.definition = {
10
+ const descriptor = {
30
11
  set(v) {
31
12
  v = parsers.prepareValue(v);
32
13
  if (parsers.hasVarFunc(v)) {
33
14
  this._borderSetter(property, v, "");
34
15
  } else {
35
- const val = module.exports.parse(v, {
36
- globalObject: this._global
37
- });
16
+ const val = parse(v);
38
17
  if (typeof val === "string") {
39
18
  const shorthandPriority = this._priorities.get(shorthand);
40
19
  const linePriority = this._priorities.get(lineShorthand);
@@ -54,4 +33,29 @@ module.exports.definition = {
54
33
  configurable: true
55
34
  };
56
35
 
57
- module.exports.property = property;
36
+ /**
37
+ * Parses the border-top-width property value.
38
+ *
39
+ * @param {string} v - The value to parse.
40
+ * @returns {string|undefined} The parsed value or undefined if invalid.
41
+ */
42
+ function parse(v) {
43
+ if (v === "") {
44
+ return v;
45
+ }
46
+ const value = parsers.parsePropertyValue(property, v);
47
+ if (Array.isArray(value) && value.length === 1) {
48
+ return parsers.resolveNumericValue(value, {
49
+ min: 0,
50
+ type: "length"
51
+ });
52
+ } else if (typeof value === "string") {
53
+ return value;
54
+ }
55
+ }
56
+
57
+ module.exports = {
58
+ descriptor,
59
+ parse,
60
+ property
61
+ };
@@ -9,22 +9,45 @@ const borderLeftWidth = require("./borderLeftWidth");
9
9
  const property = "border-width";
10
10
  const shorthand = "border";
11
11
 
12
- module.exports.shorthandFor = new Map([
12
+ const shorthandFor = new Map([
13
13
  [borderTopWidth.property, borderTopWidth],
14
14
  [borderRightWidth.property, borderRightWidth],
15
15
  [borderBottomWidth.property, borderBottomWidth],
16
16
  [borderLeftWidth.property, borderLeftWidth]
17
17
  ]);
18
18
 
19
- module.exports.parse = (v, opt = {}) => {
20
- const { globalObject } = opt;
19
+ const descriptor = {
20
+ set(v) {
21
+ v = parsers.prepareValue(v);
22
+ if (parsers.hasVarFunc(v)) {
23
+ this._borderSetter(property, v, "");
24
+ } else {
25
+ const val = parse(v);
26
+ if (Array.isArray(val) || typeof val === "string") {
27
+ const priority =
28
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
29
+ this._borderSetter(property, val, priority);
30
+ }
31
+ }
32
+ },
33
+ get() {
34
+ return this.getPropertyValue(property);
35
+ },
36
+ enumerable: true,
37
+ configurable: true
38
+ };
39
+
40
+ /**
41
+ * Parses the border-width property value.
42
+ *
43
+ * @param {string} v - The value to parse.
44
+ * @returns {Array<string>|undefined} The parsed value or undefined if invalid.
45
+ */
46
+ function parse(v) {
21
47
  if (v === "") {
22
48
  return v;
23
49
  }
24
- const values = parsers.parsePropertyValue(property, v, {
25
- globalObject,
26
- inArray: true
27
- });
50
+ const values = parsers.parsePropertyValue(property, v);
28
51
  const parsedValues = [];
29
52
  if (Array.isArray(values) && values.length) {
30
53
  if (values.length > 4) {
@@ -81,31 +104,11 @@ module.exports.parse = (v, opt = {}) => {
81
104
  default:
82
105
  }
83
106
  }
84
- };
107
+ }
85
108
 
86
- module.exports.definition = {
87
- set(v) {
88
- v = parsers.prepareValue(v);
89
- if (parsers.hasVarFunc(v)) {
90
- this._borderSetter(property, v, "");
91
- } else {
92
- const val = module.exports.parse(v, {
93
- globalObject: this._global
94
- });
95
- if (Array.isArray(val) || typeof val === "string") {
96
- const priority =
97
- !this._priorities.get(shorthand) && this._priorities.has(property)
98
- ? this._priorities.get(property)
99
- : "";
100
- this._borderSetter(property, val, priority);
101
- }
102
- }
103
- },
104
- get() {
105
- return this.getPropertyValue(property);
106
- },
107
- enumerable: true,
108
- configurable: true
109
+ module.exports = {
110
+ descriptor,
111
+ parse,
112
+ property,
113
+ shorthandFor
109
114
  };
110
-
111
- module.exports.property = property;