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
@@ -10,11 +10,12 @@ const keywordsX = ["center", ...keyX];
10
10
  const keywordsY = ["center", ...keyY];
11
11
  const keywords = ["center", ...keyX, ...keyY];
12
12
 
13
- module.exports.parse = function parse(v, opt = {}) {
13
+ module.exports.parse = (v, opt = {}) => {
14
14
  const { globalObject } = opt;
15
15
  if (v === "") {
16
16
  return v;
17
17
  }
18
+ const { AST_TYPES } = parsers;
18
19
  const values = parsers.splitValue(v, {
19
20
  delimiter: ","
20
21
  });
@@ -25,12 +26,14 @@ module.exports.parse = function parse(v, opt = {}) {
25
26
  inArray: true
26
27
  });
27
28
  if (Array.isArray(value) && value.length) {
29
+ const [part1, part2, part3, part4] = value;
28
30
  let parsedValue = "";
29
31
  switch (value.length) {
30
32
  case 1: {
31
- const [part1] = value;
32
33
  const val1 =
33
- part1.type === "Identifier" ? part1.name : parsers.parseLengthPercentage([part1]);
34
+ part1.type === AST_TYPES.IDENTIFIER
35
+ ? part1.name
36
+ : parsers.resolveNumericValue([part1], { type: "length" });
34
37
  if (val1) {
35
38
  if (val1 === "center") {
36
39
  parsedValue = `${val1} ${val1}`;
@@ -43,11 +46,14 @@ module.exports.parse = function parse(v, opt = {}) {
43
46
  break;
44
47
  }
45
48
  case 2: {
46
- const [part1, part2] = value;
47
49
  const val1 =
48
- part1.type === "Identifier" ? part1.name : parsers.parseLengthPercentage([part1]);
50
+ part1.type === AST_TYPES.IDENTIFIER
51
+ ? part1.name
52
+ : parsers.resolveNumericValue([part1], { type: "length" });
49
53
  const val2 =
50
- part2.type === "Identifier" ? part2.name : parsers.parseLengthPercentage([part2]);
54
+ part2.type === AST_TYPES.IDENTIFIER
55
+ ? part2.name
56
+ : parsers.resolveNumericValue([part2], { type: "length" });
51
57
  if (val1 && val2) {
52
58
  if (keywordsX.includes(val1) && keywordsY.includes(val2)) {
53
59
  parsedValue = `${val1} ${val2}`;
@@ -68,12 +74,15 @@ module.exports.parse = function parse(v, opt = {}) {
68
74
  break;
69
75
  }
70
76
  case 3: {
71
- const [part1, part2, part3] = value;
72
- const val1 = part1.type === "Identifier" && part1.name;
77
+ const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name;
73
78
  const val2 =
74
- part2.type === "Identifier" ? part2.name : parsers.parseLengthPercentage([part2]);
79
+ part2.type === AST_TYPES.IDENTIFIER
80
+ ? part2.name
81
+ : parsers.resolveNumericValue([part2], { type: "length" });
75
82
  const val3 =
76
- part3.type === "Identifier" ? part3.name : parsers.parseLengthPercentage([part3]);
83
+ part3.type === AST_TYPES.IDENTIFIER
84
+ ? part3.name
85
+ : parsers.resolveNumericValue([part3], { type: "length" });
77
86
  if (val1 && val2 && val3) {
78
87
  let posX = "";
79
88
  let offX = "";
@@ -119,11 +128,10 @@ module.exports.parse = function parse(v, opt = {}) {
119
128
  break;
120
129
  }
121
130
  case 4: {
122
- const [part1, part2, part3, part4] = value;
123
- const val1 = part1.type === "Identifier" && part1.name;
124
- const val2 = parsers.parseLengthPercentage([part2]);
125
- const val3 = part3.type === "Identifier" && part3.name;
126
- const val4 = parsers.parseLengthPercentage([part4]);
131
+ const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name;
132
+ const val2 = parsers.resolveNumericValue([part2], { type: "length" });
133
+ const val3 = part3.type === AST_TYPES.IDENTIFIER && part3.name;
134
+ const val4 = parsers.resolveNumericValue([part4], { type: "length" });
127
135
  if (val1 && val2 && val3 && val4) {
128
136
  let posX = "";
129
137
  let offX = "";
@@ -178,9 +186,10 @@ module.exports.definition = {
178
186
  globalObject: this._global
179
187
  });
180
188
  if (typeof val === "string") {
181
- const shorthandPriority = this._priorities.get(shorthand);
182
- const prior = this._priorities.get(property) ?? "";
183
- const priority = shorthandPriority && prior ? "" : prior;
189
+ const priority =
190
+ !this._priorities.get(shorthand) && this._priorities.has(property)
191
+ ? this._priorities.get(property)
192
+ : "";
184
193
  this._setProperty(property, val, priority);
185
194
  }
186
195
  }
@@ -191,3 +200,5 @@ module.exports.definition = {
191
200
  enumerable: true,
192
201
  configurable: true
193
202
  };
203
+
204
+ module.exports.property = property;
@@ -5,11 +5,12 @@ const parsers = require("../parsers");
5
5
  const property = "background-repeat";
6
6
  const shorthand = "background";
7
7
 
8
- module.exports.parse = function parse(v, opt = {}) {
8
+ module.exports.parse = (v, opt = {}) => {
9
9
  const { globalObject } = opt;
10
10
  if (v === "") {
11
11
  return v;
12
12
  }
13
+ const { AST_TYPES } = parsers;
13
14
  const values = parsers.splitValue(v, {
14
15
  delimiter: ","
15
16
  });
@@ -24,7 +25,7 @@ module.exports.parse = function parse(v, opt = {}) {
24
25
  switch (value.length) {
25
26
  case 1: {
26
27
  const [part1] = value;
27
- const val1 = part1.type === "Identifier" && part1.name;
28
+ const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name;
28
29
  if (val1) {
29
30
  parsedValue = val1;
30
31
  }
@@ -32,8 +33,8 @@ module.exports.parse = function parse(v, opt = {}) {
32
33
  }
33
34
  case 2: {
34
35
  const [part1, part2] = value;
35
- const val1 = part1.type === "Identifier" && part1.name;
36
- const val2 = part2.type === "Identifier" && part2.name;
36
+ const val1 = part1.type === AST_TYPES.IDENTIFIER && part1.name;
37
+ const val2 = part2.type === AST_TYPES.IDENTIFIER && part2.name;
37
38
  if (val1 && val2) {
38
39
  if (val1 === "repeat" && val2 === "no-repeat") {
39
40
  parsedValue = "repeat-x";
@@ -74,9 +75,10 @@ module.exports.definition = {
74
75
  globalObject: this._global
75
76
  });
76
77
  if (typeof val === "string") {
77
- const shorthandPriority = this._priorities.get(shorthand);
78
- const prior = this._priorities.get(property) ?? "";
79
- const priority = shorthandPriority && prior ? "" : prior;
78
+ const priority =
79
+ !this._priorities.get(shorthand) && this._priorities.has(property)
80
+ ? this._priorities.get(property)
81
+ : "";
80
82
  this._setProperty(property, val, priority);
81
83
  }
82
84
  }
@@ -87,3 +89,5 @@ module.exports.definition = {
87
89
  enumerable: true,
88
90
  configurable: true
89
91
  };
92
+
93
+ module.exports.property = property;
@@ -5,11 +5,12 @@ const parsers = require("../parsers");
5
5
  const property = "background-size";
6
6
  const shorthand = "background";
7
7
 
8
- module.exports.parse = function parse(v, opt = {}) {
8
+ module.exports.parse = (v, opt = {}) => {
9
9
  const { globalObject } = opt;
10
10
  if (v === "") {
11
11
  return v;
12
12
  }
13
+ const { AST_TYPES } = parsers;
13
14
  const values = parsers.splitValue(v, {
14
15
  delimiter: ","
15
16
  });
@@ -23,20 +24,22 @@ module.exports.parse = function parse(v, opt = {}) {
23
24
  if (value.length === 1) {
24
25
  const [{ isNumber, name, type, value: itemValue }] = value;
25
26
  switch (type) {
26
- case "Calc": {
27
+ case AST_TYPES.CALC: {
27
28
  if (isNumber) {
28
29
  return;
29
30
  }
30
31
  parsedValues.push(`${name}(${itemValue})`);
31
32
  break;
32
33
  }
33
- case "GlobalKeyword":
34
- case "Identifier": {
34
+ case AST_TYPES.GLOBAL_KEYWORD:
35
+ case AST_TYPES.IDENTIFIER: {
35
36
  parsedValues.push(name);
36
37
  break;
37
38
  }
38
39
  default: {
39
- const parsedValue = parsers.parseLengthPercentage(value);
40
+ const parsedValue = parsers.resolveNumericValue(value, {
41
+ type: "length"
42
+ });
40
43
  if (!parsedValue) {
41
44
  return;
42
45
  }
@@ -46,36 +49,36 @@ module.exports.parse = function parse(v, opt = {}) {
46
49
  } else {
47
50
  const [val1, val2] = value;
48
51
  const parts = [];
49
- if (val1.type === "Calc" && !val1.isNumber) {
52
+ if (val1.type === AST_TYPES.CALC && !val1.isNumber) {
50
53
  parts.push(`${val1.name}(${val1.value})`);
51
- } else if (val1.type === "Identifier") {
54
+ } else if (val1.type === AST_TYPES.IDENTIFIER) {
52
55
  parts.push(val1.name);
53
- } else if (val1.type === "Dimension") {
56
+ } else if (val1.type === AST_TYPES.DIMENSION) {
54
57
  parts.push(`${val1.value}${val1.unit}`);
55
- } else if (val1.type === "Percentage") {
58
+ } else if (val1.type === AST_TYPES.PERCENTAGE) {
56
59
  parts.push(`${val1.value}%`);
57
60
  } else {
58
61
  return;
59
62
  }
60
63
  switch (val2.type) {
61
- case "Calc": {
64
+ case AST_TYPES.CALC: {
62
65
  if (val2.isNumber) {
63
66
  return;
64
67
  }
65
68
  parts.push(`${val2.name}(${val2.value})`);
66
69
  break;
67
70
  }
68
- case "Dimension": {
71
+ case AST_TYPES.DIMENSION: {
69
72
  parts.push(`${val2.value}${val2.unit}`);
70
73
  break;
71
74
  }
72
- case "Identifier": {
75
+ case AST_TYPES.IDENTIFIER: {
73
76
  if (val2.name !== "auto") {
74
77
  parts.push(val2.name);
75
78
  }
76
79
  break;
77
80
  }
78
- case "Percentage": {
81
+ case AST_TYPES.PERCENTAGE: {
79
82
  parts.push(`${val2.value}%`);
80
83
  break;
81
84
  }
@@ -105,9 +108,10 @@ module.exports.definition = {
105
108
  globalObject: this._global
106
109
  });
107
110
  if (typeof val === "string") {
108
- const shorthandPriority = this._priorities.get(shorthand);
109
- const prior = this._priorities.get(property) ?? "";
110
- const priority = shorthandPriority && prior ? "" : prior;
111
+ const priority =
112
+ !this._priorities.get(shorthand) && this._priorities.has(property)
113
+ ? this._priorities.get(property)
114
+ : "";
111
115
  this._setProperty(property, val, priority);
112
116
  }
113
117
  }
@@ -118,3 +122,5 @@ module.exports.definition = {
118
122
  enumerable: true,
119
123
  configurable: true
120
124
  };
125
+
126
+ module.exports.property = property;
@@ -11,26 +11,32 @@ const borderLeft = require("./borderLeft");
11
11
 
12
12
  const property = "border";
13
13
 
14
+ const subProps = {
15
+ width: borderWidth.property,
16
+ style: borderStyle.property,
17
+ color: borderColor.property
18
+ };
19
+
14
20
  module.exports.initialValues = new Map([
15
- ["border-width", "medium"],
16
- ["border-style", "none"],
17
- ["border-color", "currentcolor"]
21
+ [borderWidth.property, "medium"],
22
+ [borderStyle.property, "none"],
23
+ [borderColor.property, "currentcolor"]
18
24
  ]);
19
25
 
20
26
  module.exports.shorthandFor = new Map([
21
- ["border-width", borderWidth],
22
- ["border-style", borderStyle],
23
- ["border-color", borderColor]
27
+ [borderWidth.property, borderWidth],
28
+ [borderStyle.property, borderStyle],
29
+ [borderColor.property, borderColor]
24
30
  ]);
25
31
 
26
32
  module.exports.positionShorthandFor = new Map([
27
- ["border-top", borderTop],
28
- ["border-right", borderRight],
29
- ["border-bottom", borderBottom],
30
- ["border-left", borderLeft]
33
+ [borderTop.property, borderTop],
34
+ [borderRight.property, borderRight],
35
+ [borderBottom.property, borderBottom],
36
+ [borderLeft.property, borderLeft]
31
37
  ]);
32
38
 
33
- module.exports.parse = function parse(v, opt = {}) {
39
+ module.exports.parse = (v, opt = {}) => {
34
40
  const { globalObject } = opt;
35
41
  if (v === "" || parsers.hasVarFunc(v)) {
36
42
  return v;
@@ -43,79 +49,14 @@ module.exports.parse = function parse(v, opt = {}) {
43
49
  inArray: true
44
50
  });
45
51
  if (Array.isArray(value) && value.length === 1) {
46
- const [{ isNumber, name, type, value: itemValue }] = value;
47
- switch (type) {
48
- case "Calc": {
49
- if (isNumber || parsedValues.has("border-width")) {
50
- return;
51
- }
52
- parsedValues.set("border-width", `${name}(${itemValue})`);
53
- break;
54
- }
55
- case "Dimension":
56
- case "Number": {
57
- if (parsedValues.has("border-width")) {
58
- return;
59
- }
60
- const parsedValue = parsers.parseLength(value, {
61
- min: 0
62
- });
63
- if (!parsedValue) {
64
- return;
65
- }
66
- parsedValues.set("border-width", parsedValue);
67
- break;
68
- }
69
- case "Function": {
70
- if (parsedValues.has("border-color")) {
71
- return;
72
- }
73
- const parsedValue = parsers.parseColor(value);
74
- if (!parsedValue) {
75
- return;
76
- }
77
- parsedValues.set("border-color", parsedValue);
78
- break;
79
- }
80
- case "GlobalKeyword": {
81
- return name;
82
- }
83
- case "Hash": {
84
- if (parsedValues.has("border-color")) {
85
- return;
86
- }
87
- const parsedValue = parsers.parseColor(value);
88
- if (!parsedValue) {
89
- return;
90
- }
91
- parsedValues.set("border-color", parsedValue);
92
- break;
93
- }
94
- case "Identifier": {
95
- if (parsers.isValidPropertyValue("border-width", name)) {
96
- if (parsedValues.has("border-width")) {
97
- return;
98
- }
99
- parsedValues.set("border-width", name);
100
- break;
101
- } else if (parsers.isValidPropertyValue("border-style", name)) {
102
- if (parsedValues.has("border-style")) {
103
- return;
104
- }
105
- parsedValues.set("border-style", name);
106
- break;
107
- } else if (parsers.isValidPropertyValue("border-color", name)) {
108
- if (parsedValues.has("border-color")) {
109
- return;
110
- }
111
- parsedValues.set("border-color", name);
112
- break;
113
- }
114
- return;
115
- }
116
- default: {
117
- return;
118
- }
52
+ const parsedValue = parsers.resolveBorderShorthandValue(value, subProps, parsedValues);
53
+ if (typeof parsedValue === "string") {
54
+ return parsedValue;
55
+ } else if (Array.isArray(parsedValue)) {
56
+ const [key, resolvedVal] = parsedValue;
57
+ parsedValues.set(key, resolvedVal);
58
+ } else {
59
+ return;
119
60
  }
120
61
  } else {
121
62
  return;
@@ -124,15 +65,15 @@ module.exports.parse = function parse(v, opt = {}) {
124
65
  if (parsedValues.size) {
125
66
  const keys = module.exports.shorthandFor.keys();
126
67
  const obj = {
127
- "border-width": "medium"
68
+ [borderWidth.property]: "medium"
128
69
  };
129
70
  for (const key of keys) {
130
71
  if (parsedValues.has(key)) {
131
72
  const parsedValue = parsedValues.get(key);
132
73
  if (parsedValue !== module.exports.initialValues.get(key)) {
133
74
  obj[key] = parsedValues.get(key);
134
- if (obj["border-width"] && obj["border-width"] === "medium") {
135
- delete obj["border-width"];
75
+ if (obj[borderWidth.property] && obj[borderWidth.property] === "medium") {
76
+ delete obj[borderWidth.property];
136
77
  }
137
78
  }
138
79
  }
@@ -162,3 +103,5 @@ module.exports.definition = {
162
103
  enumerable: true,
163
104
  configurable: true
164
105
  };
106
+
107
+ module.exports.property = property;
@@ -8,19 +8,25 @@ const borderBottomColor = require("./borderBottomColor");
8
8
  const property = "border-bottom";
9
9
  const shorthand = "border";
10
10
 
11
+ const subProps = {
12
+ width: borderBottomWidth.property,
13
+ style: borderBottomStyle.property,
14
+ color: borderBottomColor.property
15
+ };
16
+
11
17
  module.exports.initialValues = new Map([
12
- ["border-bottom-width", "medium"],
13
- ["border-bottom-style", "none"],
14
- ["border-bottom-color", "currentcolor"]
18
+ [borderBottomWidth.property, "medium"],
19
+ [borderBottomStyle.property, "none"],
20
+ [borderBottomColor.property, "currentcolor"]
15
21
  ]);
16
22
 
17
23
  module.exports.shorthandFor = new Map([
18
- ["border-bottom-width", borderBottomWidth],
19
- ["border-bottom-style", borderBottomStyle],
20
- ["border-bottom-color", borderBottomColor]
24
+ [borderBottomWidth.property, borderBottomWidth],
25
+ [borderBottomStyle.property, borderBottomStyle],
26
+ [borderBottomColor.property, borderBottomColor]
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-bottom-width")) {
40
- return;
41
- }
42
- parsedValues.set("border-bottom-width", `${name}(${itemValue})`);
43
- break;
44
- }
45
- case "Dimension":
46
- case "Number": {
47
- if (parsedValues.has("border-bottom-width")) {
48
- return;
49
- }
50
- const parsedValue = parsers.parseLength(value, {
51
- min: 0
52
- });
53
- if (!parsedValue) {
54
- return;
55
- }
56
- parsedValues.set("border-bottom-width", parsedValue);
57
- break;
58
- }
59
- case "Function": {
60
- if (parsedValues.has("border-bottom-color")) {
61
- return;
62
- }
63
- const parsedValue = parsers.parseColor(value);
64
- if (!parsedValue) {
65
- return;
66
- }
67
- parsedValues.set("border-bottom-color", parsedValue);
68
- break;
69
- }
70
- case "GlobalKeyword": {
71
- return name;
72
- }
73
- case "Hash": {
74
- if (parsedValues.has("border-bottom-color")) {
75
- return;
76
- }
77
- const parsedValue = parsers.parseColor(value);
78
- if (!parsedValue) {
79
- return;
80
- }
81
- parsedValues.set("border-bottom-color", parsedValue);
82
- break;
83
- }
84
- case "Identifier": {
85
- if (parsers.isValidPropertyValue("border-bottom-width", name)) {
86
- if (parsedValues.has("border-bottom-width")) {
87
- return;
88
- }
89
- parsedValues.set("border-bottom-width", name);
90
- break;
91
- } else if (parsers.isValidPropertyValue("border-bottom-style", name)) {
92
- if (parsedValues.has("border-bottom-style")) {
93
- return;
94
- }
95
- parsedValues.set("border-bottom-style", name);
96
- break;
97
- } else if (parsers.isValidPropertyValue("border-bottom-color", name)) {
98
- if (parsedValues.has("border-bottom-color")) {
99
- return;
100
- }
101
- parsedValues.set("border-bottom-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-bottom-width": "medium"
58
+ [borderBottomWidth.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-bottom-width"] && obj["border-bottom-width"] === "medium") {
125
- delete obj["border-bottom-width"];
65
+ if (obj[borderBottomWidth.property] && obj[borderBottomWidth.property] === "medium") {
66
+ delete obj[borderBottomWidth.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-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,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-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,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;