cssstyle 5.3.4 → 5.3.6

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 +2 -2
  2. package/lib/generated/implementedProperties.js +245 -1096
  3. package/lib/generated/properties.js +1959 -2272
  4. package/lib/generated/propertyDefinitions.js +13033 -0
  5. package/lib/normalize.js +1259 -1095
  6. package/lib/parsers.js +588 -228
  7. package/lib/properties/background.js +89 -79
  8. package/lib/properties/backgroundAttachment.js +11 -14
  9. package/lib/properties/backgroundClip.js +11 -14
  10. package/lib/properties/backgroundColor.js +8 -13
  11. package/lib/properties/backgroundImage.js +11 -26
  12. package/lib/properties/backgroundOrigin.js +11 -14
  13. package/lib/properties/backgroundPosition.js +29 -18
  14. package/lib/properties/backgroundRepeat.js +11 -7
  15. package/lib/properties/backgroundSize.js +22 -16
  16. package/lib/properties/border.js +30 -87
  17. package/lib/properties/borderBottom.js +30 -86
  18. package/lib/properties/borderBottomColor.js +8 -14
  19. package/lib/properties/borderBottomStyle.js +8 -13
  20. package/lib/properties/borderBottomWidth.js +11 -23
  21. package/lib/properties/borderCollapse.js +4 -9
  22. package/lib/properties/borderColor.js +17 -23
  23. package/lib/properties/borderLeft.js +30 -86
  24. package/lib/properties/borderLeftColor.js +8 -14
  25. package/lib/properties/borderLeftStyle.js +8 -13
  26. package/lib/properties/borderLeftWidth.js +11 -23
  27. package/lib/properties/borderRight.js +30 -86
  28. package/lib/properties/borderRightColor.js +8 -14
  29. package/lib/properties/borderRightStyle.js +8 -13
  30. package/lib/properties/borderRightWidth.js +11 -23
  31. package/lib/properties/borderSpacing.js +12 -9
  32. package/lib/properties/borderStyle.js +17 -23
  33. package/lib/properties/borderTop.js +30 -86
  34. package/lib/properties/borderTopColor.js +8 -14
  35. package/lib/properties/borderTopStyle.js +8 -13
  36. package/lib/properties/borderTopWidth.js +11 -23
  37. package/lib/properties/borderWidth.js +18 -36
  38. package/lib/properties/bottom.js +6 -17
  39. package/lib/properties/clear.js +4 -9
  40. package/lib/properties/clip.js +11 -6
  41. package/lib/properties/color.js +4 -10
  42. package/lib/properties/display.js +11 -8
  43. package/lib/properties/flex.js +55 -53
  44. package/lib/properties/flexBasis.js +10 -20
  45. package/lib/properties/flexGrow.js +10 -19
  46. package/lib/properties/flexShrink.js +10 -19
  47. package/lib/properties/float.js +4 -9
  48. package/lib/properties/floodColor.js +4 -10
  49. package/lib/properties/font.js +46 -33
  50. package/lib/properties/fontFamily.js +16 -12
  51. package/lib/properties/fontSize.js +11 -22
  52. package/lib/properties/fontStyle.js +14 -8
  53. package/lib/properties/fontVariant.js +11 -18
  54. package/lib/properties/fontWeight.js +14 -25
  55. package/lib/properties/height.js +7 -17
  56. package/lib/properties/left.js +6 -17
  57. package/lib/properties/lightingColor.js +4 -10
  58. package/lib/properties/lineHeight.js +10 -24
  59. package/lib/properties/margin.js +14 -32
  60. package/lib/properties/marginBottom.js +10 -20
  61. package/lib/properties/marginLeft.js +10 -20
  62. package/lib/properties/marginRight.js +10 -20
  63. package/lib/properties/marginTop.js +10 -20
  64. package/lib/properties/opacity.js +6 -18
  65. package/lib/properties/outlineColor.js +4 -10
  66. package/lib/properties/padding.js +15 -30
  67. package/lib/properties/paddingBottom.js +11 -21
  68. package/lib/properties/paddingLeft.js +11 -21
  69. package/lib/properties/paddingRight.js +11 -21
  70. package/lib/properties/paddingTop.js +11 -21
  71. package/lib/properties/right.js +6 -17
  72. package/lib/properties/stopColor.js +4 -10
  73. package/lib/properties/top.js +7 -17
  74. package/lib/properties/webkitBorderAfterColor.js +4 -10
  75. package/lib/properties/webkitBorderBeforeColor.js +4 -10
  76. package/lib/properties/webkitBorderEndColor.js +4 -10
  77. package/lib/properties/webkitBorderStartColor.js +4 -10
  78. package/lib/properties/webkitColumnRuleColor.js +4 -10
  79. package/lib/properties/webkitTapHighlightColor.js +4 -10
  80. package/lib/properties/webkitTextEmphasisColor.js +4 -10
  81. package/lib/properties/webkitTextFillColor.js +4 -10
  82. package/lib/properties/webkitTextStrokeColor.js +4 -10
  83. package/lib/properties/width.js +7 -17
  84. package/lib/utils/propertyDescriptors.js +49 -13
  85. package/lib/utils/strings.js +6 -0
  86. package/package.json +16 -40
