cssstyle 5.3.5 → 5.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/lib/CSSStyleDeclaration.js +6 -5
  2. package/lib/generated/implementedProperties.js +1 -1
  3. package/lib/generated/properties.js +2034 -2348
  4. package/lib/generated/propertyDefinitions.js +13033 -0
  5. package/lib/normalize.js +1252 -1095
  6. package/lib/parsers.js +589 -253
  7. package/lib/properties/background.js +90 -80
  8. package/lib/properties/backgroundAttachment.js +12 -15
  9. package/lib/properties/backgroundClip.js +12 -15
  10. package/lib/properties/backgroundColor.js +9 -14
  11. package/lib/properties/backgroundImage.js +12 -27
  12. package/lib/properties/backgroundOrigin.js +12 -15
  13. package/lib/properties/backgroundPosition.js +30 -19
  14. package/lib/properties/backgroundRepeat.js +12 -8
  15. package/lib/properties/backgroundSize.js +23 -17
  16. package/lib/properties/border.js +31 -88
  17. package/lib/properties/borderBottom.js +31 -87
  18. package/lib/properties/borderBottomColor.js +9 -15
  19. package/lib/properties/borderBottomStyle.js +9 -14
  20. package/lib/properties/borderBottomWidth.js +12 -24
  21. package/lib/properties/borderCollapse.js +5 -10
  22. package/lib/properties/borderColor.js +18 -24
  23. package/lib/properties/borderLeft.js +31 -87
  24. package/lib/properties/borderLeftColor.js +9 -15
  25. package/lib/properties/borderLeftStyle.js +9 -14
  26. package/lib/properties/borderLeftWidth.js +12 -24
  27. package/lib/properties/borderRight.js +31 -87
  28. package/lib/properties/borderRightColor.js +9 -15
  29. package/lib/properties/borderRightStyle.js +9 -14
  30. package/lib/properties/borderRightWidth.js +12 -24
  31. package/lib/properties/borderSpacing.js +13 -10
  32. package/lib/properties/borderStyle.js +18 -24
  33. package/lib/properties/borderTop.js +31 -87
  34. package/lib/properties/borderTopColor.js +9 -15
  35. package/lib/properties/borderTopStyle.js +9 -14
  36. package/lib/properties/borderTopWidth.js +12 -24
  37. package/lib/properties/borderWidth.js +19 -37
  38. package/lib/properties/bottom.js +7 -18
  39. package/lib/properties/clear.js +5 -10
  40. package/lib/properties/clip.js +11 -6
  41. package/lib/properties/color.js +5 -11
  42. package/lib/properties/display.js +12 -9
  43. package/lib/properties/flex.js +56 -54
  44. package/lib/properties/flexBasis.js +11 -21
  45. package/lib/properties/flexGrow.js +11 -20
  46. package/lib/properties/flexShrink.js +11 -20
  47. package/lib/properties/float.js +5 -10
  48. package/lib/properties/floodColor.js +5 -11
  49. package/lib/properties/font.js +47 -34
  50. package/lib/properties/fontFamily.js +17 -13
  51. package/lib/properties/fontSize.js +12 -23
  52. package/lib/properties/fontStyle.js +15 -9
  53. package/lib/properties/fontVariant.js +12 -19
  54. package/lib/properties/fontWeight.js +15 -26
  55. package/lib/properties/height.js +8 -18
  56. package/lib/properties/left.js +7 -18
  57. package/lib/properties/lightingColor.js +5 -11
  58. package/lib/properties/lineHeight.js +11 -25
  59. package/lib/properties/margin.js +15 -33
  60. package/lib/properties/marginBottom.js +11 -21
  61. package/lib/properties/marginLeft.js +11 -21
  62. package/lib/properties/marginRight.js +11 -21
  63. package/lib/properties/marginTop.js +11 -21
  64. package/lib/properties/opacity.js +7 -19
  65. package/lib/properties/outlineColor.js +5 -11
  66. package/lib/properties/padding.js +16 -31
  67. package/lib/properties/paddingBottom.js +12 -22
  68. package/lib/properties/paddingLeft.js +12 -22
  69. package/lib/properties/paddingRight.js +12 -22
  70. package/lib/properties/paddingTop.js +12 -22
  71. package/lib/properties/right.js +7 -18
  72. package/lib/properties/stopColor.js +5 -11
  73. package/lib/properties/top.js +7 -18
  74. package/lib/properties/webkitBorderAfterColor.js +5 -11
  75. package/lib/properties/webkitBorderBeforeColor.js +5 -11
  76. package/lib/properties/webkitBorderEndColor.js +5 -11
  77. package/lib/properties/webkitBorderStartColor.js +5 -11
  78. package/lib/properties/webkitColumnRuleColor.js +5 -11
  79. package/lib/properties/webkitTapHighlightColor.js +5 -11
  80. package/lib/properties/webkitTextEmphasisColor.js +5 -11
  81. package/lib/properties/webkitTextFillColor.js +5 -11
  82. package/lib/properties/webkitTextStrokeColor.js +5 -11
  83. package/lib/properties/width.js +8 -18
  84. package/lib/utils/propertyDescriptors.js +49 -13
  85. package/lib/utils/strings.js +6 -0
  86. package/package.json +8 -27
