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