@@ -7,7 +7,7 @@ const lineShorthand = "border-width";
7
7
  const positionShorthand = "border-bottom";
8
8
  const shorthand = "border";
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,24 +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
- case "Identifier": {
30
- return name;
31
- }
32
- default: {
33
- return parsers.parseLength(value, {
34
- min: 0
35
- });
36
- }
37
- }
20
+ return parsers.resolveNumericValue(value, {
21
+ min: 0,
22
+ type: "length"
23
+ });
38
24
  } else if (typeof value === "string") {
39
25
  return value;
40
26
  }
@@ -53,10 +39,10 @@ module.exports.definition = {
53
39
  const shorthandPriority = this._priorities.get(shorthand);
54
40
  const linePriority = this._priorities.get(lineShorthand);
55
41
  const positionPriority = this._priorities.get(positionShorthand);
56
- let priority = this._priorities.get(property) ?? "";
57
- if ((shorthandPriority || linePriority || positionPriority) && priority) {
58
- priority = "";
59
- }
42
+ const priority =
43
+ !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property)
44
+ ? this._priorities.get(property)
45
+ : "";
60
46
  this._borderSetter(property, val, priority);
61
47
  }
62
48
  }
@@ -67,3 +53,5 @@ module.exports.definition = {
67
53
  enumerable: true,
68
54
  configurable: true
69
55
  };
56
+
57
+ module.exports.property = property;
@@ -4,7 +4,7 @@ const parsers = require("../parsers");
4
4
 
5
5
  const property = "border-collapse";
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,14 +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
- case "Identifier": {
21
- return name;
22
- }
23
- default:
24
- }
17
+ return parsers.resolveKeywordValue(value);
25
18
  } else if (typeof value === "string") {
26
19
  return value;
27
20
  }
@@ -48,3 +41,5 @@ module.exports.definition = {
48
41
  enumerable: true,
49
42
  configurable: true
50
43
  };
44
+
45
+ module.exports.property = property;
@@ -10,13 +10,13 @@ const property = "border-color";
10
10
  const shorthand = "border";
11
11
 
12
12
  module.exports.shorthandFor = new Map([
13
- ["border-top-color", borderTopColor],
14
- ["border-right-color", borderRightColor],
15
- ["border-bottom-color", borderBottomColor],
16
- ["border-left-color", borderLeftColor]
13
+ [borderTopColor.property, borderTopColor],
14
+ [borderRightColor.property, borderRightColor],
15
+ [borderBottomColor.property, borderBottomColor],
16
+ [borderLeftColor.property, borderLeftColor]
17
17
  ]);
18
18
 
