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
@@ -17,37 +17,59 @@ const subProps = {
17
17
  color: borderColor.property
18
18
  };
19
19
 
20
- module.exports.initialValues = new Map([
20
+ const initialValues = new Map([
21
21
  [borderWidth.property, "medium"],
22
22
  [borderStyle.property, "none"],
23
23
  [borderColor.property, "currentcolor"]
24
24
  ]);
25
25
 
26
- module.exports.shorthandFor = new Map([
26
+ const shorthandFor = new Map([
27
27
  [borderWidth.property, borderWidth],
28
28
  [borderStyle.property, borderStyle],
29
29
  [borderColor.property, borderColor]
30
30
  ]);
31
31
 
32
- module.exports.positionShorthandFor = new Map([
32
+ const positionShorthandFor = new Map([
33
33
  [borderTop.property, borderTop],
34
34
  [borderRight.property, borderRight],
35
35
  [borderBottom.property, borderBottom],
36
36
  [borderLeft.property, borderLeft]
37
37
  ]);
38
38
 
39
- module.exports.parse = (v, opt = {}) => {
40
- const { globalObject } = opt;
39
+ const descriptor = {
40
+ set(v) {
41
+ v = parsers.prepareValue(v);
42
+ if (parsers.hasVarFunc(v)) {
43
+ this._borderSetter(property, v, "");
44
+ } else {
45
+ const val = parse(v);
46
+ if (val || typeof val === "string") {
47
+ const priority = this._priorities.get(property) ?? "";
48
+ this._borderSetter(property, val, priority);
49
+ }
50
+ }
51
+ },
52
+ get() {
53
+ return this.getPropertyValue(property);
54
+ },
55
+ enumerable: true,
56
+ configurable: true
57
+ };
58
+
59
+ /**
60
+ * Parses the border property value.
61
+ *
62
+ * @param {string} v - The value to parse.
63
+ * @returns {object|string|undefined} The parsed value or undefined if invalid.
64
+ */
65
+ function parse(v) {
41
66
  if (v === "" || parsers.hasVarFunc(v)) {
42
67
  return v;
43
68
  }
44
69
  const values = parsers.splitValue(v);
45
70
  const parsedValues = new Map();
46
71
  for (const val of values) {
47
- const value = parsers.parsePropertyValue(property, val, {
48
- globalObject,
49
- inArray: true
50
- });
72
+ const value = parsers.parsePropertyValue(property, val);
51
73
  if (Array.isArray(value) && value.length === 1) {
52
74
  const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues);
53
75
  if (typeof parsedValue === "string") {
@@ -63,14 +85,14 @@ module.exports.parse = (v, opt = {}) => {
63
85
  }
64
86
  }
65
87
  if (parsedValues.size) {
66
- const keys = module.exports.shorthandFor.keys();
88
+ const keys = shorthandFor.keys();
67
89
  const obj = {
68
90
  [borderWidth.property]: "medium"
69
91
  };
70
92
  for (const key of keys) {
71
93
  if (parsedValues.has(key)) {
72
94
  const parsedValue = parsedValues.get(key);
73
- if (parsedValue !== module.exports.initialValues.get(key)) {
95
+ if (parsedValue !== initialValues.get(key)) {
74
96
  obj[key] = parsedValues.get(key);
75
97
  if (obj[borderWidth.property] && obj[borderWidth.property] === "medium") {
76
98
  delete obj[borderWidth.property];
@@ -80,28 +102,13 @@ module.exports.parse = (v, opt = {}) => {
80
102
  }
81
103
  return obj;
82
104
  }
83
- };
105
+ }
84
106
 
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 (val || typeof val === "string") {
95
- const priority = this._priorities.get(property) ?? "";
96
- this._borderSetter(property, val, priority);
97
- }
98
- }
99
- },
100
- get() {
101
- return this.getPropertyValue(property);
102
- },
103
- enumerable: true,
104
- configurable: true
107
+ module.exports = {
108
+ descriptor,
109
+ initialValues,
110
+ parse,
111
+ positionShorthandFor,
112
+ property,
113
+ shorthandFor
105
114
  };
106
-
107
- module.exports.property = property;
@@ -2,33 +2,15 @@
2
2
 
3
3
  const parsers = require("../parsers");
4
4
 
5
- const property = "-webkit-border-end-color";
5
+ const property = "border-block-end-color";
6
6
 
7
- module.exports.parse = (v, opt = {}) => {
8
- const { globalObject } = opt;
9
- if (v === "") {
10
- return v;
11
- }
12
- const value = parsers.parsePropertyValue(property, v, {
13
- globalObject,
14
- inArray: true
15
- });
16
- if (Array.isArray(value) && value.length === 1) {
17
- return parsers.resolveColorValue(value);
18
- } else if (typeof value === "string") {
19
- return value;
20
- }
21
- };
22
-
23
- module.exports.definition = {
7
+ const descriptor = {
24
8
  set(v) {
25
9
  v = parsers.prepareValue(v);
26
10
  if (parsers.hasVarFunc(v)) {
27
11
  this._setProperty(property, v);
28
12
  } else {
29
- const val = module.exports.parse(v, {
30
- globalObject: this._global
31
- });
13
+ const val = parse(v);
32
14
  if (typeof val === "string") {
33
15
  const priority = this._priorities.get(property) ?? "";
34
16
  this._setProperty(property, val, priority);
@@ -42,4 +24,26 @@ module.exports.definition = {
42
24
  configurable: true
43
25
  };
44
26
 
45
- module.exports.property = property;
27
+ /**
28
+ * Parses the border-block-end-color 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) {
34
+ if (v === "") {
35
+ return v;
36
+ }
37
+ const value = parsers.parsePropertyValue(property, v);
38
+ if (Array.isArray(value) && value.length === 1) {
39
+ return parsers.resolveColorValue(value);
40
+ } else if (typeof value === "string") {
41
+ return value;
42
+ }
43
+ }
44
+
45
+ module.exports = {
46
+ descriptor,
47
+ parse,
48
+ property
49
+ };
@@ -2,33 +2,15 @@
2
2
 
3
3
  const parsers = require("../parsers");
4
4
 
5
- const property = "-webkit-border-after-color";
5
+ const property = "border-block-start-color";
6
6
 
7
- module.exports.parse = (v, opt = {}) => {
8
- const { globalObject } = opt;
9
- if (v === "") {
10
- return v;
11
- }
12
- const value = parsers.parsePropertyValue(property, v, {
13
- globalObject,
14
- inArray: true
15
- });
16
- if (Array.isArray(value) && value.length === 1) {
17
- return parsers.resolveColorValue(value);
18
- } else if (typeof value === "string") {
19
- return value;
20
- }
21
- };
22
-
23
- module.exports.definition = {
7
+ const descriptor = {
24
8
  set(v) {
25
9
  v = parsers.prepareValue(v);
26
10
  if (parsers.hasVarFunc(v)) {
27
11
  this._setProperty(property, v);
28
12
  } else {
29
- const val = module.exports.parse(v, {
30
- globalObject: this._global
31
- });
13
+ const val = parse(v);
32
14
  if (typeof val === "string") {
33
15
  const priority = this._priorities.get(property) ?? "";
34
16
  this._setProperty(property, val, priority);
@@ -42,4 +24,26 @@ module.exports.definition = {
42
24
  configurable: true
43
25
  };
44
26
 
45
- module.exports.property = property;
27
+ /**
28
+ * Parses the border-block-start-color 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) {
34
+ if (v === "") {
35
+ return v;
36
+ }
37
+ const value = parsers.parsePropertyValue(property, v);
38
+ if (Array.isArray(value) && value.length === 1) {
39
+ return parsers.resolveColorValue(value);
40
+ } else if (typeof value === "string") {
41
+ return value;
42
+ }
43
+ }
44
+
45
+ module.exports = {
46
+ descriptor,
47
+ parse,
48
+ property
49
+ };
@@ -14,30 +14,53 @@ const subProps = {
14
14
  color: borderBottomColor.property
15
15
  };
16
16
 
17
- module.exports.initialValues = new Map([
17
+ const initialValues = new Map([
18
18
  [borderBottomWidth.property, "medium"],
19
19
  [borderBottomStyle.property, "none"],
20
20
  [borderBottomColor.property, "currentcolor"]
21
21
  ]);
22
22
 
23
- module.exports.shorthandFor = new Map([
23
+ const shorthandFor = new Map([
24
24
  [borderBottomWidth.property, borderBottomWidth],
25
25
  [borderBottomStyle.property, borderBottomStyle],
26
26
  [borderBottomColor.property, borderBottomColor]
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-bottom 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
  [borderBottomWidth.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[borderBottomWidth.property] && obj[borderBottomWidth.property] === "medium") {
66
89
  delete obj[borderBottomWidth.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-bottom";
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-bottom-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-bottom";
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-bottom-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-bottom";
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-bottom-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,31 +4,13 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "border-collapse";
6
6
 
7
- module.exports.parse = (v, opt = {}) => {
8
- const { globalObject } = opt;
9
- if (v === "") {
10
- return v;
11
- }
12
- const value = parsers.parsePropertyValue(property, v, {
13
- globalObject,
14
- inArray: true
15
- });
16
- if (Array.isArray(value) && value.length === 1) {
17
- return parsers.resolveKeywordValue(value);
18
- } else if (typeof value === "string") {
19
- return value;
20
- }
21
- };
22
-
23
- module.exports.definition = {
7
+ const descriptor = {
24
8
  set(v) {
25
9
  v = parsers.prepareValue(v);
26
10
  if (parsers.hasVarFunc(v)) {
27
11
  this._setProperty(property, v);
28
12
  } else {
29
- const val = module.exports.parse(v, {
30
- globalObject: this._global
31
- });
13
+ const val = parse(v);
32
14
  if (typeof val === "string") {
33
15
  const priority = this._priorities.get(property) ?? "";
34
16
  this._setProperty(property, val, priority);
@@ -42,4 +24,26 @@ module.exports.definition = {
42
24
  configurable: true
43
25
  };
44
26
 
45
- module.exports.property = property;
27
+ /**
28
+ * Parses the border-collapse 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) {
34
+ if (v === "") {
35
+ return v;
36
+ }
37
+ const value = parsers.parsePropertyValue(property, v);
38
+ if (Array.isArray(value) && value.length === 1) {
39
+ return parsers.resolveKeywordValue(value);
40
+ } else if (typeof value === "string") {
41
+ return value;
42
+ }
43
+ }
44
+
45
+ module.exports = {
46
+ descriptor,
47
+ parse,
48
+ property
49
+ };