cssstyle 5.2.0 → 5.3.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 (88) hide show
  1. package/lib/CSSStyleDeclaration.js +250 -254
  2. package/lib/generated/allProperties.js +39 -1
  3. package/lib/generated/implementedProperties.js +2219 -80
  4. package/lib/generated/properties.js +5253 -1904
  5. package/lib/normalize.js +1417 -0
  6. package/lib/parsers.js +372 -389
  7. package/lib/properties/background.js +76 -63
  8. package/lib/properties/backgroundAttachment.js +37 -22
  9. package/lib/properties/backgroundClip.js +37 -22
  10. package/lib/properties/backgroundColor.js +35 -15
  11. package/lib/properties/backgroundImage.js +49 -19
  12. package/lib/properties/backgroundOrigin.js +37 -22
  13. package/lib/properties/backgroundPosition.js +145 -128
  14. package/lib/properties/backgroundRepeat.js +55 -48
  15. package/lib/properties/backgroundSize.js +86 -46
  16. package/lib/properties/border.js +139 -22
  17. package/lib/properties/borderBottom.js +137 -21
  18. package/lib/properties/borderBottomColor.js +41 -16
  19. package/lib/properties/borderBottomStyle.js +39 -30
  20. package/lib/properties/borderBottomWidth.js +49 -16
  21. package/lib/properties/borderCollapse.js +32 -8
  22. package/lib/properties/borderColor.js +96 -23
  23. package/lib/properties/borderLeft.js +137 -21
  24. package/lib/properties/borderLeftColor.js +41 -16
  25. package/lib/properties/borderLeftStyle.js +39 -30
  26. package/lib/properties/borderLeftWidth.js +49 -16
  27. package/lib/properties/borderRight.js +137 -21
  28. package/lib/properties/borderRightColor.js +41 -16
  29. package/lib/properties/borderRightStyle.js +39 -30
  30. package/lib/properties/borderRightWidth.js +49 -16
  31. package/lib/properties/borderSpacing.js +42 -25
  32. package/lib/properties/borderStyle.js +96 -34
  33. package/lib/properties/borderTop.js +131 -15
  34. package/lib/properties/borderTopColor.js +41 -16
  35. package/lib/properties/borderTopStyle.js +39 -30
  36. package/lib/properties/borderTopWidth.js +49 -16
  37. package/lib/properties/borderWidth.js +108 -23
  38. package/lib/properties/bottom.js +40 -12
  39. package/lib/properties/clear.js +32 -22
  40. package/lib/properties/clip.js +46 -32
  41. package/lib/properties/color.js +34 -13
  42. package/lib/properties/display.js +169 -179
  43. package/lib/properties/flex.js +137 -38
  44. package/lib/properties/flexBasis.js +43 -14
  45. package/lib/properties/flexGrow.js +42 -9
  46. package/lib/properties/flexShrink.js +42 -9
  47. package/lib/properties/float.js +32 -9
  48. package/lib/properties/floodColor.js +34 -13
  49. package/lib/properties/font.js +145 -44
  50. package/lib/properties/fontFamily.js +66 -67
  51. package/lib/properties/fontSize.js +43 -26
  52. package/lib/properties/fontStyle.js +42 -11
  53. package/lib/properties/fontVariant.js +52 -15
  54. package/lib/properties/fontWeight.js +47 -15
  55. package/lib/properties/height.js +40 -13
  56. package/lib/properties/left.js +40 -12
  57. package/lib/properties/lightingColor.js +34 -13
  58. package/lib/properties/lineHeight.js +45 -18
  59. package/lib/properties/margin.js +73 -36
  60. package/lib/properties/marginBottom.js +43 -19
  61. package/lib/properties/marginLeft.js +43 -19
  62. package/lib/properties/marginRight.js +43 -19
  63. package/lib/properties/marginTop.js +43 -19
  64. package/lib/properties/opacity.js +41 -28
  65. package/lib/properties/outlineColor.js +34 -13
  66. package/lib/properties/padding.js +71 -36
  67. package/lib/properties/paddingBottom.js +44 -21
  68. package/lib/properties/paddingLeft.js +44 -19
  69. package/lib/properties/paddingRight.js +44 -19
  70. package/lib/properties/paddingTop.js +44 -19
  71. package/lib/properties/right.js +40 -12
  72. package/lib/properties/stopColor.js +34 -13
  73. package/lib/properties/top.js +40 -12
  74. package/lib/properties/webkitBorderAfterColor.js +34 -13
  75. package/lib/properties/webkitBorderBeforeColor.js +34 -13
  76. package/lib/properties/webkitBorderEndColor.js +34 -13
  77. package/lib/properties/webkitBorderStartColor.js +34 -13
  78. package/lib/properties/webkitColumnRuleColor.js +34 -13
  79. package/lib/properties/webkitTapHighlightColor.js +34 -13
  80. package/lib/properties/webkitTextEmphasisColor.js +34 -13
  81. package/lib/properties/webkitTextFillColor.js +34 -13
  82. package/lib/properties/webkitTextStrokeColor.js +34 -13
  83. package/lib/properties/width.js +40 -13
  84. package/lib/{allWebkitProperties.js → utils/allExtraProperties.js} +42 -1
  85. package/lib/utils/propertyDescriptors.js +6 -3
  86. package/package.json +11 -10
  87. package/lib/allExtraProperties.js +0 -49
  88. package/lib/shorthandProperties.js +0 -21