19
- module.exports.parse = function parse(v, opt = {}) {
19
+ module.exports.parse = (v, opt = {}) => {
20
20
  const { globalObject } = opt;
21
21
  if (v === "") {
22
22
  return v;
@@ -31,22 +31,13 @@ module.exports.parse = function parse(v, opt = {}) {
31
31
  return;
32
32
  }
33
33
  for (const value of values) {
34
- const { name, type } = value;
35
- switch (type) {
36
- case "GlobalKeyword": {
37
- if (values.length !== 1) {
38
- return;
39
- }
40
- return name;
41
- }
42
- default: {
43
- const parsedValue = parsers.parseColor([value]);
44
- if (!parsedValue) {
45
- return;
46
- }
47
- parsedValues.push(parsedValue);
48
- }
34
+ const parsedValue = parsers.resolveColorValue([value], {
35
+ length: values.length
36
+ });
37
+ if (!parsedValue) {
38
+ return;
49
39
  }
40
+ parsedValues.push(parsedValue);
50
41
  }
51
42
  } else if (typeof values === "string") {
52
43
  parsedValues.push(values);
@@ -101,9 +92,10 @@ module.exports.definition = {
101
92
  globalObject: this._global
102
93
  });
103
94
  if (Array.isArray(val) || typeof val === "string") {
104
- const shorthandPriority = this._priorities.get(shorthand);
105
- const prior = this._priorities.get(property) ?? "";
106
- const priority = shorthandPriority && prior ? "" : prior;
95
+ const priority =
96
+ !this._priorities.get(shorthand) && this._priorities.has(property)
97
+ ? this._priorities.get(property)
98
+ : "";
107
99
  this._borderSetter(property, val, priority);
108
100
  }
109
101
  }
@@ -114,3 +106,5 @@ module.exports.definition = {
114
106
  enumerable: true,
115
107
  configurable: true
116
108
  };
109
+
110
+ module.exports.property = property;
@@ -8,19 +8,25 @@ const borderLeftColor = require("./borderLeftColor");
8
8
  const property = "border-left";
9
9
  const shorthand = "border";
10
10
 
11
+ const subProps = {
12
+ width: borderLeftWidth.property,
13
+ style: borderLeftStyle.property,
14
+ color: borderLeftColor.property
15
+ };
16
+
11
17
  module.exports.initialValues = new Map([
12
- ["border-left-width", "medium"],
13
- ["border-left-style", "none"],
14
- ["border-left-color", "currentcolor"]
18
+ [borderLeftWidth.property, "medium"],
19
+ [borderLeftStyle.property, "none"],
20
+ [borderLeftColor.property, "currentcolor"]
15
21
  ]);
16
22
 
17
23
  module.exports.shorthandFor = new Map([
18
- ["border-left-width", borderLeftWidth],
19
- ["border-left-style", borderLeftStyle],
20
- ["border-left-color", borderLeftColor]
24
+ [borderLeftWidth.property, borderLeftWidth],
25
+ [borderLeftStyle.property, borderLeftStyle],
26
+ [borderLeftColor.property, borderLeftColor]
21
27
  ]);
22
28
 
23
- module.exports.parse = function parse(v, opt = {}) {
29
+ module.exports.parse = (v, opt = {}) => {
24
30
  const { globalObject } = opt;
25
31
  if (v === "") {
26
32
  return v;
@@ -33,79 +39,14 @@ module.exports.parse = function parse(v, opt = {}) {
33
39
  inArray: true
34
40
  });
35
41
  if (Array.isArray(value) && value.length === 1) {
36
- const [{ isNumber, name, type, value: itemValue }] = value;
37
- switch (type) {
38
- case "Calc": {
39
- if (isNumber || parsedValues.has("border-left-width")) {
40
- return;
41
- }
42
- parsedValues.set("border-left-width", `${name}(${itemValue})`);
43
- break;
44
- }
45
- case "Dimension":
46
- case "Number": {
47
- if (parsedValues.has("border-left-width")) {
48
- return;
49
- }
50
- const parsedValue = parsers.parseLength(value, {
51
- min: 0
52
- });
53
- if (!parsedValue) {
54
- return;
55
- }
56
- parsedValues.set("border-left-width", parsedValue);
57
- break;
58
- }
59
- case "Function": {
60
- if (parsedValues.has("border-left-color")) {
61
- return;
62
- }
63
- const parsedValue = parsers.parseColor(value);
64
- if (!parsedValue) {
65
- return;
66
- }
67
- parsedValues.set("border-left-color", parsedValue);
68
- break;
69
- }
70
- case "GlobalKeyword": {
71
- return name;
72
- }
73
- case "Hash": {
74
- if (parsedValues.has("border-left-color")) {
75
- return;
76
- }
77
- const parsedValue = parsers.parseColor(value);
78
- if (!parsedValue) {
79
- return;
80
- }
81
- parsedValues.set("border-left-color", parsedValue);
82
- break;
83
- }
84
- case "Identifier": {
85
- if (parsers.isValidPropertyValue("border-left-width", name)) {
86
- if (parsedValues.has("border-left-width")) {
87
- return;
88
- }
89
- parsedValues.set("border-left-width", name);
90
- break;
91
- } else if (parsers.isValidPropertyValue("border-left-style", name)) {
92
- if (parsedValues.has("border-left-style")) {
93
- return;
94
- }
95
- parsedValues.set("border-left-style", name);
96
- break;
97
- } else if (parsers.isValidPropertyValue("border-left-color", name)) {
98
- if (parsedValues.has("border-left-color")) {
99
- return;
100
- }
101
- parsedValues.set("border-left-color", name);
102
- break;
103
- }
104
- return;
105
- }
106
- default: {
107
- return;
108
- }
42
+ const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues);
43
+ if (typeof parsedValue === "string") {
44
+ return parsedValue;
45
+ } else if (Array.isArray(parsedValue)) {
46
+ const [key, resolvedVal] = parsedValue;
47
+ parsedValues.set(key, resolvedVal);
48
+ } else {
49
+ return;
109
50
  }
110
51
  } else {
111
52
  return;
@@ -114,15 +55,15 @@ module.exports.parse = function parse(v, opt = {}) {
114
55
  if (parsedValues.size) {
115
56
  const keys = module.exports.shorthandFor.keys();
116
57
  const obj = {
117
- "border-left-width": "medium"
58
+ [borderLeftWidth.property]: "medium"
118
59
  };
119
60
  for (const key of keys) {
120
61
  if (parsedValues.has(key)) {
121
62
  const parsedValue = parsedValues.get(key);
122
63
  if (parsedValue !== module.exports.initialValues.get(key)) {
123
64
  obj[key] = parsedValues.get(key);
124
- if (obj["border-left-width"] && obj["border-left-width"] === "medium") {
125
- delete obj["border-left-width"];
65
+ if (obj[borderLeftWidth.property] && obj[borderLeftWidth.property] === "medium") {
66
+ delete obj[borderLeftWidth.property];
126
67
  }
127
68
  }
128
69
  }
@@ -141,9 +82,10 @@ module.exports.definition = {
141
82
  globalObject: this._global
142
83
  });
143
84
  if (val || typeof val === "string") {
144
- const shorthandPriority = this._priorities.get(shorthand);
145
- const prior = this._priorities.get(property) ?? "";
146
- const priority = shorthandPriority && prior ? "" : prior;
85
+ const priority =
86
+ !this._priorities.get(shorthand) && this._priorities.has(property)
87
+ ? this._priorities.get(property)
88
+ : "";
147
89
  this._borderSetter(property, val, priority);
148
90
  }
149
91
  }
@@ -154,3 +96,5 @@ module.exports.definition = {
154
96
  enumerable: true,
155
97
  configurable: true
156
98
  };
99
+
100
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const lineShorthand = "border-color";
7
7
  const positionShorthand = "border-left";
8
8
  const shorthand = "border";
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,15 +17,7 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ name, type }] = value;
21
- switch (type) {
22
- case "GlobalKeyword": {
23
- return name;
24
- }
25
- default: {
26
- return parsers.parseColor(value);
27
- }
28
- }
20
+ return parsers.resolveColorValue(value);
29
21
  } else if (typeof value === "string") {
30
22
  return value;
31
23
  }
@@ -44,10 +36,10 @@ module.exports.definition = {
44
36
  const shorthandPriority = this._priorities.get(shorthand);
45
37
  const linePriority = this._priorities.get(lineShorthand);
46
38
  const positionPriority = this._priorities.get(positionShorthand);
47
- let priority = this._priorities.get(property) ?? "";
48
- if ((shorthandPriority || linePriority || positionPriority) && priority) {
49
- priority = "";
50
- }
39
+ const priority =
40
+ !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property)
41
+ ? this._priorities.get(property)
42
+ : "";
51
43
  this._borderSetter(property, val, priority);
52
44
  }
53
45
  }
@@ -58,3 +50,5 @@ module.exports.definition = {
58
50
  enumerable: true,
59
51
  configurable: true
60
52
  };
53
+
54
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const lineShorthand = "border-style";
7
7
  const positionShorthand = "border-left";
8
8
  const shorthand = "border";
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,14 +17,7 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ name, type }] = value;
21
- switch (type) {
22
- case "GlobalKeyword":
23
- case "Identifier": {
24
- return name;
25
- }
26
- default:
27
- }
20
+ return parsers.resolveKeywordValue(value);
28
21
  } else if (typeof value === "string") {
29
22
  return value;
30
23
  }