@@ -7,7 +7,7 @@ const shorthand = "margin";
7
7
 
8
8
  module.exports.position = "left";
9
9
 
10
- module.exports.parse = function parse(v, opt = {}) {
10
+ module.exports.parse = (v, opt = {}) => {
11
11
  const { globalObject } = opt;
12
12
  if (v === "") {
13
13
  return v;
@@ -17,22 +17,9 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ isNumber, name, type, value: itemValue }] = value;
21
- switch (type) {
22
- case "Calc": {
23
- if (isNumber) {
24
- return;
25
- }
26
- return `${name}(${itemValue})`;
27
- }
28
- case "GlobalKeyword":
29
- case "Identifier": {
30
- return name;
31
- }
32
- default: {
33
- return parsers.parseLengthPercentage(value);
34
- }
35
- }
20
+ return parsers.resolveNumericValue(value, {
21
+ type: "length"
22
+ });
36
23
  } else if (typeof value === "string") {
37
24
  return value;
38
25
  }
@@ -40,7 +27,7 @@ module.exports.parse = function parse(v, opt = {}) {
40
27
 
41
28
  module.exports.definition = {
42
29
  set(v) {
43
- v = parsers.prepareValue(v, this._global);
30
+ v = parsers.prepareValue(v);
44
31
  if (parsers.hasVarFunc(v)) {
45
32
  this._setProperty(shorthand, "");
46
33
  this._setProperty(property, v);
@@ -49,9 +36,10 @@ module.exports.definition = {
49
36
  globalObject: this._global
50
37
  });
51
38
  if (typeof val === "string") {
52
- const shorthandPriority = this._priorities.get(shorthand);
53
- const prior = this._priorities.get(property) ?? "";
54
- const priority = shorthandPriority && prior ? "" : prior;
39
+ const priority =
40
+ !this._priorities.get(shorthand) && this._priorities.has(property)
41
+ ? this._priorities.get(property)
42
+ : "";
55
43
  this._positionLonghandSetter(property, val, priority, shorthand);
56
44
  }
57
45
  }
@@ -62,3 +50,5 @@ module.exports.definition = {
62
50
  enumerable: true,
63
51
  configurable: true
64
52
  };
53
+
54
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const shorthand = "margin";
7
7
 
8
8
  module.exports.position = "right";
9
9
 
10
- module.exports.parse = function parse(v, opt = {}) {
10
+ module.exports.parse = (v, opt = {}) => {
11
11
  const { globalObject } = opt;
12
12
  if (v === "") {
13
13
  return v;
@@ -17,22 +17,9 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ isNumber, name, type, value: itemValue }] = value;
21
- switch (type) {
22
- case "Calc": {
23
- if (isNumber) {
24
- return;
25
- }
26
- return `${name}(${itemValue})`;
27
- }
28
- case "GlobalKeyword":
29
- case "Identifier": {
30
- return name;
31
- }
32
- default: {
33
- return parsers.parseLengthPercentage(value);
34
- }
35
- }
20
+ return parsers.resolveNumericValue(value, {
21
+ type: "length"
22
+ });
36
23
  } else if (typeof value === "string") {
37
24
  return value;
38
25
  }
@@ -40,7 +27,7 @@ module.exports.parse = function parse(v, opt = {}) {
40
27
 
41
28
  module.exports.definition = {
42
29
  set(v) {
43
- v = parsers.prepareValue(v, this._global);
30
+ v = parsers.prepareValue(v);
44
31
  if (parsers.hasVarFunc(v)) {
45
32
  this._setProperty(shorthand, "");
46
33
  this._setProperty(property, v);
@@ -49,9 +36,10 @@ module.exports.definition = {
49
36
  globalObject: this._global
50
37
  });
51
38
  if (typeof val === "string") {
52
- const shorthandPriority = this._priorities.get(shorthand);
53
- const prior = this._priorities.get(property) ?? "";
54
- const priority = shorthandPriority && prior ? "" : prior;
39
+ const priority =
40
+ !this._priorities.get(shorthand) && this._priorities.has(property)
41
+ ? this._priorities.get(property)
42
+ : "";
55
43
  this._positionLonghandSetter(property, val, priority, shorthand);
56
44
  }
57
45
  }
@@ -62,3 +50,5 @@ module.exports.definition = {
62
50
  enumerable: true,
63
51
  configurable: true
64
52
  };
53
+
54
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const shorthand = "margin";
7
7
 
8
8
  module.exports.position = "top";
9
9
 
10
- module.exports.parse = function parse(v, opt = {}) {
10
+ module.exports.parse = (v, opt = {}) => {
11
11
  const { globalObject } = opt;
12
12
  if (v === "") {
13
13
  return v;
@@ -17,22 +17,9 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ isNumber, name, type, value: itemValue }] = value;
21
- switch (type) {
22
- case "Calc": {
23
- if (isNumber) {
24
- return;
25
- }
26
- return `${name}(${itemValue})`;
27
- }
28
- case "GlobalKeyword":
29
- case "Identifier": {
30
- return name;
31
- }
32
- default: {
33
- return parsers.parseLengthPercentage(value);
34
- }
35
- }
20
+ return parsers.resolveNumericValue(value, {
21
+ type: "length"
22
+ });
36
23
  } else if (typeof value === "string") {
37
24
  return value;
38
25
  }
@@ -40,7 +27,7 @@ module.exports.parse = function parse(v, opt = {}) {
40
27
 
41
28
  module.exports.definition = {
42
29
  set(v) {
43
- v = parsers.prepareValue(v, this._global);
30
+ v = parsers.prepareValue(v);
44
31
  if (parsers.hasVarFunc(v)) {
45
32
  this._setProperty(shorthand, "");
46
33
  this._setProperty(property, v);
@@ -49,9 +36,10 @@ module.exports.definition = {
49
36
  globalObject: this._global
50
37
  });
51
38
  if (typeof val === "string") {
52
- const shorthandPriority = this._priorities.get(shorthand);
53
- const prior = this._priorities.get(property) ?? "";
54
- const priority = shorthandPriority && prior ? "" : prior;
39
+ const priority =
40
+ !this._priorities.get(shorthand) && this._priorities.has(property)
41
+ ? this._priorities.get(property)
42
+ : "";
55
43
  this._positionLonghandSetter(property, val, priority, shorthand);
56
44
  }
57
45
  }
@@ -62,3 +50,5 @@ module.exports.definition = {
62
50
  enumerable: true,
63
51
  configurable: true
64
52
  };
53
+
54
+ module.exports.property = property;
@@ -4,7 +4,7 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "opacity";
6
6
 
7
- module.exports.parse = function parse(v, opt = {}) {
7
+ module.exports.parse = (v, opt = {}) => {
8
8
  const { globalObject } = opt;
9
9
  if (v === "") {
10
10
  return v;
@@ -14,23 +14,9 @@ module.exports.parse = function parse(v, opt = {}) {
14
14
  inArray: true
15
15
  });
16
16
  if (Array.isArray(value) && value.length === 1) {
17
- const [{ name, type, value: itemValue }] = value;
18
- switch (type) {
19
- case "Calc": {
20
- return `${name}(${itemValue})`;
21
- }
22
- case "GlobalKeyword":
23
- case "Identifier": {
24
- return name;
25
- }
26
- case "Number": {
27
- return parsers.parseNumber(value);
28
- }
29
- case "Percentage": {
30
- return parsers.parsePercentage(value);
31
- }
32
- default:
33
- }
17
+ return parsers.resolveNumericValue(value, {
18
+ clamp: true
19
+ });
34
20
  } else if (typeof value === "string") {
35
21
  return value;
36
22
  }
@@ -38,7 +24,7 @@ module.exports.parse = function parse(v, opt = {}) {
38
24
 
39
25
  module.exports.definition = {
40
26
  set(v) {
41
- v = parsers.prepareValue(v, this._global);
27
+ v = parsers.prepareValue(v);
42
28
  if (parsers.hasVarFunc(v)) {
43
29
  this._setProperty(property, v);
44
30
  } else {
@@ -57,3 +43,5 @@ module.exports.definition = {
57
43
  enumerable: true,
58
44
  configurable: true
59
45
  };
46
+
47
+ module.exports.property = property;
@@ -4,7 +4,7 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "outline-color";
6
6
 
7
- module.exports.parse = function parse(v, opt = {}) {
7
+ module.exports.parse = (v, opt = {}) => {
8
8
  const { globalObject } = opt;
9
9
  if (v === "") {
10
10
  return v;
@@ -14,15 +14,7 @@ module.exports.parse = function parse(v, opt = {}) {
14
14
  inArray: true
15
15
  });
16
16
  if (Array.isArray(value) && value.length === 1) {
17
- const [{ name, type }] = value;
18
- switch (type) {
19
- case "GlobalKeyword": {
20
- return name;
21
- }
22
- default: {
23
- return parsers.parseColor(value);
24
- }
25
- }
17
+ return parsers.resolveColorValue(value);
26
18
  } else if (typeof value === "string") {
27
19
  return value;
28
20
  }
@@ -30,7 +22,7 @@ module.exports.parse = function parse(v, opt = {}) {
30
22
 
31
23
  module.exports.definition = {
32
24
  set(v) {
33
- v = parsers.prepareValue(v, this._global);
25
+ v = parsers.prepareValue(v);
34
26
  if (parsers.hasVarFunc(v)) {
35
27
  this._setProperty(property, v);
36
28
  } else {
@@ -49,3 +41,5 @@ module.exports.definition = {
49
41
  enumerable: true,
50
42
  configurable: true
51
43
  };
44
+
45
+ module.exports.property = property;
@@ -11,13 +11,13 @@ const property = "padding";
11
11
  module.exports.position = "edges";
12
12
 
13
13
  module.exports.shorthandFor = new Map([
14
- ["padding-top", paddingTop],
15
- ["padding-right", paddingRight],
16
- ["padding-bottom", paddingBottom],
17
- ["padding-left", paddingLeft]
14
+ [paddingTop.property, paddingTop],
15
+ [paddingRight.property, paddingRight],
16
+ [paddingBottom.property, paddingBottom],
17
+ [paddingLeft.property, paddingLeft]
18
18
  ]);
19
19
 
20
- module.exports.parse = function parse(v, opt = {}) {
20
+ module.exports.parse = (v, opt = {}) => {
21
21
  const { globalObject } = opt;
22
22
  if (v === "") {
23
23
  return v;
@@ -32,32 +32,15 @@ module.exports.parse = function parse(v, opt = {}) {
32
32
  return;
33
33
  }
34
34
  for (const value of values) {
35
- const { isNumber, name, type, value: itemValue } = value;
36
- switch (type) {
37
- case "Calc": {
38
- if (isNumber) {
39
- return;
40
- }
41
- parsedValues.push(`${name}(${itemValue})`);
42
- break;
43
- }
44
- case "GlobalKeyword": {
45
- if (values.length !== 1) {
46
- return;
47
- }
48
- parsedValues.push(name);
49
- break;
50
- }
51
- default: {
52
- const parsedValue = parsers.parseLengthPercentage([value], {
53
- min: 0
54
- });
55
- if (!parsedValue) {
56
- return;
57
- }
58
- parsedValues.push(parsedValue);
59
- }
35
+ const parsedValue = parsers.resolveNumericValue([value], {
36
+ length: values.length,
37
+ min: 0,
38
+ type: "length"
39
+ });
40
+ if (!parsedValue) {
41
+ return;
60
42
  }
43
+ parsedValues.push(parsedValue);
61
44
  }
62
45
  } else if (typeof values === "string") {
63
46
  parsedValues.push(values);
@@ -69,7 +52,7 @@ module.exports.parse = function parse(v, opt = {}) {
69
52
 
70
53
  module.exports.definition = {
71
54
  set(v) {
72
- v = parsers.prepareValue(v, this._global);
55
+ v = parsers.prepareValue(v);
73
56
  if (parsers.hasVarFunc(v)) {
74
57
  for (const [longhand] of module.exports.shorthandFor) {
75
58
  this._setProperty(longhand, "");
@@ -91,3 +74,5 @@ module.exports.definition = {
91
74
  enumerable: true,
92
75
  configurable: true
93
76
  };
77
+
78
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const shorthand = "padding";
7
7
 
8
8
  module.exports.position = "bottom";
9
9
 
10
- module.exports.parse = function parse(v, opt = {}) {
10
+ module.exports.parse = (v, opt = {}) => {
11
11
  const { globalObject } = opt;
12
12
  if (v === "") {
13
13
  return v;
@@ -17,23 +17,10 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ isNumber, name, type, value: itemValue }] = value;
21
- switch (type) {
22
- case "Calc": {
23
- if (isNumber) {
24
- return;
25
- }
26
- return `${name}(${itemValue})`;
27
- }
28
- case "GlobalKeyword": {
29
- return name;
30
- }
31
- default: {
32
- return parsers.parseLengthPercentage(value, {
33
- min: 0
34
- });
35
- }
36
- }
20
+ return parsers.resolveNumericValue(value, {
21
+ min: 0,
22
+ type: "length"
23
+ });
37
24
  } else if (typeof value === "string") {
38
25
  return value;
39
26
  }
@@ -41,7 +28,7 @@ module.exports.parse = function parse(v, opt = {}) {
41
28
 
42
29
  module.exports.definition = {
43
30
  set(v) {
44
- v = parsers.prepareValue(v, this._global);
31
+ v = parsers.prepareValue(v);
45
32
  if (parsers.hasVarFunc(v)) {
46
33
  this._setProperty(shorthand, "");
47
34
  this._setProperty(property, v);
@@ -50,9 +37,10 @@ module.exports.definition = {
50
37
  globalObject: this._global
51
38
  });
52
39
  if (typeof val === "string") {
53
- const shorthandPriority = this._priorities.get(shorthand);
54
- const prior = this._priorities.get(property) ?? "";
55
- const priority = shorthandPriority && prior ? "" : prior;
40
+ const priority =
41
+ !this._priorities.get(shorthand) && this._priorities.has(property)
42
+ ? this._priorities.get(property)
43
+ : "";
56
44
  this._positionLonghandSetter(property, val, priority, shorthand);
57
45
  }
58
46
  }
@@ -63,3 +51,5 @@ module.exports.definition = {
63
51
  enumerable: true,
64
52
  configurable: true
65
53
  };
54
+
55
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const shorthand = "padding";
7
7
 
8
8
  module.exports.position = "left";
9
9
 
10
- module.exports.parse = function parse(v, opt = {}) {
10
+ module.exports.parse = (v, opt = {}) => {
11
11
  const { globalObject } = opt;
12
12
  if (v === "") {
13
13
  return v;
@@ -17,23 +17,10 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ isNumber, name, type, value: itemValue }] = value;
21
- switch (type) {
22
- case "Calc": {
23
- if (isNumber) {
24
- return;
25
- }
26
- return `${name}(${itemValue})`;
27
- }
28
- case "GlobalKeyword": {
29
- return name;
30
- }
31
- default: {
32
- return parsers.parseLengthPercentage(value, {
33
- min: 0
34
- });
35
- }
36
- }
20
+ return parsers.resolveNumericValue(value, {
21
+ min: 0,
22
+ type: "length"
23
+ });
37
24
  } else if (typeof value === "string") {
38
25
  return value;
39
26
  }
@@ -41,7 +28,7 @@ module.exports.parse = function parse(v, opt = {}) {
41
28
 
42
29
  module.exports.definition = {
43
30
  set(v) {
44
- v = parsers.prepareValue(v, this._global);
31
+ v = parsers.prepareValue(v);
45
32
  if (parsers.hasVarFunc(v)) {
46
33
  this._setProperty(shorthand, "");
47
34
  this._setProperty(property, v);
@@ -50,9 +37,10 @@ module.exports.definition = {
50
37
  globalObject: this._global
51
38
  });
52
39
  if (typeof val === "string") {
53
- const shorthandPriority = this._priorities.get(shorthand);
54
- const prior = this._priorities.get(property) ?? "";
55
- const priority = shorthandPriority && prior ? "" : prior;
40
+ const priority =
41
+ !this._priorities.get(shorthand) && this._priorities.has(property)
42
+ ? this._priorities.get(property)
43
+ : "";
56
44
  this._positionLonghandSetter(property, val, priority, shorthand);
57
45
  }
58
46
  }
@@ -63,3 +51,5 @@ module.exports.definition = {
63
51
  enumerable: true,
64
52
  configurable: true
65
53
  };
54
+
55
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const shorthand = "padding";
7
7
 
8
8
  module.exports.position = "right";
9
9
 
10
- module.exports.parse = function parse(v, opt = {}) {
10
+ module.exports.parse = (v, opt = {}) => {
11
11
  const { globalObject } = opt;
12
12
  if (v === "") {
13
13
  return v;
@@ -17,23 +17,10 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ isNumber, name, type, value: itemValue }] = value;
21
- switch (type) {
22
- case "Calc": {
23
- if (isNumber) {
24
- return;
25
- }
26
- return `${name}(${itemValue})`;
27
- }
28
- case "GlobalKeyword": {
29
- return name;
30
- }
31
- default: {
32
- return parsers.parseLengthPercentage(value, {
33
- min: 0
34
- });
35
- }
36
- }
20
+ return parsers.resolveNumericValue(value, {
21
+ min: 0,
22
+ type: "length"
23
+ });
37
24
  } else if (typeof value === "string") {
38
25
  return value;
39
26
  }
@@ -41,7 +28,7 @@ module.exports.parse = function parse(v, opt = {}) {
41
28
 
42
29
  module.exports.definition = {
43
30
  set(v) {
44
- v = parsers.prepareValue(v, this._global);
31
+ v = parsers.prepareValue(v);
45
32
  if (parsers.hasVarFunc(v)) {
46
33
  this._setProperty(shorthand, "");
47
34
  this._setProperty(property, v);
@@ -50,9 +37,10 @@ module.exports.definition = {
50
37
  globalObject: this._global
51
38
  });
52
39
  if (typeof val === "string") {
53
- const shorthandPriority = this._priorities.get(shorthand);
54
- const prior = this._priorities.get(property) ?? "";
55
- const priority = shorthandPriority && prior ? "" : prior;
40
+ const priority =
41
+ !this._priorities.get(shorthand) && this._priorities.has(property)
42
+ ? this._priorities.get(property)
43
+ : "";
56
44
  this._positionLonghandSetter(property, val, priority, shorthand);
57
45
  }
58
46
  }
@@ -63,3 +51,5 @@ module.exports.definition = {
63
51
  enumerable: true,
64
52
  configurable: true
65
53
  };
54
+
55
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const shorthand = "padding";
7
7
 
8
8
  module.exports.position = "top";
9
9
 
10
- module.exports.parse = function parse(v, opt = {}) {
10
+ module.exports.parse = (v, opt = {}) => {
11
11
  const { globalObject } = opt;
12
12
  if (v === "") {
13
13
  return v;
@@ -17,23 +17,10 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ isNumber, name, type, value: itemValue }] = value;
21
- switch (type) {
22
- case "Calc": {
23
- if (isNumber) {
24
- return;
25
- }
26
- return `${name}(${itemValue})`;
27
- }
28
- case "GlobalKeyword": {
29
- return name;
30
- }
31
- default: {
32
- return parsers.parseLengthPercentage(value, {
33
- min: 0
34
- });
35
- }
36
- }
20
+ return parsers.resolveNumericValue(value, {
21
+ min: 0,
22
+ type: "length"
23
+ });
37
24
  } else if (typeof value === "string") {
38
25
  return value;
39
26
  }
@@ -41,7 +28,7 @@ module.exports.parse = function parse(v, opt = {}) {
41
28
 
42
29
  module.exports.definition = {
43
30
  set(v) {
44
- v = parsers.prepareValue(v, this._global);
31
+ v = parsers.prepareValue(v);
45
32
  if (parsers.hasVarFunc(v)) {
46
33
  this._setProperty(shorthand, "");
47
34
  this._setProperty(property, v);
@@ -50,9 +37,10 @@ module.exports.definition = {
50
37
  globalObject: this._global
51
38
  });
52
39
  if (typeof val === "string") {
53
- const shorthandPriority = this._priorities.get(shorthand);
54
- const prior = this._priorities.get(property) ?? "";
55
- const priority = shorthandPriority && prior ? "" : prior;
40
+ const priority =
41
+ !this._priorities.get(shorthand) && this._priorities.has(property)
42
+ ? this._priorities.get(property)
43
+ : "";
56
44
  this._positionLonghandSetter(property, val, priority, shorthand);
57
45
  }
58
46
  }
@@ -63,3 +51,5 @@ module.exports.definition = {
63
51
  enumerable: true,
64
52
  configurable: true
65
53
  };
54
+
55
+ module.exports.property = property;
@@ -4,7 +4,7 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "right";
6
6
 
7
- module.exports.parse = function parse(v, opt = {}) {
7
+ module.exports.parse = (v, opt = {}) => {
8
8
  const { globalObject } = opt;
9
9
  if (v === "") {
10
10
  return v;
@@ -14,22 +14,9 @@ module.exports.parse = function parse(v, opt = {}) {
14
14
  inArray: true
15
15
  });
16
16
  if (Array.isArray(value) && value.length === 1) {
17
- const [{ isNumber, name, type, value: itemValue }] = value;
18
- switch (type) {
19
- case "Calc": {
20
- if (isNumber) {
21
- return;
22
- }
23
- return `${name}(${itemValue})`;
24
- }
25
- case "GlobalKeyword":
26
- case "Identifier": {
27
- return name;
28
- }
29
- default: {
30
- return parsers.parseLengthPercentage(value);
31
- }
32
- }
17
+ return parsers.resolveNumericValue(value, {
18
+ type: "length"
19
+ });
33
20
  } else if (typeof value === "string") {
34
21
  return value;
35
22
  }
@@ -37,7 +24,7 @@ module.exports.parse = function parse(v, opt = {}) {
37
24
 
38
25
  module.exports.definition = {
39
26
  set(v) {
40
- v = parsers.prepareValue(v, this._global);
27
+ v = parsers.prepareValue(v);
41
28
  if (parsers.hasVarFunc(v)) {
42
29
  this._setProperty(property, v);
43
30
  } else {
@@ -56,3 +43,5 @@ module.exports.definition = {
56
43
  enumerable: true,
57
44
  configurable: true
58
45
  };
46
+
47
+ module.exports.property = property;