@@ -2,52 +2,91 @@
2
2
 
3
3
  const parsers = require("../parsers");
4
4
 
5
- module.exports.parse = function parse(v) {
5
+ const property = "background-size";
6
+ const shorthand = "background";
7
+
8
+ module.exports.parse = function parse(v, opt = {}) {
9
+ const { globalObject } = opt;
6
10
  if (v === "") {
7
11
  return v;
8
12
  }
9
13
  const values = parsers.splitValue(v, {
10
14
  delimiter: ","
11
15
  });
12
- const keywordsRatio = ["contain", "cover"];
13
- const keywordsRepeat = ["auto"];
14
- const keywords = [...keywordsRatio, ...keywordsRepeat];
15
16
  const parsedValues = [];
16
- for (const value of values) {
17
- const parts = parsers.splitValue(value);
18
- if (!parts.length || parts.length > 2) {
19
- return;
20
- }
21
- let parsedValue = "";
22
- switch (parts.length) {
23
- case 1: {
24
- const [part] = parts;
25
- const val = parsers.parseMeasurement(part, true) || parsers.parseKeyword(part, keywords);
26
- if (val) {
27
- parsedValue = val;
17
+ for (const val of values) {
18
+ const value = parsers.parsePropertyValue(property, val, {
19
+ globalObject,
20
+ inArray: true
21
+ });
22
+ if (Array.isArray(value) && value.length) {
23
+ if (value.length === 1) {
24
+ const [{ isNumber, name, type, value: itemValue }] = value;
25
+ switch (type) {
26
+ case "Calc": {
27
+ if (isNumber) {
28
+ return;
29
+ }
30
+ parsedValues.push(`${name}(${itemValue})`);
31
+ break;
32
+ }
33
+ case "GlobalKeyword":
34
+ case "Identifier": {
35
+ parsedValues.push(name);
36
+ break;
37
+ }
38
+ default: {
39
+ const parsedValue = parsers.parseLengthPercentage(value);
40
+ if (!parsedValue) {
41
+ return;
42
+ }
43
+ parsedValues.push(parsedValue);
44
+ }
28
45
  }
29
- break;
30
- }
31
- case 2:
32
- default: {
33
- const [part1, part2] = parts;
34
- const val1 =
35
- parsers.parseMeasurement(part1, true) || parsers.parseKeyword(part1, keywordsRepeat);
36
- const val2 =
37
- parsers.parseMeasurement(part2, true) || parsers.parseKeyword(part2, keywordsRepeat);
38
- if (val1 && val2) {
39
- if (val2 === "auto") {
40
- parsedValue = val1;
41
- } else {
42
- parsedValue = `${val1} ${val2}`;
46
+ } else {
47
+ const [val1, val2] = value;
48
+ const parts = [];
49
+ if (val1.type === "Calc" && !val1.isNumber) {
50
+ parts.push(`${val1.name}(${val1.value})`);
51
+ } else if (val1.type === "Identifier") {
52
+ parts.push(val1.name);
53
+ } else if (val1.type === "Dimension") {
54
+ parts.push(`${val1.value}${val1.unit}`);
55
+ } else if (val1.type === "Percentage") {
56
+ parts.push(`${val1.value}%`);
57
+ } else {
58
+ return;
59
+ }
60
+ switch (val2.type) {
61
+ case "Calc": {
62
+ if (val2.isNumber) {
63
+ return;
64
+ }
65
+ parts.push(`${val2.name}(${val2.value})`);
66
+ break;
67
+ }
68
+ case "Dimension": {
69
+ parts.push(`${val2.value}${val2.unit}`);
70
+ break;
71
+ }
72
+ case "Identifier": {
73
+ if (val2.name !== "auto") {
74
+ parts.push(val2.name);
75
+ }
76
+ break;
77
+ }
78
+ case "Percentage": {
79
+ parts.push(`${val2.value}%`);
80
+ break;
81
+ }
82
+ default: {
83
+ return;
43
84
  }
44
85
  }
86
+ parsedValues.push(parts.join(" "));
45
87
  }
46
- }
47
- if (parsedValue) {
48
- parsedValues.push(parsedValue);
49
- } else {
50
- return;
88
+ } else if (typeof value === "string") {
89
+ parsedValues.push(value);
51
90
  }
52
91
  }
53
92
  if (parsedValues.length) {
@@ -55,25 +94,26 @@ module.exports.parse = function parse(v) {
55
94
  }
56
95
  };
57
96
 
58
- module.exports.isValid = function isValid(v) {
59
- if (v === "") {
60
- return true;
61
- }
62
- return typeof module.exports.parse(v) === "string";
63
- };
64
-
65
97
  module.exports.definition = {
66
98
  set(v) {
67
99
  v = parsers.prepareValue(v, this._global);
68
100
  if (parsers.hasVarFunc(v)) {
69
- this._setProperty("background", "");
70
- this._setProperty("background-size", v);
101
+ this._setProperty(shorthand, "");
102
+ this._setProperty(property, v);
71
103
  } else {
72
- this._setProperty("background-size", module.exports.parse(v));
104
+ const val = module.exports.parse(v, {
105
+ globalObject: this._global
106
+ });
107
+ 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
+ this._setProperty(property, val, priority);
112
+ }
73
113
  }
74
114
  },
75
115
  get() {
76
- return this.getPropertyValue("background-size");
116
+ return this.getPropertyValue(property);
77
117
  },
78
118
  enumerable: true,
79
119
  configurable: true
@@ -4,6 +4,18 @@ const parsers = require("../parsers");
4
4
  const borderWidth = require("./borderWidth");
5
5
  const borderStyle = require("./borderStyle");
6
6
  const borderColor = require("./borderColor");
7
+ const borderTop = require("./borderTop");
8
+ const borderRight = require("./borderRight");
9
+ const borderBottom = require("./borderBottom");
10
+ const borderLeft = require("./borderLeft");
11
+
12
+ const property = "border";
13
+
14
+ module.exports.initialValues = new Map([
15
+ ["border-width", "medium"],
16
+ ["border-style", "none"],
17
+ ["border-color", "currentcolor"]
18
+ ]);
7
19
 
8
20
  module.exports.shorthandFor = new Map([
9
21
  ["border-width", borderWidth],
@@ -11,36 +23,141 @@ module.exports.shorthandFor = new Map([
11
23
  ["border-color", borderColor]
12
24
  ]);
13
25
 
26
+ module.exports.positionShorthandFor = new Map([
27
+ ["border-top", borderTop],
28
+ ["border-right", borderRight],
29
+ ["border-bottom", borderBottom],
30
+ ["border-left", borderLeft]
31
+ ]);
32
+
33
+ module.exports.parse = function parse(v, opt = {}) {
34
+ const { globalObject } = opt;
35
+ if (v === "" || parsers.hasVarFunc(v)) {
36
+ return v;
37
+ }
38
+ const values = parsers.splitValue(v);
39
+ const parsedValues = new Map();
40
+ for (const val of values) {
41
+ const value = parsers.parsePropertyValue(property, val, {
42
+ globalObject,
43
+ inArray: true
44
+ });
45
+ 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(`#${itemValue}`);
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
+ }
119
+ }
120
+ } else {
121
+ return;
122
+ }
123
+ }
124
+ if (parsedValues.size) {
125
+ const keys = module.exports.shorthandFor.keys();
126
+ const obj = {
127
+ "border-width": "medium"
128
+ };
129
+ for (const key of keys) {
130
+ if (parsedValues.has(key)) {
131
+ const parsedValue = parsedValues.get(key);
132
+ if (parsedValue !== module.exports.initialValues.get(key)) {
133
+ obj[key] = parsedValues.get(key);
134
+ if (obj["border-width"] && obj["border-width"] === "medium") {
135
+ delete obj["border-width"];
136
+ }
137
+ }
138
+ }
139
+ }
140
+ return obj;
141
+ }
142
+ };
143
+
14
144
  module.exports.definition = {
15
145
  set(v) {
16
146
  v = parsers.prepareValue(v, this._global);
17
- if (/^none$/i.test(v)) {
18
- v = "";
19
- }
20
147
  if (parsers.hasVarFunc(v)) {
21
- for (const [key] of module.exports.shorthandFor) {
22
- this._setProperty(key, "");
23
- }
24
- this._setProperty("border", v);
148
+ this._borderSetter(property, v, "");
25
149
  } else {
26
- this._midShorthandSetter("border", v, module.exports.shorthandFor, [
27
- "top",
28
- "right",
29
- "bottom",
30
- "left"
31
- ]);
150
+ const val = module.exports.parse(v, {
151
+ globalObject: this._global
152
+ });
153
+ if (val || typeof val === "string") {
154
+ const priority = this._priorities.get(property) ?? "";
155
+ this._borderSetter(property, val, priority);
156
+ }
32
157
  }
33
158
  },
34
159
  get() {
35
- let val = this.getPropertyValue("border");
36
- if (parsers.hasVarFunc(val)) {
37
- return val;
38
- }
39
- val = this._shorthandGetter("border", module.exports.shorthandFor);
40
- if (parsers.hasVarFunc(val)) {
41
- return "";
42
- }
43
- return val;
160
+ return this.getPropertyValue(property);
44
161
  },
45
162
  enumerable: true,
46
163
  configurable: true
@@ -1,39 +1,155 @@
1
1
  "use strict";
2
2
 
3
3
  const parsers = require("../parsers");
4
- const borderTopWidth = require("./borderTopWidth");
5
- const borderTopStyle = require("./borderTopStyle");
6
- const borderTopColor = require("./borderTopColor");
4
+ const borderBottomWidth = require("./borderBottomWidth");
5
+ const borderBottomStyle = require("./borderBottomStyle");
6
+ const borderBottomColor = require("./borderBottomColor");
7
+
8
+ const property = "border-bottom";
9
+ const shorthand = "border";
10
+
11
+ module.exports.initialValues = new Map([
12
+ ["border-bottom-width", "medium"],
13
+ ["border-bottom-style", "none"],
14
+ ["border-bottom-color", "currentcolor"]
15
+ ]);
7
16
 
8
17
  module.exports.shorthandFor = new Map([
9
- ["border-bottom-width", borderTopWidth],
10
- ["border-bottom-style", borderTopStyle],
11
- ["border-bottom-color", borderTopColor]
18
+ ["border-bottom-width", borderBottomWidth],
19
+ ["border-bottom-style", borderBottomStyle],
20
+ ["border-bottom-color", borderBottomColor]
12
21
  ]);
13
22
 
23
+ module.exports.parse = function parse(v, opt = {}) {
24
+ const { globalObject } = opt;
25
+ if (v === "") {
26
+ return v;
27
+ }
28
+ const values = parsers.splitValue(v);
29
+ const parsedValues = new Map();
30
+ for (const val of values) {
31
+ const value = parsers.parsePropertyValue(property, val, {
32
+ globalObject,
33
+ inArray: true
34
+ });
35
+ 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(`#${itemValue}`);
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
+ }
109
+ }
110
+ } else {
111
+ return;
112
+ }
113
+ }
114
+ if (parsedValues.size) {
115
+ const keys = module.exports.shorthandFor.keys();
116
+ const obj = {
117
+ "border-bottom-width": "medium"
118
+ };
119
+ for (const key of keys) {
120
+ if (parsedValues.has(key)) {
121
+ const parsedValue = parsedValues.get(key);
122
+ if (parsedValue !== module.exports.initialValues.get(key)) {
123
+ obj[key] = parsedValues.get(key);
124
+ if (obj["border-bottom-width"] && obj["border-bottom-width"] === "medium") {
125
+ delete obj["border-bottom-width"];
126
+ }
127
+ }
128
+ }
129
+ }
130
+ return obj;
131
+ }
132
+ };
133
+
14
134
  module.exports.definition = {
15
135
  set(v) {
16
136
  v = parsers.prepareValue(v, this._global);
17
137
  if (parsers.hasVarFunc(v)) {
18
- for (const [key] of module.exports.shorthandFor) {
19
- this._setProperty(key, "");
20
- }
21
- this._setProperty("border", "");
22
- this._setProperty("border-bottom", v);
138
+ this._borderSetter(property, v, "");
23
139
  } else {
24
- this._shorthandSetter("border-bottom", v, module.exports.shorthandFor);
140
+ const val = module.exports.parse(v, {
141
+ globalObject: this._global
142
+ });
143
+ 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;
147
+ this._borderSetter(property, val, priority);
148
+ }
25
149
  }
26
150
  },
27
151
  get() {
28
- let val = this.getPropertyValue("border-bottom");
29
- if (parsers.hasVarFunc(val)) {
30
- return val;
31
- }
32
- val = this._shorthandGetter("border-bottom", module.exports.shorthandFor);
33
- if (parsers.hasVarFunc(val)) {
34
- return "";
35
- }
36
- return val;
152
+ return this.getPropertyValue(property);
37
153
  },
38
154
  enumerable: true,
39
155
  configurable: true
@@ -2,33 +2,58 @@
2
2
 
3
3
  const parsers = require("../parsers");
4
4
 
5
- module.exports.parse = function parse(v) {
6
- const val = parsers.parseColor(v);
7
- if (val) {
8
- return val;
9
- }
10
- return parsers.parseKeyword(v);
11
- };
5
+ const property = "border-bottom-color";
6
+ const lineShorthand = "border-color";
7
+ const positionShorthand = "border-bottom";
8
+ const shorthand = "border";
12
9
 
13
- module.exports.isValid = function isValid(v) {
14
- if (v === "" || typeof parsers.parseKeyword(v) === "string") {
15
- return true;
10
+ module.exports.parse = function 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
+ const [{ name, type }] = value;
21
+ switch (type) {
22
+ case "GlobalKeyword": {
23
+ return name;
24
+ }
25
+ default: {
26
+ return parsers.parseColor(value);
27
+ }
28
+ }
29
+ } else if (typeof value === "string") {
30
+ return value;
16
31
  }
17
- return parsers.isValidColor(v);
18
32
  };
19
33
 
20
34
  module.exports.definition = {
21
35
  set(v) {
22
36
  v = parsers.prepareValue(v, this._global);
23
37
  if (parsers.hasVarFunc(v)) {
24
- this._setProperty("border", "");
25
- this._setProperty("border-bottom", "");
26
- this._setProperty("border-color", "");
38
+ this._borderSetter(property, v, "");
39
+ } else {
40
+ const val = module.exports.parse(v, {
41
+ globalObject: this._global
42
+ });
43
+ if (typeof val === "string") {
44
+ const shorthandPriority = this._priorities.get(shorthand);
45
+ const linePriority = this._priorities.get(lineShorthand);
46
+ const positionPriority = this._priorities.get(positionShorthand);
47
+ let priority = this._priorities.get(property) ?? "";
48
+ if ((shorthandPriority || linePriority || positionPriority) && priority) {
49
+ priority = "";
50
+ }
51
+ this._borderSetter(property, val, priority);
52
+ }
27
53
  }
28
- this._setProperty("border-bottom-color", module.exports.parse(v));
29
54
  },
30
55
  get() {
31
- return this.getPropertyValue("border-bottom-color");
56
+ return this.getPropertyValue(property);
32
57
  },
33
58
  enumerable: true,
34
59
  configurable: true
@@ -2,48 +2,57 @@
2
2
 
3
3
  const parsers = require("../parsers");
4
4
 
5
- module.exports.parse = function parse(v) {
6
- const keywords = [
7
- "none",
8
- "hidden",
9
- "dotted",
10
- "dashed",
11
- "solid",
12
- "double",
13
- "groove",
14
- "ridge",
15
- "inset",
16
- "outset"
17
- ];
18
- return parsers.parseKeyword(v, keywords);
19
- };
5
+ const property = "border-bottom-style";
6
+ const lineShorthand = "border-style";
7
+ const positionShorthand = "border-bottom";
8
+ const shorthand = "border";
20
9
 
21
- module.exports.isValid = function isValid(v) {
10
+ module.exports.parse = function parse(v, opt = {}) {
11
+ const { globalObject } = opt;
22
12
  if (v === "") {
23
- return true;
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
+ const [{ name, type }] = value;
21
+ switch (type) {
22
+ case "GlobalKeyword":
23
+ case "Identifier": {
24
+ return name;
25
+ }
26
+ default:
27
+ }
28
+ } else if (typeof value === "string") {
29
+ return value;
24
30
  }
25
- return typeof module.exports.parse(v) === "string";
26
31
  };
27
32
 
28
33
  module.exports.definition = {
29
34
  set(v) {
30
35
  v = parsers.prepareValue(v, this._global);
31
- const val = module.exports.parse(v);
32
- if (val === "none" || val === "hidden") {
33
- this._setProperty("border-bottom-style", "");
34
- this._setProperty("border-bottom-color", "");
35
- this._setProperty("border-bottom-width", "");
36
- return;
37
- }
38
36
  if (parsers.hasVarFunc(v)) {
39
- this._setProperty("border", "");
40
- this._setProperty("border-bottom", "");
41
- this._setProperty("border-style", "");
37
+ this._borderSetter(property, v, "");
38
+ } else {
39
+ const val = module.exports.parse(v, {
40
+ globalObject: this._global
41
+ });
42
+ if (typeof val === "string") {
43
+ const shorthandPriority = this._priorities.get(shorthand);
44
+ const linePriority = this._priorities.get(lineShorthand);
45
+ const positionPriority = this._priorities.get(positionShorthand);
46
+ let priority = this._priorities.get(property) ?? "";
47
+ if ((shorthandPriority || linePriority || positionPriority) && priority) {
48
+ priority = "";
49
+ }
50
+ this._borderSetter(property, val, priority);
51
+ }
42
52
  }
43
- this._setProperty("border-bottom-style", val);
44
53
  },
45
54
  get() {
46
- return this.getPropertyValue("border-bottom-style");
55
+ return this.getPropertyValue(property);
47
56
  },
48
57
  enumerable: true,
49
58
  configurable: true