@@ -43,10 +36,10 @@ module.exports.definition = {
43
36
  const shorthandPriority = this._priorities.get(shorthand);
44
37
  const linePriority = this._priorities.get(lineShorthand);
45
38
  const positionPriority = this._priorities.get(positionShorthand);
46
- let priority = this._priorities.get(property) ?? "";
47
- if ((shorthandPriority || linePriority || positionPriority) && priority) {
48
- priority = "";
49
- }
39
+ const priority =
40
+ !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property)
41
+ ? this._priorities.get(property)
42
+ : "";
50
43
  this._borderSetter(property, val, priority);
51
44
  }
52
45
  }
@@ -57,3 +50,5 @@ module.exports.definition = {
57
50
  enumerable: true,
58
51
  configurable: true
59
52
  };
53
+
54
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const lineShorthand = "border-width";
7
7
  const positionShorthand = "border-left";
8
8
  const shorthand = "border";
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,24 +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
- case "Identifier": {
30
- return name;
31
- }
32
- default: {
33
- return parsers.parseLength(value, {
34
- min: 0
35
- });
36
- }
37
- }
20
+ return parsers.resolveNumericValue(value, {
21
+ min: 0,
22
+ type: "length"
23
+ });
38
24
  } else if (typeof value === "string") {
39
25
  return value;
40
26
  }
