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
@@ -5,41 +5,19 @@ const parsers = require("../parsers");
5
5
  const property = "margin-left";
6
6
  const shorthand = "margin";
7
7
 
8
- module.exports.position = "left";
8
+ const position = "left";
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
- type: "length"
22
- });
23
- } else if (typeof value === "string") {
24
- return value;
25
- }
26
- };
27
-
28
- module.exports.definition = {
10
+ const descriptor = {
29
11
  set(v) {
30
12
  v = parsers.prepareValue(v);
31
13
  if (parsers.hasVarFunc(v)) {
32
14
  this._setProperty(shorthand, "");
33
15
  this._setProperty(property, v);
34
16
  } else {
35
- const val = module.exports.parse(v, {
36
- globalObject: this._global
37
- });
17
+ const val = parse(v);
38
18
  if (typeof val === "string") {
39
19
  const priority =
40
- !this._priorities.get(shorthand) && this._priorities.has(property)
41
- ? this._priorities.get(property)
42
- : "";
20
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
43
21
  this._positionLonghandSetter(property, val, priority, shorthand);
44
22
  }
45
23
  }
@@ -51,4 +29,29 @@ module.exports.definition = {
51
29
  configurable: true
52
30
  };
53
31
 
54
- module.exports.property = property;
32
+ /**
33
+ * Parses the margin-left property value.
34
+ *
35
+ * @param {string} v - The value to parse.
36
+ * @returns {string|undefined} The parsed value or undefined if invalid.
37
+ */
38
+ function parse(v) {
39
+ if (v === "") {
40
+ return v;
41
+ }
42
+ const value = parsers.parsePropertyValue(property, v);
43
+ if (Array.isArray(value) && value.length === 1) {
44
+ return parsers.resolveNumericValue(value, {
45
+ type: "length"
46
+ });
47
+ } else if (typeof value === "string") {
48
+ return value;
49
+ }
50
+ }
51
+
52
+ module.exports = {
53
+ descriptor,
54
+ parse,
55
+ position,
56
+ property
57
+ };
@@ -5,41 +5,19 @@ const parsers = require("../parsers");
5
5
  const property = "margin-right";
6
6
  const shorthand = "margin";
7
7
 
8
- module.exports.position = "right";
8
+ const position = "right";
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
- type: "length"
22
- });
23
- } else if (typeof value === "string") {
24
- return value;
25
- }
26
- };
27
-
28
- module.exports.definition = {
10
+ const descriptor = {
29
11
  set(v) {
30
12
  v = parsers.prepareValue(v);
31
13
  if (parsers.hasVarFunc(v)) {
32
14
  this._setProperty(shorthand, "");
33
15
  this._setProperty(property, v);
34
16
  } else {
35
- const val = module.exports.parse(v, {
36
- globalObject: this._global
37
- });
17
+ const val = parse(v);
38
18
  if (typeof val === "string") {
39
19
  const priority =
40
- !this._priorities.get(shorthand) && this._priorities.has(property)
41
- ? this._priorities.get(property)
42
- : "";
20
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
43
21
  this._positionLonghandSetter(property, val, priority, shorthand);
44
22
  }
45
23
  }
@@ -51,4 +29,29 @@ module.exports.definition = {
51
29
  configurable: true
52
30
  };
53
31
 
54
- module.exports.property = property;
32
+ /**
33
+ * Parses the margin-right property value.
34
+ *
35
+ * @param {string} v - The value to parse.
36
+ * @returns {string|undefined} The parsed value or undefined if invalid.
37
+ */
38
+ function parse(v) {
39
+ if (v === "") {
40
+ return v;
41
+ }
42
+ const value = parsers.parsePropertyValue(property, v);
43
+ if (Array.isArray(value) && value.length === 1) {
44
+ return parsers.resolveNumericValue(value, {
45
+ type: "length"
46
+ });
47
+ } else if (typeof value === "string") {
48
+ return value;
49
+ }
50
+ }
51
+
52
+ module.exports = {
53
+ descriptor,
54
+ parse,
55
+ position,
56
+ property
57
+ };
@@ -5,41 +5,19 @@ const parsers = require("../parsers");
5
5
  const property = "margin-top";
6
6
  const shorthand = "margin";
7
7
 
8
- module.exports.position = "top";
8
+ const position = "top";
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
- type: "length"
22
- });
23
- } else if (typeof value === "string") {
24
- return value;
25
- }
26
- };
27
-
28
- module.exports.definition = {
10
+ const descriptor = {
29
11
  set(v) {
30
12
  v = parsers.prepareValue(v);
31
13
  if (parsers.hasVarFunc(v)) {
32
14
  this._setProperty(shorthand, "");
33
15
  this._setProperty(property, v);
34
16
  } else {
35
- const val = module.exports.parse(v, {
36
- globalObject: this._global
37
- });
17
+ const val = parse(v);
38
18
  if (typeof val === "string") {
39
19
  const priority =
40
- !this._priorities.get(shorthand) && this._priorities.has(property)
41
- ? this._priorities.get(property)
42
- : "";
20
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
43
21
  this._positionLonghandSetter(property, val, priority, shorthand);
44
22
  }
45
23
  }
@@ -51,4 +29,29 @@ module.exports.definition = {
51
29
  configurable: true
52
30
  };
53
31
 
54
- module.exports.property = property;
32
+ /**
33
+ * Parses the margin-top property value.
34
+ *
35
+ * @param {string} v - The value to parse.
36
+ * @returns {string|undefined} The parsed value or undefined if invalid.
37
+ */
38
+ function parse(v) {
39
+ if (v === "") {
40
+ return v;
41
+ }
42
+ const value = parsers.parsePropertyValue(property, v);
43
+ if (Array.isArray(value) && value.length === 1) {
44
+ return parsers.resolveNumericValue(value, {
45
+ type: "length"
46
+ });
47
+ } else if (typeof value === "string") {
48
+ return value;
49
+ }
50
+ }
51
+
52
+ module.exports = {
53
+ descriptor,
54
+ parse,
55
+ position,
56
+ property
57
+ };
@@ -4,33 +4,13 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "opacity";
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.resolveNumericValue(value, {
18
- clamp: true
19
- });
20
- } else if (typeof value === "string") {
21
- return value;
22
- }
23
- };
24
-
25
- module.exports.definition = {
7
+ const descriptor = {
26
8
  set(v) {
27
9
  v = parsers.prepareValue(v);
28
10
  if (parsers.hasVarFunc(v)) {
29
11
  this._setProperty(property, v);
30
12
  } else {
31
- const val = module.exports.parse(v, {
32
- globalObject: this._global
33
- });
13
+ const val = parse(v);
34
14
  if (typeof val === "string") {
35
15
  const priority = this._priorities.get(property) ?? "";
36
16
  this._setProperty(property, val, priority);
@@ -44,4 +24,28 @@ module.exports.definition = {
44
24
  configurable: true
45
25
  };
46
26
 
47
- module.exports.property = property;
27
+ /**
28
+ * Parses the opacity 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.resolveNumericValue(value, {
40
+ clamp: true
41
+ });
42
+ } else if (typeof value === "string") {
43
+ return value;
44
+ }
45
+ }
46
+
47
+ module.exports = {
48
+ descriptor,
49
+ parse,
50
+ property
51
+ };
@@ -4,31 +4,13 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "outline-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 outline-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
+ };
@@ -8,24 +8,49 @@ const paddingLeft = require("./paddingLeft");
8
8
 
9
9
  const property = "padding";
10
10
 
11
- module.exports.position = "edges";
11
+ const position = "edges";
12
12
 
13
- module.exports.shorthandFor = new Map([
13
+ const shorthandFor = new Map([
14
14
  [paddingTop.property, paddingTop],
15
15
  [paddingRight.property, paddingRight],
16
16
  [paddingBottom.property, paddingBottom],
17
17
  [paddingLeft.property, paddingLeft]
18
18
  ]);
19
19
 
20
- module.exports.parse = (v, opt = {}) => {
21
- const { globalObject } = opt;
20
+ const descriptor = {
21
+ set(v) {
22
+ v = parsers.prepareValue(v);
23
+ if (parsers.hasVarFunc(v)) {
24
+ for (const [longhand] of shorthandFor) {
25
+ this._setProperty(longhand, "");
26
+ }
27
+ this._setProperty(property, v);
28
+ } else {
29
+ const val = parse(v);
30
+ if (Array.isArray(val) || typeof val === "string") {
31
+ const priority = this._priorities.get(property) ?? "";
32
+ this._positionShorthandSetter(property, val, priority);
33
+ }
34
+ }
35
+ },
36
+ get() {
37
+ return this.getPropertyValue(property);
38
+ },
39
+ enumerable: true,
40
+ configurable: true
41
+ };
42
+
43
+ /**
44
+ * Parses the padding property value.
45
+ *
46
+ * @param {string} v - The value to parse.
47
+ * @returns {Array<string>|string|undefined} The parsed value or undefined if invalid.
48
+ */
49
+ function parse(v) {
22
50
  if (v === "") {
23
51
  return v;
24
52
  }
25
- const values = parsers.parsePropertyValue(property, v, {
26
- globalObject,
27
- inArray: true
28
- });
53
+ const values = parsers.parsePropertyValue(property, v);
29
54
  const parsedValues = [];
30
55
  if (Array.isArray(values) && values.length) {
31
56
  if (values.length > 4) {
@@ -48,31 +73,12 @@ module.exports.parse = (v, opt = {}) => {
48
73
  if (parsedValues.length) {
49
74
  return parsedValues;
50
75
  }
51
- };
76
+ }
52
77
 
53
- module.exports.definition = {
54
- set(v) {
55
- v = parsers.prepareValue(v);
56
- if (parsers.hasVarFunc(v)) {
57
- for (const [longhand] of module.exports.shorthandFor) {
58
- this._setProperty(longhand, "");
59
- }
60
- this._setProperty(property, v);
61
- } else {
62
- const val = module.exports.parse(v, {
63
- globalObject: this._global
64
- });
65
- if (Array.isArray(val) || typeof val === "string") {
66
- const priority = this._priorities.get(property) ?? "";
67
- this._positionShorthandSetter(property, val, priority);
68
- }
69
- }
70
- },
71
- get() {
72
- return this.getPropertyValue(property);
73
- },
74
- enumerable: true,
75
- configurable: true
78
+ module.exports = {
79
+ descriptor,
80
+ parse,
81
+ position,
82
+ property,
83
+ shorthandFor
76
84
  };
77
-
78
- module.exports.property = property;
@@ -5,42 +5,19 @@ const parsers = require("../parsers");
5
5
  const property = "padding-bottom";
6
6
  const shorthand = "padding";
7
7
 
8
- module.exports.position = "bottom";
8
+ const position = "bottom";
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._setProperty(shorthand, "");
34
15
  this._setProperty(property, v);
35
16
  } else {
36
- const val = module.exports.parse(v, {
37
- globalObject: this._global
38
- });
17
+ const val = parse(v);
39
18
  if (typeof val === "string") {
40
19
  const priority =
41
- !this._priorities.get(shorthand) && this._priorities.has(property)
42
- ? this._priorities.get(property)
43
- : "";
20
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
44
21
  this._positionLonghandSetter(property, val, priority, shorthand);
45
22
  }
46
23
  }
@@ -52,4 +29,30 @@ module.exports.definition = {
52
29
  configurable: true
53
30
  };
54
31
 
55
- module.exports.property = property;
32
+ /**
33
+ * Parses the padding-bottom property value.
34
+ *
35
+ * @param {string} v - The value to parse.
36
+ * @returns {string|undefined} The parsed value or undefined if invalid.
37
+ */
38
+ function parse(v) {
39
+ if (v === "") {
40
+ return v;
41
+ }
42
+ const value = parsers.parsePropertyValue(property, v);
43
+ if (Array.isArray(value) && value.length === 1) {
44
+ return parsers.resolveNumericValue(value, {
45
+ min: 0,
46
+ type: "length"
47
+ });
48
+ } else if (typeof value === "string") {
49
+ return value;
50
+ }
51
+ }
52
+
53
+ module.exports = {
54
+ descriptor,
55
+ parse,
56
+ position,
57
+ property
58
+ };
@@ -5,42 +5,19 @@ const parsers = require("../parsers");
5
5
  const property = "padding-left";
6
6
  const shorthand = "padding";
7
7
 
8
- module.exports.position = "left";
8
+ const position = "left";
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._setProperty(shorthand, "");
34
15
  this._setProperty(property, v);
35
16
  } else {
36
- const val = module.exports.parse(v, {
37
- globalObject: this._global
38
- });
17
+ const val = parse(v);
39
18
  if (typeof val === "string") {
40
19
  const priority =
41
- !this._priorities.get(shorthand) && this._priorities.has(property)
42
- ? this._priorities.get(property)
43
- : "";
20
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
44
21
  this._positionLonghandSetter(property, val, priority, shorthand);
45
22
  }
46
23
  }
@@ -52,4 +29,30 @@ module.exports.definition = {
52
29
  configurable: true
53
30
  };
54
31
 
55
- module.exports.property = property;
32
+ /**
33
+ * Parses the padding-left property value.
34
+ *
35
+ * @param {string} v - The value to parse.
36
+ * @returns {string|undefined} The parsed value or undefined if invalid.
37
+ */
38
+ function parse(v) {
39
+ if (v === "") {
40
+ return v;
41
+ }
42
+ const value = parsers.parsePropertyValue(property, v);
43
+ if (Array.isArray(value) && value.length === 1) {
44
+ return parsers.resolveNumericValue(value, {
45
+ min: 0,
46
+ type: "length"
47
+ });
48
+ } else if (typeof value === "string") {
49
+ return value;
50
+ }
51
+ }
52
+
53
+ module.exports = {
54
+ descriptor,
55
+ parse,
56
+ position,
57
+ property
58
+ };
@@ -5,42 +5,19 @@ const parsers = require("../parsers");
5
5
  const property = "padding-right";
6
6
  const shorthand = "padding";
7
7
 
8
- module.exports.position = "right";
8
+ const position = "right";
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._setProperty(shorthand, "");
34
15
  this._setProperty(property, v);
35
16
  } else {
36
- const val = module.exports.parse(v, {
37
- globalObject: this._global
38
- });
17
+ const val = parse(v);
39
18
  if (typeof val === "string") {
40
19
  const priority =
41
- !this._priorities.get(shorthand) && this._priorities.has(property)
42
- ? this._priorities.get(property)
43
- : "";
20
+ !this._priorities.get(shorthand) && this._priorities.has(property) ? this._priorities.get(property) : "";
44
21
  this._positionLonghandSetter(property, val, priority, shorthand);
45
22
  }
46
23
  }
@@ -52,4 +29,30 @@ module.exports.definition = {
52
29
  configurable: true
53
30
  };
54
31
 
55
- module.exports.property = property;
32
+ /**
33
+ * Parses the padding-right property value.
34
+ *
35
+ * @param {string} v - The value to parse.
36
+ * @returns {string|undefined} The parsed value or undefined if invalid.
37
+ */
38
+ function parse(v) {
39
+ if (v === "") {
40
+ return v;
41
+ }
42
+ const value = parsers.parsePropertyValue(property, v);
43
+ if (Array.isArray(value) && value.length === 1) {
44
+ return parsers.resolveNumericValue(value, {
45
+ min: 0,
46
+ type: "length"
47
+ });
48
+ } else if (typeof value === "string") {
49
+ return value;
50
+ }
51
+ }
52
+
53
+ module.exports = {
54
+ descriptor,
55
+ parse,
56
+ position,
57
+ property
58
+ };