@@ -53,10 +39,10 @@ module.exports.definition = {
53
39
  const shorthandPriority = this._priorities.get(shorthand);
54
40
  const linePriority = this._priorities.get(lineShorthand);
55
41
  const positionPriority = this._priorities.get(positionShorthand);
56
- let priority = this._priorities.get(property) ?? "";
57
- if ((shorthandPriority || linePriority || positionPriority) && priority) {
58
- priority = "";
59
- }
42
+ const priority =
43
+ !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property)
44
+ ? this._priorities.get(property)
45
+ : "";
60
46
  this._borderSetter(property, val, priority);
61
47
  }
62
48
  }
@@ -67,3 +53,5 @@ module.exports.definition = {
67
53
  enumerable: true,
68
54
  configurable: true
69
55
  };
56
+
57
+ module.exports.property = property;
@@ -8,19 +8,25 @@ const borderRightColor = require("./borderRightColor");
8
8
  const property = "border-right";
9
9
  const shorthand = "border";
10
10
 
11
+ const subProps = {
12
+ width: borderRightWidth.property,
13
+ style: borderRightStyle.property,
14
+ color: borderRightColor.property
15
+ };
16
+
11
17
  module.exports.initialValues = new Map([
12
- ["border-right-width", "medium"],
13
- ["border-right-style", "none"],
14
- ["border-right-color", "currentcolor"]
18
+ [borderRightWidth.property, "medium"],
19
+ [borderRightStyle.property, "none"],
20
+ [borderRightColor.property, "currentcolor"]
15
21
  ]);
16
22
 
17
23
  module.exports.shorthandFor = new Map([
18
- ["border-right-width", borderRightWidth],
19
- ["border-right-style", borderRightStyle],
20
- ["border-right-color", borderRightColor]
24
+ [borderRightWidth.property, borderRightWidth],
25
+ [borderRightStyle.property, borderRightStyle],
26
+ [borderRightColor.property, borderRightColor]
21
27
  ]);
22
28
 
23
- module.exports.parse = function parse(v, opt = {}) {
29
+ module.exports.parse = (v, opt = {}) => {
24
30
  const { globalObject } = opt;
25
31
  if (v === "") {
26
32
  return v;
@@ -33,79 +39,14 @@ module.exports.parse = function parse(v, opt = {}) {
33
39
  inArray: true
34
40
  });
35
41
  if (Array.isArray(value) && value.length === 1) {
36
- const [{ isNumber, name, type, value: itemValue }] = value;
37
- switch (type) {
38
- case "Calc": {
39
- if (isNumber || parsedValues.has("border-right-width")) {
40
- return;
41
- }
42
- parsedValues.set("border-right-width", `${name}(${itemValue})`);
43
- break;
44
- }
45
- case "Dimension":
46
- case "Number": {
47
- if (parsedValues.has("border-right-width")) {
48
- return;
49
- }
50
- const parsedValue = parsers.parseLength(value, {
51
- min: 0
52
- });
53
- if (!parsedValue) {
54
- return;
55
- }
56
- parsedValues.set("border-right-width", parsedValue);
57
- break;
58
- }
59
- case "Function": {
60
- if (parsedValues.has("border-right-color")) {
61
- return;
62
- }
63
- const parsedValue = parsers.parseColor(value);
64
- if (!parsedValue) {
65
- return;
66
- }
67
- parsedValues.set("border-right-color", parsedValue);
68
- break;
69
- }
70
- case "GlobalKeyword": {
71
- return name;
72
- }
73
- case "Hash": {
74
- if (parsedValues.has("border-right-color")) {
75
- return;
76
- }
77
- const parsedValue = parsers.parseColor(value);
78
- if (!parsedValue) {
79
- return;
80
- }
81
- parsedValues.set("border-right-color", parsedValue);
82
- break;
83
- }
84
- case "Identifier": {
85
- if (parsers.isValidPropertyValue("border-right-width", name)) {
86
- if (parsedValues.has("border-right-width")) {
87
- return;
88
- }
89
- parsedValues.set("border-right-width", name);
90
- break;
91
- } else if (parsers.isValidPropertyValue("border-right-style", name)) {
92
- if (parsedValues.has("border-right-style")) {
93
- return;
94
- }
95
- parsedValues.set("border-right-style", name);
96
- break;
97
- } else if (parsers.isValidPropertyValue("border-right-color", name)) {
98
- if (parsedValues.has("border-right-color")) {
99
- return;
100
- }
101
- parsedValues.set("border-right-color", name);
102
- break;
103
- }
104
- return;
105
- }
106
- default: {
107
- return;
108
- }
42
+ const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues);
43
+ if (typeof parsedValue === "string") {
44
+ return parsedValue;
45
+ } else if (Array.isArray(parsedValue)) {
46
+ const [key, resolvedVal] = parsedValue;
47
+ parsedValues.set(key, resolvedVal);
48
+ } else {
49
+ return;
109
50
  }
110
51
  } else {
111
52
  return;
@@ -114,15 +55,15 @@ module.exports.parse = function parse(v, opt = {}) {
114
55
  if (parsedValues.size) {
115
56
  const keys = module.exports.shorthandFor.keys();
116
57
  const obj = {
117
- "border-right-width": "medium"
58
+ [borderRightWidth.property]: "medium"
118
59
  };
119
60
  for (const key of keys) {
120
61
  if (parsedValues.has(key)) {
121
62
  const parsedValue = parsedValues.get(key);
122
63
  if (parsedValue !== module.exports.initialValues.get(key)) {
123
64
  obj[key] = parsedValues.get(key);
124
- if (obj["border-right-width"] && obj["border-right-width"] === "medium") {
125
- delete obj["border-right-width"];
65
+ if (obj[borderRightWidth.property] && obj[borderRightWidth.property] === "medium") {
66
+ delete obj[borderRightWidth.property];
126
67
  }
127
68
  }
128
69
  }
@@ -141,9 +82,10 @@ module.exports.definition = {
141
82
  globalObject: this._global
142
83
  });
143
84
  if (val || typeof val === "string") {
144
- const shorthandPriority = this._priorities.get(shorthand);
145
- const prior = this._priorities.get(property) ?? "";
146
- const priority = shorthandPriority && prior ? "" : prior;
85
+ const priority =
86
+ !this._priorities.get(shorthand) && this._priorities.has(property)
87
+ ? this._priorities.get(property)
88
+ : "";
147
89
  this._borderSetter(property, val, priority);
148
90
  }
149
91
  }
@@ -154,3 +96,5 @@ module.exports.definition = {
154
96
  enumerable: true,
155
97
  configurable: true
156
98
  };
99
+
100
+ module.exports.property = property;
@@ -7,7 +7,7 @@ const lineShorthand = "border-color";
7
7
  const positionShorthand = "border-right";
8
8
  const shorthand = "border";
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,15 +17,7 @@ module.exports.parse = function parse(v, opt = {}) {
17
17
  inArray: true
18
18
  });
19
19
  if (Array.isArray(value) && value.length === 1) {
20
- const [{ name, type }] = value;
21
- switch (type) {
22
- case "GlobalKeyword": {
23
- return name;
24
- }
25
- default: {
26
- return parsers.parseColor(value);
27
- }
28
- }
20
+ return parsers.resolveColorValue(value);
29
21
  } else if (typeof value === "string") {
30
22
  return value;
31
23
  }
@@ -44,10 +36,10 @@ module.exports.definition = {
44
36
  const shorthandPriority = this._priorities.get(shorthand);
45
37
  const linePriority = this._priorities.get(lineShorthand);
46
38
  const positionPriority = this._priorities.get(positionShorthand);
47
- let priority = this._priorities.get(property) ?? "";
48
- if ((shorthandPriority || linePriority || positionPriority) && priority) {
49
- priority = "";
50
- }
39
+ const priority =
40
+ !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property)
41
+ ? this._priorities.get(property)
42
+ : "";
51
43
  this._borderSetter(property, val, priority);
52
44
  }
53
45
  }
@@ -58,3 +50,5 @@ module.exports.definition = {
58
50
  enumerable: true,
59
51
  configurable: true
60
52
  };
53
+
54
+ module.exports.property = property;