happy-dom 6.0.4 → 7.0.1
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.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/lib/css/CSSParser.js +12 -6
- package/lib/css/CSSParser.js.map +1 -1
- package/lib/css/CSSRule.d.ts +15 -13
- package/lib/css/CSSRule.js +18 -13
- package/lib/css/CSSRule.js.map +1 -1
- package/lib/css/CSSRuleTypeEnum.d.ts +17 -0
- package/lib/css/CSSRuleTypeEnum.js +21 -0
- package/lib/css/CSSRuleTypeEnum.js.map +1 -0
- package/lib/css/CSSStyleSheet.d.ts +6 -16
- package/lib/css/CSSStyleSheet.js +11 -19
- package/lib/css/CSSStyleSheet.js.map +1 -1
- package/lib/css/declaration/AbstractCSSStyleDeclaration.d.ts +76 -0
- package/lib/css/declaration/AbstractCSSStyleDeclaration.js +182 -0
- package/lib/css/declaration/AbstractCSSStyleDeclaration.js.map +1 -0
- package/lib/css/declaration/CSSStyleDeclaration.d.ts +1194 -0
- package/lib/css/declaration/CSSStyleDeclaration.js +3566 -0
- package/lib/css/declaration/CSSStyleDeclaration.js.map +1 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationCSSParser.d.ts +12 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationCSSParser.js +34 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationCSSParser.js.map +1 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationElementDefaultCSS.d.ts +131 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationElementDefaultCSS.js +133 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationElementDefaultCSS.js.map +1 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationElementInheritedProperties.d.ts +40 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationElementInheritedProperties.js +42 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationElementInheritedProperties.js.map +1 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationElementStyle.d.ts +49 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationElementStyle.js +244 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationElementStyle.js.map +1 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationPropertyGetParser.d.ts +167 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationPropertyGetParser.js +537 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationPropertyGetParser.js.map +1 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationPropertyManager.d.ts +65 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationPropertyManager.js +565 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationPropertyManager.js.map +1 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationPropertySetParser.d.ts +809 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationPropertySetParser.js +2303 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationPropertySetParser.js.map +1 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationValueParser.d.ts +127 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationValueParser.js +411 -0
- package/lib/css/declaration/utilities/CSSStyleDeclarationValueParser.js.map +1 -0
- package/lib/css/declaration/utilities/ICSSStyleDeclarationPropertyValue.d.ts +4 -0
- package/lib/css/declaration/utilities/ICSSStyleDeclarationPropertyValue.js +3 -0
- package/lib/css/declaration/utilities/ICSSStyleDeclarationPropertyValue.js.map +1 -0
- package/lib/css/rules/CSSContainerRule.d.ts +15 -0
- package/lib/css/rules/CSSContainerRule.js +31 -0
- package/lib/css/rules/CSSContainerRule.js.map +1 -0
- package/lib/css/rules/CSSFontFaceRule.d.ts +10 -3
- package/lib/css/rules/CSSFontFaceRule.js +16 -0
- package/lib/css/rules/CSSFontFaceRule.js.map +1 -1
- package/lib/css/rules/CSSKeyframeRule.d.ts +10 -3
- package/lib/css/rules/CSSKeyframeRule.js +16 -0
- package/lib/css/rules/CSSKeyframeRule.js.map +1 -1
- package/lib/css/rules/CSSKeyframesRule.d.ts +1 -1
- package/lib/css/rules/CSSKeyframesRule.js +1 -1
- package/lib/css/rules/CSSKeyframesRule.js.map +1 -1
- package/lib/css/rules/CSSMediaRule.d.ts +1 -1
- package/lib/css/rules/CSSStyleRule.d.ts +10 -3
- package/lib/css/rules/CSSStyleRule.js +16 -0
- package/lib/css/rules/CSSStyleRule.js.map +1 -1
- package/lib/event/Event.d.ts +2 -3
- package/lib/event/Event.js.map +1 -1
- package/lib/event/events/IMediaQueryListInit.d.ts +5 -0
- package/lib/event/events/IMediaQueryListInit.js +3 -0
- package/lib/event/events/IMediaQueryListInit.js.map +1 -0
- package/lib/event/events/MediaQueryListEvent.d.ts +16 -0
- package/lib/event/events/MediaQueryListEvent.js +28 -0
- package/lib/event/events/MediaQueryListEvent.js.map +1 -0
- package/lib/exception/DOMException.js +5 -3
- package/lib/exception/DOMException.js.map +1 -1
- package/lib/exception/DOMExceptionNameEnum.d.ts +2 -1
- package/lib/exception/DOMExceptionNameEnum.js +1 -0
- package/lib/exception/DOMExceptionNameEnum.js.map +1 -1
- package/lib/file/Blob.d.ts +9 -0
- package/lib/file/Blob.js +14 -0
- package/lib/file/Blob.js.map +1 -1
- package/lib/index.d.ts +9 -2
- package/lib/index.js +16 -2
- package/lib/index.js.map +1 -1
- package/lib/match-media/MediaQueryList.d.ts +19 -8
- package/lib/match-media/MediaQueryList.js +56 -13
- package/lib/match-media/MediaQueryList.js.map +1 -1
- package/lib/{attribute → nodes/attr}/Attr.d.ts +8 -7
- package/lib/{attribute → nodes/attr}/Attr.js +12 -5
- package/lib/nodes/attr/Attr.js.map +1 -0
- package/lib/nodes/attr/IAttr.d.ts +14 -0
- package/lib/nodes/attr/IAttr.js +3 -0
- package/lib/nodes/attr/IAttr.js.map +1 -0
- package/lib/nodes/child-node/ChildNodeUtility.js +2 -1
- package/lib/nodes/child-node/ChildNodeUtility.js.map +1 -1
- package/lib/nodes/document/Document.d.ts +4 -4
- package/lib/nodes/document/Document.js +5 -8
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/document/IDocument.d.ts +3 -3
- package/lib/nodes/element/Element.d.ts +11 -9
- package/lib/nodes/element/Element.js +2 -1
- package/lib/nodes/element/Element.js.map +1 -1
- package/lib/nodes/element/IElement.d.ts +10 -8
- package/lib/nodes/html-element/HTMLElement.d.ts +21 -5
- package/lib/nodes/html-element/HTMLElement.js +74 -11
- package/lib/nodes/html-element/HTMLElement.js.map +1 -1
- package/lib/nodes/html-element/IHTMLElement.d.ts +5 -1
- package/lib/nodes/html-link-element/HTMLLinkElement.d.ts +2 -2
- package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElement.d.ts +2 -2
- package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
- package/lib/nodes/html-select-element/HTMLSelectElement.js +1 -1
- package/lib/nodes/html-select-element/HTMLSelectElement.js.map +1 -1
- package/lib/nodes/html-style-element/HTMLStyleElement.js +1 -1
- package/lib/nodes/html-style-element/HTMLStyleElement.js.map +1 -1
- package/lib/nodes/node/INode.d.ts +2 -0
- package/lib/nodes/node/Node.d.ts +5 -1
- package/lib/nodes/node/Node.js +7 -1
- package/lib/nodes/node/Node.js.map +1 -1
- package/lib/nodes/node/NodeTypeEnum.d.ts +2 -0
- package/lib/nodes/node/NodeTypeEnum.js +2 -0
- package/lib/nodes/node/NodeTypeEnum.js.map +1 -1
- package/lib/nodes/svg-element/ISVGElement.d.ts +1 -1
- package/lib/nodes/svg-element/SVGElement.d.ts +4 -4
- package/lib/nodes/svg-element/SVGElement.js +2 -2
- package/lib/nodes/svg-element/SVGElement.js.map +1 -1
- package/lib/window/IWindow.d.ts +23 -3
- package/lib/window/Window.d.ts +35 -6
- package/lib/window/Window.js +58 -23
- package/lib/window/Window.js.map +1 -1
- package/package.json +2 -2
- package/src/css/CSSParser.ts +14 -6
- package/src/css/CSSRule.ts +15 -13
- package/src/css/CSSRuleTypeEnum.ts +18 -0
- package/src/css/CSSStyleSheet.ts +12 -22
- package/src/css/declaration/AbstractCSSStyleDeclaration.ts +202 -0
- package/src/css/declaration/CSSStyleDeclaration.ts +4743 -0
- package/src/css/declaration/utilities/CSSStyleDeclarationCSSParser.ts +35 -0
- package/src/css/declaration/utilities/CSSStyleDeclarationElementDefaultCSS.ts +130 -0
- package/src/css/declaration/utilities/CSSStyleDeclarationElementInheritedProperties.ts +39 -0
- package/src/css/declaration/utilities/CSSStyleDeclarationElementStyle.ts +282 -0
- package/src/css/declaration/utilities/CSSStyleDeclarationPropertyGetParser.ts +743 -0
- package/src/css/declaration/utilities/CSSStyleDeclarationPropertyManager.ts +592 -0
- package/src/css/declaration/utilities/CSSStyleDeclarationPropertySetParser.ts +3026 -0
- package/src/css/declaration/utilities/CSSStyleDeclarationValueParser.ts +437 -0
- package/src/css/declaration/utilities/ICSSStyleDeclarationPropertyValue.ts +4 -0
- package/src/css/rules/CSSContainerRule.ts +23 -0
- package/src/css/rules/CSSFontFaceRule.ts +17 -2
- package/src/css/rules/CSSKeyframeRule.ts +17 -2
- package/src/css/rules/CSSKeyframesRule.ts +1 -1
- package/src/css/rules/CSSStyleRule.ts +17 -2
- package/src/event/Event.ts +2 -3
- package/src/event/events/IMediaQueryListInit.ts +6 -0
- package/src/event/events/MediaQueryListEvent.ts +25 -0
- package/src/exception/DOMException.ts +3 -3
- package/src/exception/DOMExceptionNameEnum.ts +2 -1
- package/src/file/Blob.ts +16 -0
- package/src/index.ts +15 -1
- package/src/match-media/MediaQueryList.ts +63 -10
- package/src/{attribute → nodes/attr}/Attr.ts +11 -8
- package/src/nodes/attr/IAttr.ts +15 -0
- package/src/nodes/child-node/ChildNodeUtility.ts +2 -1
- package/src/nodes/document/Document.ts +8 -10
- package/src/nodes/document/IDocument.ts +3 -3
- package/src/nodes/element/Element.ts +13 -10
- package/src/nodes/element/IElement.ts +8 -8
- package/src/nodes/html-element/HTMLElement.ts +94 -16
- package/src/nodes/html-element/IHTMLElement.ts +3 -1
- package/src/nodes/html-link-element/HTMLLinkElement.ts +2 -2
- package/src/nodes/html-script-element/HTMLScriptElement.ts +2 -2
- package/src/nodes/html-select-element/HTMLSelectElement.ts +1 -1
- package/src/nodes/html-style-element/HTMLStyleElement.ts +1 -1
- package/src/nodes/node/INode.ts +2 -0
- package/src/nodes/node/Node.ts +7 -1
- package/src/nodes/node/NodeTypeEnum.ts +2 -0
- package/src/nodes/svg-element/ISVGElement.ts +1 -1
- package/src/nodes/svg-element/SVGElement.ts +5 -5
- package/src/window/IWindow.ts +23 -3
- package/src/window/Window.ts +51 -11
- package/lib/attribute/Attr.js.map +0 -1
- package/lib/css/CSSStyleDeclaration.d.ts +0 -3017
- package/lib/css/CSSStyleDeclaration.js +0 -4643
- package/lib/css/CSSStyleDeclaration.js.map +0 -1
- package/src/css/CSSStyleDeclaration.ts +0 -5026
@@ -0,0 +1,3026 @@
|
|
1
|
+
import CSSStyleDeclarationValueParser from './CSSStyleDeclarationValueParser';
|
2
|
+
import ICSSStyleDeclarationPropertyValue from './ICSSStyleDeclarationPropertyValue';
|
3
|
+
|
4
|
+
const RECT_REGEXP = /^rect\((.*)\)$/i;
|
5
|
+
const BORDER_STYLE = [
|
6
|
+
'none',
|
7
|
+
'hidden',
|
8
|
+
'dotted',
|
9
|
+
'dashed',
|
10
|
+
'solid',
|
11
|
+
'double',
|
12
|
+
'groove',
|
13
|
+
'ridge',
|
14
|
+
'inset',
|
15
|
+
'outset'
|
16
|
+
];
|
17
|
+
const BORDER_WIDTH = ['thin', 'medium', 'thick'];
|
18
|
+
const BORDER_COLLAPSE = ['separate', 'collapse'];
|
19
|
+
const BACKGROUND_REPEAT = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'];
|
20
|
+
const BACKGROUND_ORIGIN = ['border-box', 'padding-box', 'content-box'];
|
21
|
+
const BACKGROUND_CLIP = ['border-box', 'padding-box', 'content-box'];
|
22
|
+
const BACKGROUND_ATTACHMENT = ['scroll', 'fixed'];
|
23
|
+
const FLEX_BASIS = ['auto', 'fill', 'content'];
|
24
|
+
const CLEAR = ['none', 'left', 'right', 'both'];
|
25
|
+
const FLOAT = ['none', 'left', 'right', 'inline-start', 'inline-end'];
|
26
|
+
const SYSTEM_FONT = ['caption', 'icon', 'menu', 'message-box', 'small-caption', 'status-bar'];
|
27
|
+
const FONT_WEIGHT = ['normal', 'bold', 'bolder', 'lighter'];
|
28
|
+
const FONT_STYLE = ['normal', 'italic', 'oblique'];
|
29
|
+
const FONT_SIZE = [
|
30
|
+
'xx-small',
|
31
|
+
'x-small',
|
32
|
+
'small',
|
33
|
+
'medium',
|
34
|
+
'large',
|
35
|
+
'x-large',
|
36
|
+
'xx-large',
|
37
|
+
'xxx-large',
|
38
|
+
'smaller',
|
39
|
+
'larger'
|
40
|
+
];
|
41
|
+
const FONT_STRETCH = [
|
42
|
+
'ultra-condensed',
|
43
|
+
'extra-condensed',
|
44
|
+
'condensed',
|
45
|
+
'semi-condensed',
|
46
|
+
'normal',
|
47
|
+
'semi-expanded',
|
48
|
+
'expanded',
|
49
|
+
'extra-expanded',
|
50
|
+
'ultra-expanded'
|
51
|
+
];
|
52
|
+
|
53
|
+
const DISPLAY = [
|
54
|
+
/* Legacy values */
|
55
|
+
'block',
|
56
|
+
'inline',
|
57
|
+
'inline-block',
|
58
|
+
'flex',
|
59
|
+
'inline-flex',
|
60
|
+
'grid',
|
61
|
+
'inline-grid',
|
62
|
+
'flow-root',
|
63
|
+
|
64
|
+
/* Box generation */
|
65
|
+
'none',
|
66
|
+
'contents',
|
67
|
+
|
68
|
+
/* Two-value syntax */
|
69
|
+
'block flow',
|
70
|
+
'inline flow',
|
71
|
+
'inline flow-root',
|
72
|
+
'block flex',
|
73
|
+
'inline flex',
|
74
|
+
'block grid',
|
75
|
+
'inline grid',
|
76
|
+
'block flow-root',
|
77
|
+
|
78
|
+
/* Other values */
|
79
|
+
'table',
|
80
|
+
'table-row',
|
81
|
+
'list-item'
|
82
|
+
];
|
83
|
+
const BORDER_IMAGE_REPEAT = ['stretch', 'repeat', 'round', 'space'];
|
84
|
+
const TEXT_TRANSFORM = [
|
85
|
+
'capitalize',
|
86
|
+
'uppercase',
|
87
|
+
'lowercase',
|
88
|
+
'none',
|
89
|
+
'full-width',
|
90
|
+
'full-size-kana'
|
91
|
+
];
|
92
|
+
const VISIBILITY = ['visible', 'hidden', 'collapse'];
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Computed style property parser.
|
96
|
+
*/
|
97
|
+
export default class CSSStyleDeclarationPropertySetParser {
|
98
|
+
/**
|
99
|
+
* Returns border collapse.
|
100
|
+
*
|
101
|
+
* @param value Value.
|
102
|
+
* @param important Important.
|
103
|
+
* @returns Property values
|
104
|
+
*/
|
105
|
+
public static getBorderCollapse(
|
106
|
+
value: string,
|
107
|
+
important: boolean
|
108
|
+
): {
|
109
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
110
|
+
} {
|
111
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
112
|
+
if (variable) {
|
113
|
+
return { 'border-collapse': { value: variable, important } };
|
114
|
+
}
|
115
|
+
const lowerValue = value.toLowerCase();
|
116
|
+
if (
|
117
|
+
CSSStyleDeclarationValueParser.getGlobal(lowerValue) ||
|
118
|
+
BORDER_COLLAPSE.includes(lowerValue)
|
119
|
+
) {
|
120
|
+
return { 'border-collapse': { value: lowerValue, important } };
|
121
|
+
}
|
122
|
+
return null;
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Returns display.
|
127
|
+
*
|
128
|
+
* @param value Value.
|
129
|
+
* @param important Important.
|
130
|
+
* @returns Property values
|
131
|
+
*/
|
132
|
+
public static getDisplay(
|
133
|
+
value: string,
|
134
|
+
important: boolean
|
135
|
+
): {
|
136
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
137
|
+
} {
|
138
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
139
|
+
if (variable) {
|
140
|
+
return { display: { value: variable, important } };
|
141
|
+
}
|
142
|
+
const lowerValue = value.toLowerCase();
|
143
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || DISPLAY.includes(lowerValue)) {
|
144
|
+
return { display: { value: lowerValue, important } };
|
145
|
+
}
|
146
|
+
return null;
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Returns direction.
|
151
|
+
*
|
152
|
+
* @param value Value.
|
153
|
+
* @param important Important.
|
154
|
+
* @returns Property values
|
155
|
+
*/
|
156
|
+
public static getDirection(
|
157
|
+
value: string,
|
158
|
+
important: boolean
|
159
|
+
): {
|
160
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
161
|
+
} {
|
162
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
163
|
+
if (variable) {
|
164
|
+
return { direction: { value: variable, important } };
|
165
|
+
}
|
166
|
+
const lowerValue = value.toLowerCase();
|
167
|
+
if (
|
168
|
+
CSSStyleDeclarationValueParser.getGlobal(lowerValue) ||
|
169
|
+
lowerValue === 'ltr' ||
|
170
|
+
lowerValue === 'rtl'
|
171
|
+
) {
|
172
|
+
return { direction: { value: lowerValue, important } };
|
173
|
+
}
|
174
|
+
return null;
|
175
|
+
}
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Returns width.
|
179
|
+
*
|
180
|
+
* @param value Value.
|
181
|
+
* @param important Important.
|
182
|
+
* @returns Property values
|
183
|
+
*/
|
184
|
+
public static getWidth(
|
185
|
+
value: string,
|
186
|
+
important: boolean
|
187
|
+
): {
|
188
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
189
|
+
} {
|
190
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
191
|
+
if (variable) {
|
192
|
+
return { width: { value: variable, important } };
|
193
|
+
}
|
194
|
+
const parsedValue =
|
195
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
196
|
+
CSSStyleDeclarationValueParser.getContentMeasurement(value);
|
197
|
+
return parsedValue ? { width: { value: parsedValue, important } } : null;
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Returns top.
|
202
|
+
*
|
203
|
+
* @param value Value.
|
204
|
+
* @param important Important.
|
205
|
+
* @returns Property values
|
206
|
+
*/
|
207
|
+
public static getTop(
|
208
|
+
value: string,
|
209
|
+
important: boolean
|
210
|
+
): {
|
211
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
212
|
+
} {
|
213
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
214
|
+
if (variable) {
|
215
|
+
return { top: { value: variable, important } };
|
216
|
+
}
|
217
|
+
const parsedValue =
|
218
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
219
|
+
CSSStyleDeclarationValueParser.getContentMeasurement(value);
|
220
|
+
return parsedValue ? { top: { value: parsedValue, important } } : null;
|
221
|
+
}
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Returns top.
|
225
|
+
*
|
226
|
+
* @param value Value.
|
227
|
+
* @param important Important.
|
228
|
+
* @returns Property values
|
229
|
+
*/
|
230
|
+
public static getRight(
|
231
|
+
value: string,
|
232
|
+
important: boolean
|
233
|
+
): {
|
234
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
235
|
+
} {
|
236
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
237
|
+
if (variable) {
|
238
|
+
return { right: { value: variable, important } };
|
239
|
+
}
|
240
|
+
const parsedValue =
|
241
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
242
|
+
CSSStyleDeclarationValueParser.getContentMeasurement(value);
|
243
|
+
return parsedValue ? { right: { value: parsedValue, important } } : null;
|
244
|
+
}
|
245
|
+
|
246
|
+
/**
|
247
|
+
* Returns top.
|
248
|
+
*
|
249
|
+
* @param value Value.
|
250
|
+
* @param important Important.
|
251
|
+
* @returns Property values
|
252
|
+
*/
|
253
|
+
public static getBottom(
|
254
|
+
value: string,
|
255
|
+
important: boolean
|
256
|
+
): {
|
257
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
258
|
+
} {
|
259
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
260
|
+
if (variable) {
|
261
|
+
return { bottom: { value: variable, important } };
|
262
|
+
}
|
263
|
+
const parsedValue =
|
264
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
265
|
+
CSSStyleDeclarationValueParser.getContentMeasurement(value);
|
266
|
+
return parsedValue ? { bottom: { value: parsedValue, important } } : null;
|
267
|
+
}
|
268
|
+
|
269
|
+
/**
|
270
|
+
* Returns top.
|
271
|
+
*
|
272
|
+
* @param value Value.
|
273
|
+
* @param important Important.
|
274
|
+
* @returns Property values
|
275
|
+
*/
|
276
|
+
public static getLeft(
|
277
|
+
value: string,
|
278
|
+
important: boolean
|
279
|
+
): {
|
280
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
281
|
+
} {
|
282
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
283
|
+
if (variable) {
|
284
|
+
return { left: { value: variable, important } };
|
285
|
+
}
|
286
|
+
const parsedValue =
|
287
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
288
|
+
CSSStyleDeclarationValueParser.getContentMeasurement(value);
|
289
|
+
return parsedValue ? { left: { value: parsedValue, important } } : null;
|
290
|
+
}
|
291
|
+
|
292
|
+
/**
|
293
|
+
* Returns clear.
|
294
|
+
*
|
295
|
+
* @param value Value.
|
296
|
+
* @param important Important.
|
297
|
+
* @returns Property values
|
298
|
+
*/
|
299
|
+
public static getClear(
|
300
|
+
value: string,
|
301
|
+
important: boolean
|
302
|
+
): {
|
303
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
304
|
+
} {
|
305
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
306
|
+
if (variable) {
|
307
|
+
return { clear: { value: variable, important } };
|
308
|
+
}
|
309
|
+
const lowerValue = value.toLowerCase();
|
310
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || CLEAR.includes(lowerValue)) {
|
311
|
+
return { clear: { value: lowerValue, important } };
|
312
|
+
}
|
313
|
+
return null;
|
314
|
+
}
|
315
|
+
|
316
|
+
/**
|
317
|
+
* Returns clip
|
318
|
+
*
|
319
|
+
* Based on:
|
320
|
+
* https://github.com/jsdom/cssstyle/blob/master/lib/properties/clip.js
|
321
|
+
*
|
322
|
+
* @param value Value.
|
323
|
+
* @param important Important.
|
324
|
+
* @returns Property values
|
325
|
+
*/
|
326
|
+
public static getClip(
|
327
|
+
value: string,
|
328
|
+
important: boolean
|
329
|
+
): {
|
330
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
331
|
+
} {
|
332
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
333
|
+
if (variable) {
|
334
|
+
return { clip: { value: variable, important } };
|
335
|
+
}
|
336
|
+
const lowerValue = value.toLowerCase();
|
337
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === 'auto') {
|
338
|
+
return { clip: { value: lowerValue, important } };
|
339
|
+
}
|
340
|
+
const matches = lowerValue.match(RECT_REGEXP);
|
341
|
+
if (!matches) {
|
342
|
+
return null;
|
343
|
+
}
|
344
|
+
const parts = matches[1].split(/\s*,\s*/);
|
345
|
+
if (parts.length !== 4) {
|
346
|
+
return null;
|
347
|
+
}
|
348
|
+
for (const part of parts) {
|
349
|
+
if (!CSSStyleDeclarationValueParser.getMeasurement(part)) {
|
350
|
+
return null;
|
351
|
+
}
|
352
|
+
}
|
353
|
+
return { clip: { value, important } };
|
354
|
+
}
|
355
|
+
|
356
|
+
/**
|
357
|
+
* Returns float.
|
358
|
+
*
|
359
|
+
* @param value Value.
|
360
|
+
* @param important Important.
|
361
|
+
* @returns Property values
|
362
|
+
*/
|
363
|
+
public static getFloat(
|
364
|
+
value: string,
|
365
|
+
important: boolean
|
366
|
+
): {
|
367
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
368
|
+
} {
|
369
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
370
|
+
if (variable) {
|
371
|
+
return { float: { value: variable, important } };
|
372
|
+
}
|
373
|
+
const lowerValue = value.toLowerCase();
|
374
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FLOAT.includes(lowerValue)) {
|
375
|
+
return { float: { value: lowerValue, important } };
|
376
|
+
}
|
377
|
+
return null;
|
378
|
+
}
|
379
|
+
|
380
|
+
/**
|
381
|
+
* Returns float.
|
382
|
+
*
|
383
|
+
* @param value Value.
|
384
|
+
* @param important Important.
|
385
|
+
* @returns Property values
|
386
|
+
*/
|
387
|
+
public static getCSSFloat(
|
388
|
+
value: string,
|
389
|
+
important: boolean
|
390
|
+
): {
|
391
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
392
|
+
} {
|
393
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
394
|
+
if (variable) {
|
395
|
+
return { 'css-float': { value: variable, important } };
|
396
|
+
}
|
397
|
+
const float = this.getFloat(value, important);
|
398
|
+
return float ? { 'css-float': float['float'] } : null;
|
399
|
+
}
|
400
|
+
|
401
|
+
/**
|
402
|
+
* Returns border.
|
403
|
+
*
|
404
|
+
* @param value Value.
|
405
|
+
* @param important Important.
|
406
|
+
* @returns Property values.
|
407
|
+
*/
|
408
|
+
public static getBorder(
|
409
|
+
value: string,
|
410
|
+
important: boolean
|
411
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
412
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
413
|
+
if (variable) {
|
414
|
+
return { border: { value: variable, important } };
|
415
|
+
}
|
416
|
+
|
417
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
418
|
+
|
419
|
+
if (globalValue) {
|
420
|
+
return {
|
421
|
+
...this.getBorderWidth(globalValue, important),
|
422
|
+
...this.getBorderStyle(globalValue, important),
|
423
|
+
...this.getBorderColor(globalValue, important),
|
424
|
+
...this.getBorderImage(globalValue, important)
|
425
|
+
};
|
426
|
+
}
|
427
|
+
|
428
|
+
const properties = {
|
429
|
+
...this.getBorderWidth('initial', important),
|
430
|
+
...this.getBorderStyle('initial', important),
|
431
|
+
...this.getBorderColor('initial', important),
|
432
|
+
...this.getBorderImage('initial', important)
|
433
|
+
};
|
434
|
+
|
435
|
+
const parts = value.replace(/ *, */g, ',').split(/ +/);
|
436
|
+
|
437
|
+
for (const part of parts) {
|
438
|
+
const width = this.getBorderWidth(part, important);
|
439
|
+
const style = this.getBorderStyle(part, important);
|
440
|
+
const color = this.getBorderColor(part, important);
|
441
|
+
|
442
|
+
if (width === null && style === null && color === null) {
|
443
|
+
return null;
|
444
|
+
}
|
445
|
+
|
446
|
+
Object.assign(properties, width, style, color);
|
447
|
+
}
|
448
|
+
|
449
|
+
return properties;
|
450
|
+
}
|
451
|
+
|
452
|
+
/**
|
453
|
+
* Returns border width.
|
454
|
+
*
|
455
|
+
* @param value Value.
|
456
|
+
* @param important Important.
|
457
|
+
* @returns Property values
|
458
|
+
*/
|
459
|
+
public static getBorderWidth(
|
460
|
+
value: string,
|
461
|
+
important: boolean
|
462
|
+
): {
|
463
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
464
|
+
} {
|
465
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
466
|
+
if (variable) {
|
467
|
+
return { 'border-width': { value: variable, important } };
|
468
|
+
}
|
469
|
+
|
470
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
471
|
+
|
472
|
+
if (globalValue) {
|
473
|
+
return {
|
474
|
+
...this.getBorderTopWidth(globalValue, important),
|
475
|
+
...this.getBorderRightWidth(globalValue, important),
|
476
|
+
...this.getBorderBottomWidth(globalValue, important),
|
477
|
+
...this.getBorderLeftWidth(globalValue, important)
|
478
|
+
};
|
479
|
+
}
|
480
|
+
|
481
|
+
const parts = value.split(/ +/);
|
482
|
+
const top = this.getBorderTopWidth(parts[0], important);
|
483
|
+
const right = this.getBorderRightWidth(parts[1] || parts[0], important);
|
484
|
+
const bottom = this.getBorderBottomWidth(parts[2] || parts[0], important);
|
485
|
+
const left = this.getBorderLeftWidth(parts[3] || parts[1] || parts[0], important);
|
486
|
+
|
487
|
+
if (!top || !right || !bottom || !left) {
|
488
|
+
return null;
|
489
|
+
}
|
490
|
+
|
491
|
+
return {
|
492
|
+
...top,
|
493
|
+
...right,
|
494
|
+
...bottom,
|
495
|
+
...left
|
496
|
+
};
|
497
|
+
}
|
498
|
+
/**
|
499
|
+
* Returns border style.
|
500
|
+
*
|
501
|
+
* @param value Value.
|
502
|
+
* @param important Important.
|
503
|
+
* @returns Property values
|
504
|
+
*/
|
505
|
+
public static getBorderStyle(
|
506
|
+
value: string,
|
507
|
+
important: boolean
|
508
|
+
): {
|
509
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
510
|
+
} {
|
511
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
512
|
+
if (variable) {
|
513
|
+
return { 'border-style': { value: variable, important } };
|
514
|
+
}
|
515
|
+
|
516
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
517
|
+
|
518
|
+
if (globalValue) {
|
519
|
+
return {
|
520
|
+
...this.getBorderTopStyle(globalValue, important),
|
521
|
+
...this.getBorderRightStyle(globalValue, important),
|
522
|
+
...this.getBorderBottomStyle(globalValue, important),
|
523
|
+
...this.getBorderLeftStyle(globalValue, important)
|
524
|
+
};
|
525
|
+
}
|
526
|
+
|
527
|
+
const parts = value.split(/ +/);
|
528
|
+
const top = this.getBorderTopStyle(parts[0], important);
|
529
|
+
const right = this.getBorderRightStyle(parts[1] || parts[0], important);
|
530
|
+
const bottom = this.getBorderBottomStyle(parts[2] || parts[0], important);
|
531
|
+
const left = this.getBorderLeftStyle(parts[3] || parts[1] || parts[0], important);
|
532
|
+
|
533
|
+
if (!top || !right || !bottom || !left) {
|
534
|
+
return null;
|
535
|
+
}
|
536
|
+
|
537
|
+
return {
|
538
|
+
...top,
|
539
|
+
...right,
|
540
|
+
...bottom,
|
541
|
+
...left
|
542
|
+
};
|
543
|
+
}
|
544
|
+
|
545
|
+
/**
|
546
|
+
* Returns border color.
|
547
|
+
*
|
548
|
+
* @param value Value.
|
549
|
+
* @param important Important.
|
550
|
+
* @returns Property values
|
551
|
+
*/
|
552
|
+
public static getBorderColor(
|
553
|
+
value: string,
|
554
|
+
important: boolean
|
555
|
+
): {
|
556
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
557
|
+
} {
|
558
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
559
|
+
if (variable) {
|
560
|
+
return { 'border-color': { value: variable, important } };
|
561
|
+
}
|
562
|
+
|
563
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
564
|
+
|
565
|
+
if (globalValue) {
|
566
|
+
return {
|
567
|
+
...this.getBorderTopColor(globalValue, important),
|
568
|
+
...this.getBorderRightColor(globalValue, important),
|
569
|
+
...this.getBorderBottomColor(globalValue, important),
|
570
|
+
...this.getBorderLeftColor(globalValue, important)
|
571
|
+
};
|
572
|
+
}
|
573
|
+
|
574
|
+
const parts = value.split(/ +/);
|
575
|
+
const top = this.getBorderTopColor(parts[0], important);
|
576
|
+
const right = this.getBorderRightColor(parts[1] || parts[0], important);
|
577
|
+
const bottom = this.getBorderBottomColor(parts[2] || parts[0], important);
|
578
|
+
const left = this.getBorderLeftColor(parts[3] || parts[1] || parts[0], important);
|
579
|
+
|
580
|
+
if (!top || !right || !bottom || !left) {
|
581
|
+
return null;
|
582
|
+
}
|
583
|
+
|
584
|
+
return {
|
585
|
+
...top,
|
586
|
+
...right,
|
587
|
+
...bottom,
|
588
|
+
...left
|
589
|
+
};
|
590
|
+
}
|
591
|
+
|
592
|
+
/**
|
593
|
+
* Returns border image.
|
594
|
+
*
|
595
|
+
* @param value Value.
|
596
|
+
* @param important Important.
|
597
|
+
* @returns Property values
|
598
|
+
*/
|
599
|
+
public static getBorderImage(
|
600
|
+
value: string,
|
601
|
+
important: boolean
|
602
|
+
): {
|
603
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
604
|
+
} {
|
605
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
606
|
+
if (variable) {
|
607
|
+
return { 'border-image': { value: variable, important } };
|
608
|
+
}
|
609
|
+
|
610
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
611
|
+
|
612
|
+
if (globalValue) {
|
613
|
+
return {
|
614
|
+
...this.getBorderImageSource(globalValue, important),
|
615
|
+
...this.getBorderImageSlice(globalValue, important),
|
616
|
+
...this.getBorderImageWidth(globalValue, important),
|
617
|
+
...this.getBorderImageOutset(globalValue, important),
|
618
|
+
...this.getBorderImageRepeat(globalValue, important)
|
619
|
+
};
|
620
|
+
}
|
621
|
+
|
622
|
+
let parsedValue = value.replace(/[ ]*\/[ ]*/g, '/');
|
623
|
+
const sourceMatch = parsedValue.match(/ *([a-zA-Z-]+\([^)]*\)) */);
|
624
|
+
|
625
|
+
if (sourceMatch) {
|
626
|
+
parsedValue = parsedValue.replace(sourceMatch[0], '');
|
627
|
+
}
|
628
|
+
|
629
|
+
const parts = parsedValue.split(/ +/);
|
630
|
+
|
631
|
+
if (sourceMatch) {
|
632
|
+
parts.push(sourceMatch[1]);
|
633
|
+
}
|
634
|
+
|
635
|
+
const properties = {
|
636
|
+
...this.getBorderImageSource('none', important),
|
637
|
+
...this.getBorderImageSlice('100%', important),
|
638
|
+
...this.getBorderImageWidth('1', important),
|
639
|
+
...this.getBorderImageOutset('0', important),
|
640
|
+
...this.getBorderImageRepeat('stretch', important)
|
641
|
+
};
|
642
|
+
|
643
|
+
for (let i = 0, max = parts.length; i < max; i++) {
|
644
|
+
const part = parts[i];
|
645
|
+
const previousPart = i > 0 ? parts[i - 1] : '';
|
646
|
+
|
647
|
+
if (!part.startsWith('url') && part.includes('/')) {
|
648
|
+
const [slice, width, outset] = part.split('/');
|
649
|
+
const borderImageSlice =
|
650
|
+
this.getBorderImageSlice(`${previousPart} ${slice}`, important) ||
|
651
|
+
this.getBorderImageSlice(slice, important);
|
652
|
+
const borderImageWidth = this.getBorderImageWidth(width, important);
|
653
|
+
const borderImageOutset = outset && this.getBorderImageOutset(outset, important);
|
654
|
+
|
655
|
+
if (!borderImageSlice || !borderImageWidth || borderImageOutset === null) {
|
656
|
+
return null;
|
657
|
+
}
|
658
|
+
|
659
|
+
Object.assign(properties, borderImageSlice, borderImageWidth, borderImageOutset);
|
660
|
+
} else {
|
661
|
+
const slice =
|
662
|
+
this.getBorderImageSlice(`${previousPart} ${part}`, important) ||
|
663
|
+
this.getBorderImageSlice(part, important);
|
664
|
+
const source = this.getBorderImageSource(part, important);
|
665
|
+
const repeat = this.getBorderImageRepeat(part, important);
|
666
|
+
|
667
|
+
if (!slice && !source && !repeat) {
|
668
|
+
return null;
|
669
|
+
}
|
670
|
+
|
671
|
+
Object.assign(properties, slice, source, repeat);
|
672
|
+
}
|
673
|
+
}
|
674
|
+
|
675
|
+
return properties;
|
676
|
+
}
|
677
|
+
|
678
|
+
/**
|
679
|
+
* Returns border source.
|
680
|
+
*
|
681
|
+
* @param value Value.
|
682
|
+
* @param important Important.
|
683
|
+
* @returns Property values
|
684
|
+
*/
|
685
|
+
public static getBorderImageSource(
|
686
|
+
value: string,
|
687
|
+
important: boolean
|
688
|
+
): {
|
689
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
690
|
+
} {
|
691
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
692
|
+
if (variable) {
|
693
|
+
return { 'border-image-source': { value: variable, important } };
|
694
|
+
}
|
695
|
+
|
696
|
+
const lowerValue = value.toLowerCase();
|
697
|
+
|
698
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === 'none') {
|
699
|
+
return {
|
700
|
+
'border-image-source': {
|
701
|
+
important,
|
702
|
+
value: lowerValue
|
703
|
+
}
|
704
|
+
};
|
705
|
+
}
|
706
|
+
|
707
|
+
const parsedValue =
|
708
|
+
CSSStyleDeclarationValueParser.getURL(value) ||
|
709
|
+
CSSStyleDeclarationValueParser.getGradient(value);
|
710
|
+
|
711
|
+
if (!parsedValue) {
|
712
|
+
return null;
|
713
|
+
}
|
714
|
+
|
715
|
+
return {
|
716
|
+
'border-image-source': {
|
717
|
+
important,
|
718
|
+
value: parsedValue
|
719
|
+
}
|
720
|
+
};
|
721
|
+
}
|
722
|
+
|
723
|
+
/**
|
724
|
+
* Returns border slice.
|
725
|
+
*
|
726
|
+
* @param value Value.
|
727
|
+
* @param important Important.
|
728
|
+
* @returns Property values
|
729
|
+
*/
|
730
|
+
public static getBorderImageSlice(
|
731
|
+
value: string,
|
732
|
+
important: boolean
|
733
|
+
): {
|
734
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
735
|
+
} {
|
736
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
737
|
+
if (variable) {
|
738
|
+
return { 'border-image-slice': { value: variable, important } };
|
739
|
+
}
|
740
|
+
|
741
|
+
const lowerValue = value.toLowerCase();
|
742
|
+
|
743
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) {
|
744
|
+
return {
|
745
|
+
'border-image-slice': {
|
746
|
+
important,
|
747
|
+
value: lowerValue
|
748
|
+
}
|
749
|
+
};
|
750
|
+
}
|
751
|
+
|
752
|
+
if (lowerValue !== lowerValue.trim()) {
|
753
|
+
return null;
|
754
|
+
}
|
755
|
+
|
756
|
+
const regexp = /(fill)|(calc\([^^)]+\))|([0-9]+%)|([0-9]+)/g;
|
757
|
+
const values = [];
|
758
|
+
let match;
|
759
|
+
|
760
|
+
while ((match = regexp.exec(lowerValue))) {
|
761
|
+
const previousCharacter = lowerValue[match.index - 1];
|
762
|
+
const nextCharacter = lowerValue[match.index + match[0].length];
|
763
|
+
|
764
|
+
if (
|
765
|
+
(previousCharacter && previousCharacter !== ' ') ||
|
766
|
+
(nextCharacter && nextCharacter !== ' ')
|
767
|
+
) {
|
768
|
+
return null;
|
769
|
+
}
|
770
|
+
|
771
|
+
const fill = match[1] && 'fill';
|
772
|
+
const calc = match[2] && CSSStyleDeclarationValueParser.getCalc(match[2]);
|
773
|
+
const percentage = match[3] && CSSStyleDeclarationValueParser.getPercentage(match[3]);
|
774
|
+
const integer = match[4] && CSSStyleDeclarationValueParser.getInteger(match[4]);
|
775
|
+
|
776
|
+
if (!fill && !calc && !percentage && !integer) {
|
777
|
+
return null;
|
778
|
+
}
|
779
|
+
|
780
|
+
values.push(fill || calc || percentage || integer);
|
781
|
+
}
|
782
|
+
|
783
|
+
if (!values.length || values.length > 4) {
|
784
|
+
return null;
|
785
|
+
}
|
786
|
+
|
787
|
+
return {
|
788
|
+
'border-image-slice': {
|
789
|
+
important,
|
790
|
+
value: values.join(' ')
|
791
|
+
}
|
792
|
+
};
|
793
|
+
}
|
794
|
+
|
795
|
+
/**
|
796
|
+
* Returns border width.
|
797
|
+
*
|
798
|
+
* @param value Value.
|
799
|
+
* @param important Important.
|
800
|
+
* @returns Property values
|
801
|
+
*/
|
802
|
+
public static getBorderImageWidth(
|
803
|
+
value: string,
|
804
|
+
important: boolean
|
805
|
+
): {
|
806
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
807
|
+
} {
|
808
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
809
|
+
if (variable) {
|
810
|
+
return { 'border-image-width': { value: variable, important } };
|
811
|
+
}
|
812
|
+
|
813
|
+
const lowerValue = value.toLowerCase();
|
814
|
+
|
815
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) {
|
816
|
+
return {
|
817
|
+
'border-image-width': {
|
818
|
+
important,
|
819
|
+
value: lowerValue
|
820
|
+
}
|
821
|
+
};
|
822
|
+
}
|
823
|
+
|
824
|
+
const parts = lowerValue.split(/ +/);
|
825
|
+
|
826
|
+
if (parts.length > 4) {
|
827
|
+
return null;
|
828
|
+
}
|
829
|
+
|
830
|
+
for (const part of parts) {
|
831
|
+
if (
|
832
|
+
!CSSStyleDeclarationValueParser.getInteger(part) &&
|
833
|
+
!CSSStyleDeclarationValueParser.getAutoMeasurement(part)
|
834
|
+
) {
|
835
|
+
return null;
|
836
|
+
}
|
837
|
+
}
|
838
|
+
|
839
|
+
return {
|
840
|
+
'border-image-width': {
|
841
|
+
important,
|
842
|
+
value
|
843
|
+
}
|
844
|
+
};
|
845
|
+
}
|
846
|
+
|
847
|
+
/**
|
848
|
+
* Returns border outset.
|
849
|
+
*
|
850
|
+
* @param value Value.
|
851
|
+
* @param important Important.
|
852
|
+
* @returns Property values
|
853
|
+
*/
|
854
|
+
public static getBorderImageOutset(
|
855
|
+
value: string,
|
856
|
+
important: boolean
|
857
|
+
): {
|
858
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
859
|
+
} {
|
860
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
861
|
+
if (variable) {
|
862
|
+
return { 'border-image-outset': { value: variable, important } };
|
863
|
+
}
|
864
|
+
|
865
|
+
const lowerValue = value.toLowerCase();
|
866
|
+
|
867
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) {
|
868
|
+
return {
|
869
|
+
'border-image-outset': {
|
870
|
+
important,
|
871
|
+
value: lowerValue
|
872
|
+
}
|
873
|
+
};
|
874
|
+
}
|
875
|
+
|
876
|
+
const parts = value.split(/ +/);
|
877
|
+
|
878
|
+
if (parts.length > 4) {
|
879
|
+
return null;
|
880
|
+
}
|
881
|
+
|
882
|
+
for (const part of parts) {
|
883
|
+
if (
|
884
|
+
!CSSStyleDeclarationValueParser.getLength(part) &&
|
885
|
+
!CSSStyleDeclarationValueParser.getFloat(part)
|
886
|
+
) {
|
887
|
+
return null;
|
888
|
+
}
|
889
|
+
}
|
890
|
+
|
891
|
+
return {
|
892
|
+
'border-image-outset': {
|
893
|
+
important,
|
894
|
+
value
|
895
|
+
}
|
896
|
+
};
|
897
|
+
}
|
898
|
+
|
899
|
+
/**
|
900
|
+
* Returns border repeat.
|
901
|
+
*
|
902
|
+
* @param value Value.
|
903
|
+
* @param important Important.
|
904
|
+
* @returns Property values
|
905
|
+
*/
|
906
|
+
public static getBorderImageRepeat(
|
907
|
+
value: string,
|
908
|
+
important: boolean
|
909
|
+
): {
|
910
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
911
|
+
} {
|
912
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
913
|
+
if (variable) {
|
914
|
+
return { 'border-image-repeat': { value: variable, important } };
|
915
|
+
}
|
916
|
+
|
917
|
+
const lowerValue = value.toLowerCase();
|
918
|
+
|
919
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) {
|
920
|
+
return {
|
921
|
+
'border-image-repeat': {
|
922
|
+
important,
|
923
|
+
value: lowerValue
|
924
|
+
}
|
925
|
+
};
|
926
|
+
}
|
927
|
+
|
928
|
+
const parts = lowerValue.split(/ +/);
|
929
|
+
|
930
|
+
if (parts.length > 2) {
|
931
|
+
return null;
|
932
|
+
}
|
933
|
+
|
934
|
+
for (const part of parts) {
|
935
|
+
if (!BORDER_IMAGE_REPEAT.includes(part)) {
|
936
|
+
return null;
|
937
|
+
}
|
938
|
+
}
|
939
|
+
|
940
|
+
return {
|
941
|
+
'border-image-repeat': {
|
942
|
+
important,
|
943
|
+
value
|
944
|
+
}
|
945
|
+
};
|
946
|
+
}
|
947
|
+
|
948
|
+
/**
|
949
|
+
* Returns border width.
|
950
|
+
*
|
951
|
+
* @param value Value.
|
952
|
+
* @param important Important.
|
953
|
+
* @returns Property values
|
954
|
+
*/
|
955
|
+
public static getBorderTopWidth(
|
956
|
+
value: string,
|
957
|
+
important: boolean
|
958
|
+
): {
|
959
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
960
|
+
} {
|
961
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
962
|
+
if (variable) {
|
963
|
+
return { 'border-top-width': { value: variable, important } };
|
964
|
+
}
|
965
|
+
|
966
|
+
const lowerValue = value.toLowerCase();
|
967
|
+
const parsedValue =
|
968
|
+
BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser.getGlobal(lowerValue)
|
969
|
+
? lowerValue
|
970
|
+
: CSSStyleDeclarationValueParser.getLength(value);
|
971
|
+
if (parsedValue) {
|
972
|
+
return {
|
973
|
+
'border-top-width': { value: parsedValue, important }
|
974
|
+
};
|
975
|
+
}
|
976
|
+
return null;
|
977
|
+
}
|
978
|
+
|
979
|
+
/**
|
980
|
+
* Returns border width.
|
981
|
+
*
|
982
|
+
* @param value Value.
|
983
|
+
* @param important Important.
|
984
|
+
* @returns Property values
|
985
|
+
*/
|
986
|
+
public static getBorderRightWidth(
|
987
|
+
value: string,
|
988
|
+
important: boolean
|
989
|
+
): {
|
990
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
991
|
+
} {
|
992
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
993
|
+
if (variable) {
|
994
|
+
return { 'border-right-width': { value: variable, important } };
|
995
|
+
}
|
996
|
+
|
997
|
+
const lowerValue = value.toLowerCase();
|
998
|
+
const parsedValue =
|
999
|
+
BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser.getGlobal(lowerValue)
|
1000
|
+
? lowerValue
|
1001
|
+
: CSSStyleDeclarationValueParser.getLength(value);
|
1002
|
+
if (parsedValue) {
|
1003
|
+
return {
|
1004
|
+
'border-right-width': { value: parsedValue, important }
|
1005
|
+
};
|
1006
|
+
}
|
1007
|
+
return null;
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
/**
|
1011
|
+
* Returns border width.
|
1012
|
+
*
|
1013
|
+
* @param value Value.
|
1014
|
+
* @param important Important.
|
1015
|
+
* @returns Property values
|
1016
|
+
*/
|
1017
|
+
public static getBorderBottomWidth(
|
1018
|
+
value: string,
|
1019
|
+
important: boolean
|
1020
|
+
): {
|
1021
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1022
|
+
} {
|
1023
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1024
|
+
if (variable) {
|
1025
|
+
return { 'border-bottom-width': { value: variable, important } };
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
const lowerValue = value.toLowerCase();
|
1029
|
+
const parsedValue =
|
1030
|
+
BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser.getGlobal(lowerValue)
|
1031
|
+
? lowerValue
|
1032
|
+
: CSSStyleDeclarationValueParser.getLength(value);
|
1033
|
+
if (parsedValue) {
|
1034
|
+
return {
|
1035
|
+
'border-bottom-width': { value: parsedValue, important }
|
1036
|
+
};
|
1037
|
+
}
|
1038
|
+
return null;
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
/**
|
1042
|
+
* Returns border width.
|
1043
|
+
*
|
1044
|
+
* @param value Value.
|
1045
|
+
* @param important Important.
|
1046
|
+
* @returns Property values
|
1047
|
+
*/
|
1048
|
+
public static getBorderLeftWidth(
|
1049
|
+
value: string,
|
1050
|
+
important: boolean
|
1051
|
+
): {
|
1052
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1053
|
+
} {
|
1054
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1055
|
+
if (variable) {
|
1056
|
+
return { 'border-left-width': { value: variable, important } };
|
1057
|
+
}
|
1058
|
+
|
1059
|
+
const lowerValue = value.toLowerCase();
|
1060
|
+
const parsedValue =
|
1061
|
+
BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser.getGlobal(lowerValue)
|
1062
|
+
? lowerValue
|
1063
|
+
: CSSStyleDeclarationValueParser.getLength(value);
|
1064
|
+
if (parsedValue) {
|
1065
|
+
return {
|
1066
|
+
'border-left-width': { value: parsedValue, important }
|
1067
|
+
};
|
1068
|
+
}
|
1069
|
+
return null;
|
1070
|
+
}
|
1071
|
+
|
1072
|
+
/**
|
1073
|
+
* Returns border style.
|
1074
|
+
*
|
1075
|
+
* @param value Value.
|
1076
|
+
* @param important Important.
|
1077
|
+
* @returns Property values
|
1078
|
+
*/
|
1079
|
+
public static getBorderTopStyle(
|
1080
|
+
value: string,
|
1081
|
+
important: boolean
|
1082
|
+
): {
|
1083
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1084
|
+
} {
|
1085
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1086
|
+
if (variable) {
|
1087
|
+
return { 'border-top-style': { value: variable, important } };
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
const lowerValue = value.toLowerCase();
|
1091
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) {
|
1092
|
+
return {
|
1093
|
+
'border-top-style': { value: lowerValue, important }
|
1094
|
+
};
|
1095
|
+
}
|
1096
|
+
return null;
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
/**
|
1100
|
+
* Returns border style.
|
1101
|
+
*
|
1102
|
+
* @param value Value.
|
1103
|
+
* @param important Important.
|
1104
|
+
* @returns Property values
|
1105
|
+
*/
|
1106
|
+
public static getBorderRightStyle(
|
1107
|
+
value: string,
|
1108
|
+
important: boolean
|
1109
|
+
): {
|
1110
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1111
|
+
} {
|
1112
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1113
|
+
if (variable) {
|
1114
|
+
return { 'border-right-style': { value: variable, important } };
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
const lowerValue = value.toLowerCase();
|
1118
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) {
|
1119
|
+
return {
|
1120
|
+
'border-right-style': { value: lowerValue, important }
|
1121
|
+
};
|
1122
|
+
}
|
1123
|
+
return null;
|
1124
|
+
}
|
1125
|
+
|
1126
|
+
/**
|
1127
|
+
* Returns border style.
|
1128
|
+
*
|
1129
|
+
* @param value Value.
|
1130
|
+
* @param important Important.
|
1131
|
+
* @returns Property values
|
1132
|
+
*/
|
1133
|
+
public static getBorderBottomStyle(
|
1134
|
+
value: string,
|
1135
|
+
important: boolean
|
1136
|
+
): {
|
1137
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1138
|
+
} {
|
1139
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1140
|
+
if (variable) {
|
1141
|
+
return { 'border-bottom-style': { value: variable, important } };
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
const lowerValue = value.toLowerCase();
|
1145
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) {
|
1146
|
+
return {
|
1147
|
+
'border-bottom-style': { value: lowerValue, important }
|
1148
|
+
};
|
1149
|
+
}
|
1150
|
+
return null;
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
/**
|
1154
|
+
* Returns border style.
|
1155
|
+
*
|
1156
|
+
* @param value Value.
|
1157
|
+
* @param important Important.
|
1158
|
+
* @returns Property values
|
1159
|
+
*/
|
1160
|
+
public static getBorderLeftStyle(
|
1161
|
+
value: string,
|
1162
|
+
important: boolean
|
1163
|
+
): {
|
1164
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1165
|
+
} {
|
1166
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1167
|
+
if (variable) {
|
1168
|
+
return { 'border-left-style': { value: variable, important } };
|
1169
|
+
}
|
1170
|
+
|
1171
|
+
const lowerValue = value.toLowerCase();
|
1172
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) {
|
1173
|
+
return {
|
1174
|
+
'border-left-style': { value: lowerValue, important }
|
1175
|
+
};
|
1176
|
+
}
|
1177
|
+
return null;
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
/**
|
1181
|
+
* Returns border color.
|
1182
|
+
*
|
1183
|
+
* @param value Value.
|
1184
|
+
* @param important Important.
|
1185
|
+
* @returns Property values
|
1186
|
+
*/
|
1187
|
+
public static getBorderTopColor(
|
1188
|
+
value: string,
|
1189
|
+
important: boolean
|
1190
|
+
): {
|
1191
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1192
|
+
} {
|
1193
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1194
|
+
if (variable) {
|
1195
|
+
return { 'border-top-color': { value: variable, important } };
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
const color =
|
1199
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1200
|
+
CSSStyleDeclarationValueParser.getColor(value);
|
1201
|
+
return color
|
1202
|
+
? {
|
1203
|
+
'border-top-color': { value: color, important }
|
1204
|
+
}
|
1205
|
+
: null;
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
/**
|
1209
|
+
* Returns border color.
|
1210
|
+
*
|
1211
|
+
* @param value Value.
|
1212
|
+
* @param important Important.
|
1213
|
+
* @returns Property values
|
1214
|
+
*/
|
1215
|
+
public static getBorderRightColor(
|
1216
|
+
value: string,
|
1217
|
+
important: boolean
|
1218
|
+
): {
|
1219
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1220
|
+
} {
|
1221
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1222
|
+
if (variable) {
|
1223
|
+
return { 'border-right-color': { value: variable, important } };
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
const color =
|
1227
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1228
|
+
CSSStyleDeclarationValueParser.getColor(value);
|
1229
|
+
return color
|
1230
|
+
? {
|
1231
|
+
'border-right-color': { value: color, important }
|
1232
|
+
}
|
1233
|
+
: null;
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
/**
|
1237
|
+
* Returns border color.
|
1238
|
+
*
|
1239
|
+
* @param value Value.
|
1240
|
+
* @param important Important.
|
1241
|
+
* @returns Property values
|
1242
|
+
*/
|
1243
|
+
public static getBorderBottomColor(
|
1244
|
+
value: string,
|
1245
|
+
important: boolean
|
1246
|
+
): {
|
1247
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1248
|
+
} {
|
1249
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1250
|
+
if (variable) {
|
1251
|
+
return { 'border-bottom-color': { value: variable, important } };
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
const color =
|
1255
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1256
|
+
CSSStyleDeclarationValueParser.getColor(value);
|
1257
|
+
return color
|
1258
|
+
? {
|
1259
|
+
'border-bottom-color': { value: color, important }
|
1260
|
+
}
|
1261
|
+
: null;
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
/**
|
1265
|
+
* Returns border color.
|
1266
|
+
*
|
1267
|
+
* @param value Value.
|
1268
|
+
* @param important Important.
|
1269
|
+
* @returns Property values
|
1270
|
+
*/
|
1271
|
+
public static getBorderLeftColor(
|
1272
|
+
value: string,
|
1273
|
+
important: boolean
|
1274
|
+
): {
|
1275
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1276
|
+
} {
|
1277
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1278
|
+
if (variable) {
|
1279
|
+
return { 'border-left-color': { value: variable, important } };
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
const color =
|
1283
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1284
|
+
CSSStyleDeclarationValueParser.getColor(value);
|
1285
|
+
return color
|
1286
|
+
? {
|
1287
|
+
'border-left-color': { value: color, important }
|
1288
|
+
}
|
1289
|
+
: null;
|
1290
|
+
}
|
1291
|
+
|
1292
|
+
/**
|
1293
|
+
* Returns border radius.
|
1294
|
+
*
|
1295
|
+
* @param value Value.
|
1296
|
+
* @param important Important.
|
1297
|
+
* @returns Property values.
|
1298
|
+
*/
|
1299
|
+
public static getBorderRadius(
|
1300
|
+
value: string,
|
1301
|
+
important: boolean
|
1302
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1303
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1304
|
+
if (variable) {
|
1305
|
+
return { 'border-radius': { value: variable, important } };
|
1306
|
+
}
|
1307
|
+
|
1308
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
1309
|
+
|
1310
|
+
if (globalValue) {
|
1311
|
+
return {
|
1312
|
+
...this.getBorderTopLeftRadius(globalValue, important),
|
1313
|
+
...this.getBorderTopRightRadius(globalValue, important),
|
1314
|
+
...this.getBorderBottomRightRadius(globalValue, important),
|
1315
|
+
...this.getBorderBottomLeftRadius(globalValue, important)
|
1316
|
+
};
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
const parts = value.split(/ +/);
|
1320
|
+
const topLeft = this.getBorderTopLeftRadius(parts[0], important);
|
1321
|
+
const topRight = this.getBorderTopRightRadius(parts[1] || parts[0], important);
|
1322
|
+
const bottomRight = this.getBorderBottomRightRadius(parts[2] || parts[0], important);
|
1323
|
+
const bottomLeft = this.getBorderBottomLeftRadius(parts[3] || parts[1] || parts[0], important);
|
1324
|
+
|
1325
|
+
if (!topLeft || !topRight || !bottomRight || !bottomLeft) {
|
1326
|
+
return null;
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
return {
|
1330
|
+
...topLeft,
|
1331
|
+
...topRight,
|
1332
|
+
...bottomRight,
|
1333
|
+
...bottomLeft
|
1334
|
+
};
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
/**
|
1338
|
+
* Returns border radius.
|
1339
|
+
*
|
1340
|
+
* @param value Value.
|
1341
|
+
* @param important Important.
|
1342
|
+
* @returns Property values.
|
1343
|
+
*/
|
1344
|
+
public static getBorderTopLeftRadius(
|
1345
|
+
value: string,
|
1346
|
+
important: boolean
|
1347
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1348
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1349
|
+
if (variable) {
|
1350
|
+
return { 'border-top-left-radius': { value: variable, important } };
|
1351
|
+
}
|
1352
|
+
|
1353
|
+
const radius =
|
1354
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1355
|
+
CSSStyleDeclarationValueParser.getMeasurement(value);
|
1356
|
+
return radius ? { 'border-top-left-radius': { important, value: radius } } : null;
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
/**
|
1360
|
+
* Returns border radius.
|
1361
|
+
*
|
1362
|
+
* @param value Value.
|
1363
|
+
* @param important Important.
|
1364
|
+
* @returns Property values.
|
1365
|
+
*/
|
1366
|
+
public static getBorderTopRightRadius(
|
1367
|
+
value: string,
|
1368
|
+
important: boolean
|
1369
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1370
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1371
|
+
if (variable) {
|
1372
|
+
return { 'border-top-right-radius': { value: variable, important } };
|
1373
|
+
}
|
1374
|
+
|
1375
|
+
const radius =
|
1376
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1377
|
+
CSSStyleDeclarationValueParser.getMeasurement(value);
|
1378
|
+
return radius ? { 'border-top-right-radius': { important, value: radius } } : null;
|
1379
|
+
}
|
1380
|
+
|
1381
|
+
/**
|
1382
|
+
* Returns border radius.
|
1383
|
+
*
|
1384
|
+
* @param value Value.
|
1385
|
+
* @param important Important.
|
1386
|
+
* @returns Property values.
|
1387
|
+
*/
|
1388
|
+
public static getBorderBottomRightRadius(
|
1389
|
+
value: string,
|
1390
|
+
important: boolean
|
1391
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1392
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1393
|
+
if (variable) {
|
1394
|
+
return { 'border-bottom-right-radius': { value: variable, important } };
|
1395
|
+
}
|
1396
|
+
|
1397
|
+
const radius =
|
1398
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1399
|
+
CSSStyleDeclarationValueParser.getMeasurement(value);
|
1400
|
+
return radius ? { 'border-bottom-right-radius': { important, value: radius } } : null;
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
/**
|
1404
|
+
* Returns border radius.
|
1405
|
+
*
|
1406
|
+
* @param value Value.
|
1407
|
+
* @param important Important.
|
1408
|
+
* @returns Property values.
|
1409
|
+
*/
|
1410
|
+
public static getBorderBottomLeftRadius(
|
1411
|
+
value: string,
|
1412
|
+
important: boolean
|
1413
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1414
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1415
|
+
if (variable) {
|
1416
|
+
return { 'border-bottom-left-radius': { value: variable, important } };
|
1417
|
+
}
|
1418
|
+
|
1419
|
+
const radius =
|
1420
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1421
|
+
CSSStyleDeclarationValueParser.getMeasurement(value);
|
1422
|
+
return radius ? { 'border-bottom-left-radius': { important, value: radius } } : null;
|
1423
|
+
}
|
1424
|
+
|
1425
|
+
/**
|
1426
|
+
* Returns border top, right, bottom or left.
|
1427
|
+
*
|
1428
|
+
* @param value Value.
|
1429
|
+
* @param important Important.
|
1430
|
+
* @returns Property values.
|
1431
|
+
*/
|
1432
|
+
public static getBorderTop(
|
1433
|
+
value: string,
|
1434
|
+
important: boolean
|
1435
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1436
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1437
|
+
if (variable) {
|
1438
|
+
return { 'border-top': { value: variable, important } };
|
1439
|
+
}
|
1440
|
+
|
1441
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
1442
|
+
|
1443
|
+
if (globalValue) {
|
1444
|
+
return {
|
1445
|
+
...this.getBorderTopWidth(globalValue, important),
|
1446
|
+
...this.getBorderTopStyle(globalValue, important),
|
1447
|
+
...this.getBorderTopColor(globalValue, important)
|
1448
|
+
};
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
const properties = {
|
1452
|
+
...this.getBorderTopWidth('initial', important),
|
1453
|
+
...this.getBorderTopStyle('initial', important),
|
1454
|
+
...this.getBorderTopColor('initial', important)
|
1455
|
+
};
|
1456
|
+
|
1457
|
+
const parts = value.split(/ +/);
|
1458
|
+
|
1459
|
+
for (const part of parts) {
|
1460
|
+
const width = this.getBorderTopWidth(part, important);
|
1461
|
+
const style = this.getBorderTopStyle(part, important);
|
1462
|
+
const color = this.getBorderTopColor(part, important);
|
1463
|
+
|
1464
|
+
if (width === null && style === null && color === null) {
|
1465
|
+
return null;
|
1466
|
+
}
|
1467
|
+
|
1468
|
+
Object.assign(properties, width, style, color);
|
1469
|
+
}
|
1470
|
+
|
1471
|
+
return properties;
|
1472
|
+
}
|
1473
|
+
|
1474
|
+
/**
|
1475
|
+
* Returns border top, right, bottom or left.
|
1476
|
+
*
|
1477
|
+
* @param value Value.
|
1478
|
+
* @param important Important.
|
1479
|
+
* @returns Property values.
|
1480
|
+
*/
|
1481
|
+
public static getBorderRight(
|
1482
|
+
value: string,
|
1483
|
+
important: boolean
|
1484
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1485
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1486
|
+
if (variable) {
|
1487
|
+
return { 'border-right': { value: variable, important } };
|
1488
|
+
}
|
1489
|
+
|
1490
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
1491
|
+
|
1492
|
+
if (globalValue) {
|
1493
|
+
return {
|
1494
|
+
...this.getBorderRightWidth(globalValue, important),
|
1495
|
+
...this.getBorderRightStyle(globalValue, important),
|
1496
|
+
...this.getBorderRightColor(globalValue, important)
|
1497
|
+
};
|
1498
|
+
}
|
1499
|
+
|
1500
|
+
const properties = {
|
1501
|
+
...this.getBorderRightWidth('initial', important),
|
1502
|
+
...this.getBorderRightStyle('initial', important),
|
1503
|
+
...this.getBorderRightColor('initial', important)
|
1504
|
+
};
|
1505
|
+
|
1506
|
+
const parts = value.split(/ +/);
|
1507
|
+
|
1508
|
+
for (const part of parts) {
|
1509
|
+
const width = this.getBorderRightWidth(part, important);
|
1510
|
+
const style = this.getBorderRightStyle(part, important);
|
1511
|
+
const color = this.getBorderRightColor(part, important);
|
1512
|
+
|
1513
|
+
if (width === null && style === null && color === null) {
|
1514
|
+
return null;
|
1515
|
+
}
|
1516
|
+
|
1517
|
+
Object.assign(properties, width, style, color);
|
1518
|
+
}
|
1519
|
+
|
1520
|
+
return properties;
|
1521
|
+
}
|
1522
|
+
|
1523
|
+
/**
|
1524
|
+
* Returns border top, right, bottom or left.
|
1525
|
+
*
|
1526
|
+
* @param value Value.
|
1527
|
+
* @param important Important.
|
1528
|
+
* @returns Property values.
|
1529
|
+
*/
|
1530
|
+
public static getBorderBottom(
|
1531
|
+
value: string,
|
1532
|
+
important: boolean
|
1533
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1534
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1535
|
+
if (variable) {
|
1536
|
+
return { 'border-bottom': { value: variable, important } };
|
1537
|
+
}
|
1538
|
+
|
1539
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
1540
|
+
|
1541
|
+
if (globalValue) {
|
1542
|
+
return {
|
1543
|
+
...this.getBorderBottomWidth(globalValue, important),
|
1544
|
+
...this.getBorderBottomStyle(globalValue, important),
|
1545
|
+
...this.getBorderBottomColor(globalValue, important)
|
1546
|
+
};
|
1547
|
+
}
|
1548
|
+
|
1549
|
+
const properties = {
|
1550
|
+
...this.getBorderBottomWidth('initial', important),
|
1551
|
+
...this.getBorderBottomStyle('initial', important),
|
1552
|
+
...this.getBorderBottomColor('initial', important)
|
1553
|
+
};
|
1554
|
+
|
1555
|
+
const parts = value.split(/ +/);
|
1556
|
+
|
1557
|
+
for (const part of parts) {
|
1558
|
+
const width = this.getBorderBottomWidth(part, important);
|
1559
|
+
const style = this.getBorderBottomStyle(part, important);
|
1560
|
+
const color = this.getBorderBottomColor(part, important);
|
1561
|
+
|
1562
|
+
if (width === null && style === null && color === null) {
|
1563
|
+
return null;
|
1564
|
+
}
|
1565
|
+
|
1566
|
+
Object.assign(properties, width, style, color);
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
return properties;
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
/**
|
1573
|
+
* Returns border top, right, bottom or left.
|
1574
|
+
*
|
1575
|
+
* @param value Value.
|
1576
|
+
* @param important Important.
|
1577
|
+
* @returns Property values.
|
1578
|
+
*/
|
1579
|
+
public static getBorderLeft(
|
1580
|
+
value: string,
|
1581
|
+
important: boolean
|
1582
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1583
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1584
|
+
if (variable) {
|
1585
|
+
return { 'border-left': { value: variable, important } };
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
1589
|
+
|
1590
|
+
if (globalValue) {
|
1591
|
+
return {
|
1592
|
+
...this.getBorderLeftWidth(globalValue, important),
|
1593
|
+
...this.getBorderLeftStyle(globalValue, important),
|
1594
|
+
...this.getBorderLeftColor(globalValue, important)
|
1595
|
+
};
|
1596
|
+
}
|
1597
|
+
|
1598
|
+
const properties = {
|
1599
|
+
...this.getBorderLeftWidth('initial', important),
|
1600
|
+
...this.getBorderLeftStyle('initial', important),
|
1601
|
+
...this.getBorderLeftColor('initial', important)
|
1602
|
+
};
|
1603
|
+
|
1604
|
+
const parts = value.split(/ +/);
|
1605
|
+
|
1606
|
+
for (const part of parts) {
|
1607
|
+
const width = this.getBorderLeftWidth(part, important);
|
1608
|
+
const style = this.getBorderLeftStyle(part, important);
|
1609
|
+
const color = this.getBorderLeftColor(part, important);
|
1610
|
+
|
1611
|
+
if (width === null && style === null && color === null) {
|
1612
|
+
return null;
|
1613
|
+
}
|
1614
|
+
|
1615
|
+
Object.assign(properties, width, style, color);
|
1616
|
+
}
|
1617
|
+
|
1618
|
+
return properties;
|
1619
|
+
}
|
1620
|
+
|
1621
|
+
/**
|
1622
|
+
* Returns padding.
|
1623
|
+
*
|
1624
|
+
* @param value Value.
|
1625
|
+
* @param important Important.
|
1626
|
+
*/
|
1627
|
+
public static getPadding(
|
1628
|
+
value: string,
|
1629
|
+
important: boolean
|
1630
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1631
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1632
|
+
if (variable) {
|
1633
|
+
return { padding: { value: variable, important } };
|
1634
|
+
}
|
1635
|
+
|
1636
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
1637
|
+
|
1638
|
+
if (globalValue) {
|
1639
|
+
return {
|
1640
|
+
...this.getPaddingTop(globalValue, important),
|
1641
|
+
...this.getPaddingRight(globalValue, important),
|
1642
|
+
...this.getPaddingBottom(globalValue, important),
|
1643
|
+
...this.getPaddingLeft(globalValue, important)
|
1644
|
+
};
|
1645
|
+
}
|
1646
|
+
|
1647
|
+
const parts = value.split(/ +/);
|
1648
|
+
const top = this.getPaddingTop(parts[0], important);
|
1649
|
+
const right = this.getPaddingRight(parts[1] || parts[0], important);
|
1650
|
+
const bottom = this.getPaddingBottom(parts[2] || parts[0], important);
|
1651
|
+
const left = this.getPaddingLeft(parts[3] || parts[1] || parts[0], important);
|
1652
|
+
|
1653
|
+
if (!top || !right || !bottom || !left) {
|
1654
|
+
return null;
|
1655
|
+
}
|
1656
|
+
|
1657
|
+
return {
|
1658
|
+
...top,
|
1659
|
+
...right,
|
1660
|
+
...bottom,
|
1661
|
+
...left
|
1662
|
+
};
|
1663
|
+
}
|
1664
|
+
|
1665
|
+
/**
|
1666
|
+
* Returns padding top.
|
1667
|
+
*
|
1668
|
+
* @param value Value.
|
1669
|
+
* @param important Important.
|
1670
|
+
* @returns Property values.
|
1671
|
+
*/
|
1672
|
+
public static getPaddingTop(
|
1673
|
+
value: string,
|
1674
|
+
important: boolean
|
1675
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1676
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1677
|
+
if (variable) {
|
1678
|
+
return { 'padding-top': { value: variable, important } };
|
1679
|
+
}
|
1680
|
+
|
1681
|
+
const padding =
|
1682
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1683
|
+
CSSStyleDeclarationValueParser.getMeasurement(value);
|
1684
|
+
return padding ? { 'padding-top': { value: padding, important } } : null;
|
1685
|
+
}
|
1686
|
+
|
1687
|
+
/**
|
1688
|
+
* Returns padding right.
|
1689
|
+
*
|
1690
|
+
* @param value Value.
|
1691
|
+
* @param important Important.
|
1692
|
+
* @returns Property values.
|
1693
|
+
*/
|
1694
|
+
public static getPaddingRight(
|
1695
|
+
value: string,
|
1696
|
+
important: boolean
|
1697
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1698
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1699
|
+
if (variable) {
|
1700
|
+
return { 'padding-right': { value: variable, important } };
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
const padding =
|
1704
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1705
|
+
CSSStyleDeclarationValueParser.getMeasurement(value);
|
1706
|
+
return padding ? { 'padding-right': { value: padding, important } } : null;
|
1707
|
+
}
|
1708
|
+
|
1709
|
+
/**
|
1710
|
+
* Returns padding bottom.
|
1711
|
+
*
|
1712
|
+
* @param value Value.
|
1713
|
+
* @param important Important.
|
1714
|
+
* @returns Property values.
|
1715
|
+
*/
|
1716
|
+
public static getPaddingBottom(
|
1717
|
+
value: string,
|
1718
|
+
important: boolean
|
1719
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1720
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1721
|
+
if (variable) {
|
1722
|
+
return { 'padding-bottom': { value: variable, important } };
|
1723
|
+
}
|
1724
|
+
|
1725
|
+
const padding =
|
1726
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1727
|
+
CSSStyleDeclarationValueParser.getMeasurement(value);
|
1728
|
+
return padding ? { 'padding-bottom': { value: padding, important } } : null;
|
1729
|
+
}
|
1730
|
+
|
1731
|
+
/**
|
1732
|
+
* Returns padding left.
|
1733
|
+
*
|
1734
|
+
* @param value Value.
|
1735
|
+
* @param important Important.
|
1736
|
+
* @returns Property values.
|
1737
|
+
*/
|
1738
|
+
public static getPaddingLeft(
|
1739
|
+
value: string,
|
1740
|
+
important: boolean
|
1741
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1742
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1743
|
+
if (variable) {
|
1744
|
+
return { 'padding-left': { value: variable, important } };
|
1745
|
+
}
|
1746
|
+
|
1747
|
+
const padding =
|
1748
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1749
|
+
CSSStyleDeclarationValueParser.getMeasurement(value);
|
1750
|
+
return padding ? { 'padding-left': { value: padding, important } } : null;
|
1751
|
+
}
|
1752
|
+
|
1753
|
+
/**
|
1754
|
+
* Returns margin.
|
1755
|
+
*
|
1756
|
+
* @param value Value.
|
1757
|
+
* @param important Important.
|
1758
|
+
* @returns Property values.
|
1759
|
+
*/
|
1760
|
+
public static getMargin(
|
1761
|
+
value: string,
|
1762
|
+
important: boolean
|
1763
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1764
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1765
|
+
if (variable) {
|
1766
|
+
return { margin: { value: variable, important } };
|
1767
|
+
}
|
1768
|
+
|
1769
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
1770
|
+
|
1771
|
+
if (globalValue) {
|
1772
|
+
return {
|
1773
|
+
...this.getMarginTop(globalValue, important),
|
1774
|
+
...this.getMarginRight(globalValue, important),
|
1775
|
+
...this.getMarginBottom(globalValue, important),
|
1776
|
+
...this.getMarginLeft(globalValue, important)
|
1777
|
+
};
|
1778
|
+
}
|
1779
|
+
|
1780
|
+
const parts = value.split(/ +/);
|
1781
|
+
const top = this.getMarginTop(parts[0], important);
|
1782
|
+
const right = this.getMarginRight(parts[1] || parts[0], important);
|
1783
|
+
const bottom = this.getMarginBottom(parts[2] || parts[0], important);
|
1784
|
+
const left = this.getMarginLeft(parts[3] || parts[1] || parts[0], important);
|
1785
|
+
|
1786
|
+
if (!top || !right || !bottom || !left) {
|
1787
|
+
return null;
|
1788
|
+
}
|
1789
|
+
|
1790
|
+
return {
|
1791
|
+
...top,
|
1792
|
+
...right,
|
1793
|
+
...bottom,
|
1794
|
+
...left
|
1795
|
+
};
|
1796
|
+
}
|
1797
|
+
|
1798
|
+
/**
|
1799
|
+
* Returns margin top.
|
1800
|
+
*
|
1801
|
+
* @param value Value.
|
1802
|
+
* @param important Important.
|
1803
|
+
* @returns Property values.
|
1804
|
+
*/
|
1805
|
+
public static getMarginTop(
|
1806
|
+
value: string,
|
1807
|
+
important: boolean
|
1808
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1809
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1810
|
+
if (variable) {
|
1811
|
+
return { 'margin-top': { value: variable, important } };
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
const margin =
|
1815
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1816
|
+
CSSStyleDeclarationValueParser.getAutoMeasurement(value);
|
1817
|
+
return margin ? { 'margin-top': { value: margin, important } } : null;
|
1818
|
+
}
|
1819
|
+
|
1820
|
+
/**
|
1821
|
+
* Returns margin right.
|
1822
|
+
*
|
1823
|
+
* @param value Value.
|
1824
|
+
* @param important Important.
|
1825
|
+
* @returns Property values.
|
1826
|
+
*/
|
1827
|
+
public static getMarginRight(
|
1828
|
+
value: string,
|
1829
|
+
important: boolean
|
1830
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1831
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1832
|
+
if (variable) {
|
1833
|
+
return { 'margin-right': { value: variable, important } };
|
1834
|
+
}
|
1835
|
+
|
1836
|
+
const margin =
|
1837
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1838
|
+
CSSStyleDeclarationValueParser.getAutoMeasurement(value);
|
1839
|
+
return margin ? { 'margin-right': { value: margin, important } } : null;
|
1840
|
+
}
|
1841
|
+
|
1842
|
+
/**
|
1843
|
+
* Returns margin right.
|
1844
|
+
*
|
1845
|
+
* @param value Value.
|
1846
|
+
* @param important Important.
|
1847
|
+
* @returns Property values.
|
1848
|
+
*/
|
1849
|
+
public static getMarginBottom(
|
1850
|
+
value: string,
|
1851
|
+
important: boolean
|
1852
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1853
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1854
|
+
if (variable) {
|
1855
|
+
return { 'margin-bottom': { value: variable, important } };
|
1856
|
+
}
|
1857
|
+
|
1858
|
+
const margin =
|
1859
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1860
|
+
CSSStyleDeclarationValueParser.getAutoMeasurement(value);
|
1861
|
+
return margin ? { 'margin-bottom': { value: margin, important } } : null;
|
1862
|
+
}
|
1863
|
+
|
1864
|
+
/**
|
1865
|
+
* Returns margin left.
|
1866
|
+
*
|
1867
|
+
* @param value Value.
|
1868
|
+
* @param important Important.
|
1869
|
+
* @returns Property values.
|
1870
|
+
*/
|
1871
|
+
public static getMarginLeft(
|
1872
|
+
value: string,
|
1873
|
+
important: boolean
|
1874
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1875
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1876
|
+
if (variable) {
|
1877
|
+
return { 'margin-left': { value: variable, important } };
|
1878
|
+
}
|
1879
|
+
|
1880
|
+
const margin =
|
1881
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
1882
|
+
CSSStyleDeclarationValueParser.getAutoMeasurement(value);
|
1883
|
+
return margin ? { 'margin-left': { value: margin, important } } : null;
|
1884
|
+
}
|
1885
|
+
|
1886
|
+
/**
|
1887
|
+
* Returns flex.
|
1888
|
+
*
|
1889
|
+
* @param value Value.
|
1890
|
+
* @param important Important.
|
1891
|
+
* @returns Property values.
|
1892
|
+
*/
|
1893
|
+
public static getFlex(
|
1894
|
+
value: string,
|
1895
|
+
important: boolean
|
1896
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
1897
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1898
|
+
if (variable) {
|
1899
|
+
return { flex: { value: variable, important } };
|
1900
|
+
}
|
1901
|
+
|
1902
|
+
const lowerValue = value.trim().toLowerCase();
|
1903
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
1904
|
+
|
1905
|
+
if (globalValue) {
|
1906
|
+
return {
|
1907
|
+
...this.getFlexGrow(globalValue, important),
|
1908
|
+
...this.getFlexShrink(globalValue, important),
|
1909
|
+
...this.getFlexBasis(globalValue, important)
|
1910
|
+
};
|
1911
|
+
}
|
1912
|
+
|
1913
|
+
switch (lowerValue) {
|
1914
|
+
case 'none':
|
1915
|
+
return {
|
1916
|
+
...this.getFlexGrow('0', important),
|
1917
|
+
...this.getFlexShrink('0', important),
|
1918
|
+
...this.getFlexBasis('auto', important)
|
1919
|
+
};
|
1920
|
+
case 'auto':
|
1921
|
+
return {
|
1922
|
+
...this.getFlexGrow('1', important),
|
1923
|
+
...this.getFlexShrink('1', important),
|
1924
|
+
...this.getFlexBasis('auto', important)
|
1925
|
+
};
|
1926
|
+
}
|
1927
|
+
|
1928
|
+
const measurement = CSSStyleDeclarationValueParser.getContentMeasurement(lowerValue);
|
1929
|
+
|
1930
|
+
if (measurement) {
|
1931
|
+
return {
|
1932
|
+
...this.getFlexGrow('1', important),
|
1933
|
+
...this.getFlexShrink('1', important),
|
1934
|
+
...this.getFlexBasis(measurement, important)
|
1935
|
+
};
|
1936
|
+
}
|
1937
|
+
|
1938
|
+
const parts = value.split(/ +/);
|
1939
|
+
const flexGrow = this.getFlexGrow(parts[0], important);
|
1940
|
+
const flexShrink = this.getFlexShrink(parts[1] || '1', important);
|
1941
|
+
const flexBasis = this.getFlexBasis(parts[2] || '0%', important);
|
1942
|
+
|
1943
|
+
if (!flexGrow || !flexShrink || !flexBasis) {
|
1944
|
+
return null;
|
1945
|
+
}
|
1946
|
+
|
1947
|
+
return {
|
1948
|
+
...flexGrow,
|
1949
|
+
...flexShrink,
|
1950
|
+
...flexBasis
|
1951
|
+
};
|
1952
|
+
}
|
1953
|
+
|
1954
|
+
/**
|
1955
|
+
* Returns flex basis.
|
1956
|
+
*
|
1957
|
+
* @param value Value.
|
1958
|
+
* @param important Important.
|
1959
|
+
* @returns Property values
|
1960
|
+
*/
|
1961
|
+
public static getFlexBasis(
|
1962
|
+
value: string,
|
1963
|
+
important: boolean
|
1964
|
+
): {
|
1965
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1966
|
+
} {
|
1967
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1968
|
+
if (variable) {
|
1969
|
+
return { 'flex-basis': { value: variable, important } };
|
1970
|
+
}
|
1971
|
+
|
1972
|
+
const lowerValue = value.toLowerCase();
|
1973
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FLEX_BASIS.includes(lowerValue)) {
|
1974
|
+
return { 'flex-basis': { value: lowerValue, important } };
|
1975
|
+
}
|
1976
|
+
const measurement = CSSStyleDeclarationValueParser.getContentMeasurement(lowerValue);
|
1977
|
+
return measurement ? { 'flex-basis': { value: measurement, important } } : null;
|
1978
|
+
}
|
1979
|
+
|
1980
|
+
/**
|
1981
|
+
* Returns flex shrink.
|
1982
|
+
*
|
1983
|
+
* @param value Value.
|
1984
|
+
* @param important Important.
|
1985
|
+
* @returns Property values
|
1986
|
+
*/
|
1987
|
+
public static getFlexShrink(
|
1988
|
+
value: string,
|
1989
|
+
important: boolean
|
1990
|
+
): {
|
1991
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
1992
|
+
} {
|
1993
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
1994
|
+
if (variable) {
|
1995
|
+
return { 'flex-shrink': { value: variable, important } };
|
1996
|
+
}
|
1997
|
+
|
1998
|
+
const parsedValue =
|
1999
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
2000
|
+
CSSStyleDeclarationValueParser.getFloat(value);
|
2001
|
+
return parsedValue ? { 'flex-shrink': { value: parsedValue, important } } : null;
|
2002
|
+
}
|
2003
|
+
|
2004
|
+
/**
|
2005
|
+
* Returns flex grow.
|
2006
|
+
*
|
2007
|
+
* @param value Value.
|
2008
|
+
* @param important Important.
|
2009
|
+
* @returns Property values
|
2010
|
+
*/
|
2011
|
+
public static getFlexGrow(
|
2012
|
+
value: string,
|
2013
|
+
important: boolean
|
2014
|
+
): {
|
2015
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2016
|
+
} {
|
2017
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2018
|
+
if (variable) {
|
2019
|
+
return { 'flex-grow': { value: variable, important } };
|
2020
|
+
}
|
2021
|
+
|
2022
|
+
const parsedValue =
|
2023
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
2024
|
+
CSSStyleDeclarationValueParser.getFloat(value);
|
2025
|
+
return parsedValue ? { 'flex-grow': { value: parsedValue, important } } : null;
|
2026
|
+
}
|
2027
|
+
|
2028
|
+
/**
|
2029
|
+
* Returns background.
|
2030
|
+
*
|
2031
|
+
* @param name Name.
|
2032
|
+
* @param value Value.
|
2033
|
+
* @param important Important.
|
2034
|
+
* @returns Property values.
|
2035
|
+
*/
|
2036
|
+
public static getBackground(
|
2037
|
+
value: string,
|
2038
|
+
important: boolean
|
2039
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
2040
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2041
|
+
if (variable) {
|
2042
|
+
return { background: { value: variable, important } };
|
2043
|
+
}
|
2044
|
+
|
2045
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
2046
|
+
|
2047
|
+
if (globalValue) {
|
2048
|
+
return {
|
2049
|
+
...this.getBackgroundImage(globalValue, important),
|
2050
|
+
...this.getBackgroundPosition(globalValue, important),
|
2051
|
+
...this.getBackgroundSize(globalValue, important),
|
2052
|
+
...this.getBackgroundRepeat(globalValue, important),
|
2053
|
+
...this.getBackgroundAttachment(globalValue, important),
|
2054
|
+
...this.getBackgroundOrigin(globalValue, important),
|
2055
|
+
...this.getBackgroundClip(globalValue, important),
|
2056
|
+
...this.getBackgroundColor(globalValue, important)
|
2057
|
+
};
|
2058
|
+
}
|
2059
|
+
|
2060
|
+
const properties = {
|
2061
|
+
...this.getBackgroundImage('initial', important),
|
2062
|
+
...this.getBackgroundPosition('initial', important),
|
2063
|
+
...this.getBackgroundSize('initial', important),
|
2064
|
+
...this.getBackgroundRepeat('initial', important),
|
2065
|
+
...this.getBackgroundAttachment('initial', important),
|
2066
|
+
...this.getBackgroundOrigin('initial', important),
|
2067
|
+
...this.getBackgroundClip('initial', important),
|
2068
|
+
...this.getBackgroundColor('initial', important)
|
2069
|
+
};
|
2070
|
+
|
2071
|
+
const parts = value
|
2072
|
+
.replace(/[ ]*,[ ]*/g, ',')
|
2073
|
+
.replace(/[ ]*\/[ ]*/g, '/')
|
2074
|
+
.split(/ +/);
|
2075
|
+
|
2076
|
+
const backgroundPositions = [];
|
2077
|
+
|
2078
|
+
for (const part of parts) {
|
2079
|
+
if (!part.startsWith('url') && part.includes('/')) {
|
2080
|
+
const [position, size] = part.split('/');
|
2081
|
+
const backgroundPositionX = this.getBackgroundPositionX(position, important);
|
2082
|
+
const backgroundPositionY = this.getBackgroundPositionY(position, important);
|
2083
|
+
|
2084
|
+
const backgroundSize = this.getBackgroundSize(size, important);
|
2085
|
+
|
2086
|
+
if ((!backgroundPositionX && !backgroundPositionY) || !backgroundSize) {
|
2087
|
+
return null;
|
2088
|
+
}
|
2089
|
+
|
2090
|
+
if (backgroundPositionY) {
|
2091
|
+
backgroundPositions.push(backgroundPositionY['background-position-y'].value);
|
2092
|
+
} else if (backgroundPositionX) {
|
2093
|
+
backgroundPositions.push(backgroundPositionX['background-position-x'].value);
|
2094
|
+
}
|
2095
|
+
|
2096
|
+
Object.assign(properties, backgroundSize);
|
2097
|
+
} else {
|
2098
|
+
const backgroundImage = this.getBackgroundImage(part, important);
|
2099
|
+
const backgroundRepeat = this.getBackgroundRepeat(part, important);
|
2100
|
+
const backgroundAttachment = this.getBackgroundAttachment(part, important);
|
2101
|
+
const backgroundPositionX = this.getBackgroundPositionX(part, important);
|
2102
|
+
const backgroundPositionY = this.getBackgroundPositionY(part, important);
|
2103
|
+
const backgroundColor = this.getBackgroundColor(part, important);
|
2104
|
+
const backgroundOrigin = this.getBackgroundOrigin(part, important);
|
2105
|
+
const backgroundClip = this.getBackgroundClip(part, important);
|
2106
|
+
|
2107
|
+
if (
|
2108
|
+
!backgroundImage &&
|
2109
|
+
!backgroundRepeat &&
|
2110
|
+
!backgroundAttachment &&
|
2111
|
+
!backgroundPositionX &&
|
2112
|
+
!backgroundPositionY &&
|
2113
|
+
!backgroundColor &&
|
2114
|
+
!backgroundOrigin &&
|
2115
|
+
!backgroundClip
|
2116
|
+
) {
|
2117
|
+
return null;
|
2118
|
+
}
|
2119
|
+
|
2120
|
+
if (backgroundPositionX) {
|
2121
|
+
backgroundPositions.push(backgroundPositionX['background-position-x'].value);
|
2122
|
+
} else if (backgroundPositionY) {
|
2123
|
+
backgroundPositions.push(backgroundPositionY['background-position-y'].value);
|
2124
|
+
}
|
2125
|
+
|
2126
|
+
Object.assign(
|
2127
|
+
properties,
|
2128
|
+
backgroundImage,
|
2129
|
+
backgroundRepeat,
|
2130
|
+
backgroundAttachment,
|
2131
|
+
backgroundColor,
|
2132
|
+
backgroundOrigin,
|
2133
|
+
backgroundClip
|
2134
|
+
);
|
2135
|
+
}
|
2136
|
+
}
|
2137
|
+
|
2138
|
+
if (backgroundPositions.length) {
|
2139
|
+
Object.assign(
|
2140
|
+
properties,
|
2141
|
+
this.getBackgroundPosition(backgroundPositions.join(' '), important)
|
2142
|
+
);
|
2143
|
+
}
|
2144
|
+
|
2145
|
+
return properties;
|
2146
|
+
}
|
2147
|
+
|
2148
|
+
/**
|
2149
|
+
* Returns background size.
|
2150
|
+
*
|
2151
|
+
* @param value Value.
|
2152
|
+
* @param important Important.
|
2153
|
+
* @returns Property values
|
2154
|
+
*/
|
2155
|
+
public static getBackgroundSize(
|
2156
|
+
value: string,
|
2157
|
+
important: boolean
|
2158
|
+
): {
|
2159
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2160
|
+
} {
|
2161
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2162
|
+
if (variable) {
|
2163
|
+
return { 'background-size': { value: variable, important } };
|
2164
|
+
}
|
2165
|
+
|
2166
|
+
const lowerValue = value.toLowerCase();
|
2167
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) {
|
2168
|
+
return { 'background-size': { value: lowerValue, important } };
|
2169
|
+
}
|
2170
|
+
|
2171
|
+
const imageParts = lowerValue.split(',');
|
2172
|
+
const parsed = [];
|
2173
|
+
|
2174
|
+
for (const imagePart of imageParts) {
|
2175
|
+
const parts = imagePart.trim().split(' ');
|
2176
|
+
if (parts.length !== 1 && parts.length !== 2) {
|
2177
|
+
return null;
|
2178
|
+
}
|
2179
|
+
if (parts.length === 1) {
|
2180
|
+
if (
|
2181
|
+
parts[0] !== 'cover' &&
|
2182
|
+
parts[0] !== 'contain' &&
|
2183
|
+
!CSSStyleDeclarationValueParser.getAutoMeasurement(parts[0])
|
2184
|
+
) {
|
2185
|
+
return null;
|
2186
|
+
}
|
2187
|
+
parsed.push(parts[0]);
|
2188
|
+
} else {
|
2189
|
+
if (
|
2190
|
+
!CSSStyleDeclarationValueParser.getAutoMeasurement(parts[0]) ||
|
2191
|
+
!CSSStyleDeclarationValueParser.getAutoMeasurement(parts[1])
|
2192
|
+
) {
|
2193
|
+
return null;
|
2194
|
+
}
|
2195
|
+
parsed.push(`${parts[0]} ${parts[1]}`);
|
2196
|
+
}
|
2197
|
+
}
|
2198
|
+
if (parsed.length === 1) {
|
2199
|
+
return { 'background-size': { value: parsed.join(', '), important } };
|
2200
|
+
}
|
2201
|
+
return null;
|
2202
|
+
}
|
2203
|
+
|
2204
|
+
/**
|
2205
|
+
* Returns background origin.
|
2206
|
+
*
|
2207
|
+
* @param value Value.
|
2208
|
+
* @param important Important.
|
2209
|
+
* @returns Property values
|
2210
|
+
*/
|
2211
|
+
public static getBackgroundOrigin(
|
2212
|
+
value: string,
|
2213
|
+
important: boolean
|
2214
|
+
): {
|
2215
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2216
|
+
} {
|
2217
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2218
|
+
if (variable) {
|
2219
|
+
return { 'background-origin': { value: variable, important } };
|
2220
|
+
}
|
2221
|
+
|
2222
|
+
const lowerValue = value.toLowerCase();
|
2223
|
+
if (
|
2224
|
+
CSSStyleDeclarationValueParser.getGlobal(lowerValue) ||
|
2225
|
+
BACKGROUND_ORIGIN.includes(lowerValue)
|
2226
|
+
) {
|
2227
|
+
return { 'background-origin': { value: lowerValue, important } };
|
2228
|
+
}
|
2229
|
+
return null;
|
2230
|
+
}
|
2231
|
+
|
2232
|
+
/**
|
2233
|
+
* Returns background clip.
|
2234
|
+
*
|
2235
|
+
* @param value Value.
|
2236
|
+
* @param important Important.
|
2237
|
+
* @returns Property values
|
2238
|
+
*/
|
2239
|
+
public static getBackgroundClip(
|
2240
|
+
value: string,
|
2241
|
+
important: boolean
|
2242
|
+
): {
|
2243
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2244
|
+
} {
|
2245
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2246
|
+
if (variable) {
|
2247
|
+
return { 'background-clip': { value: variable, important } };
|
2248
|
+
}
|
2249
|
+
|
2250
|
+
const lowerValue = value.toLowerCase();
|
2251
|
+
if (
|
2252
|
+
CSSStyleDeclarationValueParser.getGlobal(lowerValue) ||
|
2253
|
+
BACKGROUND_CLIP.includes(lowerValue)
|
2254
|
+
) {
|
2255
|
+
return { 'background-clip': { value: lowerValue, important } };
|
2256
|
+
}
|
2257
|
+
return null;
|
2258
|
+
}
|
2259
|
+
|
2260
|
+
/**
|
2261
|
+
* Returns background repeat.
|
2262
|
+
*
|
2263
|
+
* @param value Value.
|
2264
|
+
* @param important Important.
|
2265
|
+
* @returns Property values
|
2266
|
+
*/
|
2267
|
+
public static getBackgroundRepeat(
|
2268
|
+
value: string,
|
2269
|
+
important: boolean
|
2270
|
+
): {
|
2271
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2272
|
+
} {
|
2273
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2274
|
+
if (variable) {
|
2275
|
+
return { 'background-repeat': { value: variable, important } };
|
2276
|
+
}
|
2277
|
+
|
2278
|
+
const lowerValue = value.toLowerCase();
|
2279
|
+
if (
|
2280
|
+
CSSStyleDeclarationValueParser.getGlobal(lowerValue) ||
|
2281
|
+
BACKGROUND_REPEAT.includes(lowerValue)
|
2282
|
+
) {
|
2283
|
+
return { 'background-repeat': { value: lowerValue, important } };
|
2284
|
+
}
|
2285
|
+
return null;
|
2286
|
+
}
|
2287
|
+
|
2288
|
+
/**
|
2289
|
+
* Returns background attachment.
|
2290
|
+
*
|
2291
|
+
* @param value Value.
|
2292
|
+
* @param important Important.
|
2293
|
+
* @returns Property values
|
2294
|
+
*/
|
2295
|
+
public static getBackgroundAttachment(
|
2296
|
+
value: string,
|
2297
|
+
important: boolean
|
2298
|
+
): {
|
2299
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2300
|
+
} {
|
2301
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2302
|
+
if (variable) {
|
2303
|
+
return { 'background-attachment': { value: variable, important } };
|
2304
|
+
}
|
2305
|
+
|
2306
|
+
const lowerValue = value.toLowerCase();
|
2307
|
+
if (
|
2308
|
+
CSSStyleDeclarationValueParser.getGlobal(lowerValue) ||
|
2309
|
+
BACKGROUND_ATTACHMENT.includes(lowerValue)
|
2310
|
+
) {
|
2311
|
+
return { 'background-attachment': { value: lowerValue, important } };
|
2312
|
+
}
|
2313
|
+
return null;
|
2314
|
+
}
|
2315
|
+
|
2316
|
+
/**
|
2317
|
+
* Returns background position.
|
2318
|
+
*
|
2319
|
+
* @param value Value.
|
2320
|
+
* @param important Important.
|
2321
|
+
* @returns Property values
|
2322
|
+
*/
|
2323
|
+
public static getBackgroundPosition(
|
2324
|
+
value: string,
|
2325
|
+
important: boolean
|
2326
|
+
): {
|
2327
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2328
|
+
} {
|
2329
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2330
|
+
if (variable) {
|
2331
|
+
return { 'background-position': { value: variable, important } };
|
2332
|
+
}
|
2333
|
+
|
2334
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
2335
|
+
if (globalValue) {
|
2336
|
+
return {
|
2337
|
+
...this.getBackgroundPositionX(globalValue, important),
|
2338
|
+
...this.getBackgroundPositionY(globalValue, important)
|
2339
|
+
};
|
2340
|
+
}
|
2341
|
+
|
2342
|
+
const imageParts = value.replace(/ *, */g, ',').split(',');
|
2343
|
+
let x = '';
|
2344
|
+
let y = '';
|
2345
|
+
|
2346
|
+
for (const imagePart of imageParts) {
|
2347
|
+
const parts = imagePart.trim().split(/ +/);
|
2348
|
+
|
2349
|
+
if (x) {
|
2350
|
+
x += ',';
|
2351
|
+
y += ',';
|
2352
|
+
}
|
2353
|
+
|
2354
|
+
switch (parts.length) {
|
2355
|
+
case 1:
|
2356
|
+
if (parts[0] === 'top' || parts[0] === 'bottom') {
|
2357
|
+
x += 'center';
|
2358
|
+
y += parts[0];
|
2359
|
+
} else if (parts[0] === 'left' || parts[0] === 'right') {
|
2360
|
+
x += parts[0];
|
2361
|
+
y += 'center';
|
2362
|
+
} else if (parts[0] === 'center') {
|
2363
|
+
x += 'center';
|
2364
|
+
y += 'center';
|
2365
|
+
}
|
2366
|
+
break;
|
2367
|
+
case 2:
|
2368
|
+
x += parts[0] === 'top' || parts[0] === 'bottom' ? parts[1] : parts[0];
|
2369
|
+
y += parts[0] === 'top' || parts[0] === 'bottom' ? parts[0] : parts[1];
|
2370
|
+
break;
|
2371
|
+
case 3:
|
2372
|
+
if (
|
2373
|
+
parts[0] === 'top' ||
|
2374
|
+
parts[0] === 'bottom' ||
|
2375
|
+
parts[1] === 'left' ||
|
2376
|
+
parts[1] === 'right' ||
|
2377
|
+
parts[2] === 'left' ||
|
2378
|
+
parts[2] === 'right'
|
2379
|
+
) {
|
2380
|
+
if (CSSStyleDeclarationValueParser.getMeasurement(parts[1])) {
|
2381
|
+
x += parts[2];
|
2382
|
+
y += `${parts[0]} ${parts[1]}`;
|
2383
|
+
} else {
|
2384
|
+
x += `${parts[1]} ${parts[2]}`;
|
2385
|
+
y += parts[0];
|
2386
|
+
}
|
2387
|
+
} else {
|
2388
|
+
if (CSSStyleDeclarationValueParser.getMeasurement(parts[1])) {
|
2389
|
+
x += `${parts[0]} ${parts[1]}`;
|
2390
|
+
y += parts[2];
|
2391
|
+
} else {
|
2392
|
+
x += parts[0];
|
2393
|
+
y += `${parts[1]} ${parts[2]}`;
|
2394
|
+
}
|
2395
|
+
}
|
2396
|
+
break;
|
2397
|
+
case 4:
|
2398
|
+
x +=
|
2399
|
+
parts[0] === 'top' ||
|
2400
|
+
parts[0] === 'bottom' ||
|
2401
|
+
parts[1] === 'top' ||
|
2402
|
+
parts[1] === 'bottom'
|
2403
|
+
? `${parts[2]} ${parts[3]}`
|
2404
|
+
: `${parts[0]} ${parts[1]}`;
|
2405
|
+
y +=
|
2406
|
+
parts[0] === 'top' ||
|
2407
|
+
parts[0] === 'bottom' ||
|
2408
|
+
parts[1] === 'top' ||
|
2409
|
+
parts[1] === 'bottom'
|
2410
|
+
? `${parts[0]} ${parts[1]}`
|
2411
|
+
: `${parts[2]} ${parts[3]}`;
|
2412
|
+
break;
|
2413
|
+
default:
|
2414
|
+
return null;
|
2415
|
+
}
|
2416
|
+
}
|
2417
|
+
|
2418
|
+
const xValue = this.getBackgroundPositionX(x, important);
|
2419
|
+
const yValue = this.getBackgroundPositionY(y, important);
|
2420
|
+
|
2421
|
+
if (xValue && yValue) {
|
2422
|
+
return {
|
2423
|
+
...xValue,
|
2424
|
+
...yValue
|
2425
|
+
};
|
2426
|
+
}
|
2427
|
+
|
2428
|
+
return null;
|
2429
|
+
}
|
2430
|
+
|
2431
|
+
/**
|
2432
|
+
* Returns background position.
|
2433
|
+
*
|
2434
|
+
* @param value Value.
|
2435
|
+
* @param important Important.
|
2436
|
+
* @returns Property values
|
2437
|
+
*/
|
2438
|
+
public static getBackgroundPositionX(
|
2439
|
+
value: string,
|
2440
|
+
important: boolean
|
2441
|
+
): {
|
2442
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2443
|
+
} {
|
2444
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2445
|
+
if (variable) {
|
2446
|
+
return { 'background-position-x': { value: variable, important } };
|
2447
|
+
}
|
2448
|
+
|
2449
|
+
const lowerValue = value.toLowerCase();
|
2450
|
+
|
2451
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) {
|
2452
|
+
return { 'background-position-x': { value: lowerValue, important } };
|
2453
|
+
}
|
2454
|
+
|
2455
|
+
const imageParts = lowerValue.replace(/ *, */g, ',').split(',');
|
2456
|
+
let parsedValue = '';
|
2457
|
+
|
2458
|
+
for (const imagePart of imageParts) {
|
2459
|
+
const parts = imagePart.trim().split(/ +/);
|
2460
|
+
|
2461
|
+
if (parsedValue) {
|
2462
|
+
parsedValue += ',';
|
2463
|
+
}
|
2464
|
+
|
2465
|
+
for (const part of parts) {
|
2466
|
+
const measurement = CSSStyleDeclarationValueParser.getMeasurement(part);
|
2467
|
+
if (!measurement && part !== 'left' && part !== 'right' && part !== 'center') {
|
2468
|
+
return null;
|
2469
|
+
}
|
2470
|
+
|
2471
|
+
if (parsedValue) {
|
2472
|
+
parsedValue += ' ';
|
2473
|
+
}
|
2474
|
+
|
2475
|
+
parsedValue += measurement || part;
|
2476
|
+
}
|
2477
|
+
}
|
2478
|
+
|
2479
|
+
return { 'background-position-x': { value: parsedValue, important } };
|
2480
|
+
}
|
2481
|
+
|
2482
|
+
/**
|
2483
|
+
* Returns background position.
|
2484
|
+
*
|
2485
|
+
* @param value Value.
|
2486
|
+
* @param important Important.
|
2487
|
+
* @returns Property values
|
2488
|
+
*/
|
2489
|
+
public static getBackgroundPositionY(
|
2490
|
+
value: string,
|
2491
|
+
important: boolean
|
2492
|
+
): {
|
2493
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2494
|
+
} {
|
2495
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2496
|
+
if (variable) {
|
2497
|
+
return { 'background-position-y': { value: variable, important } };
|
2498
|
+
}
|
2499
|
+
|
2500
|
+
const lowerValue = value.toLowerCase();
|
2501
|
+
|
2502
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) {
|
2503
|
+
return { 'background-position-y': { value: lowerValue, important } };
|
2504
|
+
}
|
2505
|
+
|
2506
|
+
const imageParts = lowerValue.replace(/ *, */g, ',').split(',');
|
2507
|
+
let parsedValue = '';
|
2508
|
+
|
2509
|
+
for (const imagePart of imageParts) {
|
2510
|
+
const parts = imagePart.trim().split(/ +/);
|
2511
|
+
|
2512
|
+
if (parsedValue) {
|
2513
|
+
parsedValue += ',';
|
2514
|
+
}
|
2515
|
+
|
2516
|
+
for (const part of parts) {
|
2517
|
+
const measurement = CSSStyleDeclarationValueParser.getMeasurement(part);
|
2518
|
+
if (!measurement && part !== 'top' && part !== 'bottom' && part !== 'center') {
|
2519
|
+
return null;
|
2520
|
+
}
|
2521
|
+
|
2522
|
+
if (parsedValue) {
|
2523
|
+
parsedValue += ' ';
|
2524
|
+
}
|
2525
|
+
|
2526
|
+
parsedValue += measurement || part;
|
2527
|
+
}
|
2528
|
+
}
|
2529
|
+
|
2530
|
+
return { 'background-position-y': { value: parsedValue, important } };
|
2531
|
+
}
|
2532
|
+
|
2533
|
+
/**
|
2534
|
+
* Returns background color.
|
2535
|
+
*
|
2536
|
+
* @param value Value.
|
2537
|
+
* @param important Important.
|
2538
|
+
* @returns Property value.
|
2539
|
+
*/
|
2540
|
+
public static getBackgroundColor(
|
2541
|
+
value: string,
|
2542
|
+
important: boolean
|
2543
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
2544
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2545
|
+
if (variable) {
|
2546
|
+
return { 'background-color': { value: variable, important } };
|
2547
|
+
}
|
2548
|
+
|
2549
|
+
const color =
|
2550
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
2551
|
+
CSSStyleDeclarationValueParser.getColor(value);
|
2552
|
+
|
2553
|
+
return color
|
2554
|
+
? {
|
2555
|
+
['background-color']: { important, value: color }
|
2556
|
+
}
|
2557
|
+
: null;
|
2558
|
+
}
|
2559
|
+
|
2560
|
+
/**
|
2561
|
+
* Returns background image.
|
2562
|
+
*
|
2563
|
+
* @param value Value.
|
2564
|
+
* @param important Important.
|
2565
|
+
* @returns Property value.
|
2566
|
+
*/
|
2567
|
+
public static getBackgroundImage(
|
2568
|
+
value: string,
|
2569
|
+
important: boolean
|
2570
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
2571
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2572
|
+
if (variable) {
|
2573
|
+
return { 'background-image': { value: variable, important } };
|
2574
|
+
}
|
2575
|
+
|
2576
|
+
const lowerValue = value.toLowerCase();
|
2577
|
+
|
2578
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === 'none') {
|
2579
|
+
return { 'background-image': { value: lowerValue, important } };
|
2580
|
+
}
|
2581
|
+
|
2582
|
+
const parts = value.replace(/ *, */g, ',').split(',');
|
2583
|
+
const parsed = [];
|
2584
|
+
|
2585
|
+
for (const part of parts) {
|
2586
|
+
const url = CSSStyleDeclarationValueParser.getURL(part.trim());
|
2587
|
+
if (!url) {
|
2588
|
+
return null;
|
2589
|
+
}
|
2590
|
+
parsed.push(url);
|
2591
|
+
}
|
2592
|
+
|
2593
|
+
if (parsed.length) {
|
2594
|
+
return { 'background-image': { value: parsed.join(', '), important } };
|
2595
|
+
}
|
2596
|
+
|
2597
|
+
return null;
|
2598
|
+
}
|
2599
|
+
|
2600
|
+
/**
|
2601
|
+
* Returns color.
|
2602
|
+
*
|
2603
|
+
* @param value Value.
|
2604
|
+
* @param important Important.
|
2605
|
+
* @returns Property value.
|
2606
|
+
*/
|
2607
|
+
public static getColor(
|
2608
|
+
value: string,
|
2609
|
+
important: boolean
|
2610
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
2611
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2612
|
+
if (variable) {
|
2613
|
+
return { color: { value: variable, important } };
|
2614
|
+
}
|
2615
|
+
|
2616
|
+
const color =
|
2617
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
2618
|
+
CSSStyleDeclarationValueParser.getColor(value);
|
2619
|
+
|
2620
|
+
return color ? { color: { important, value: color } } : null;
|
2621
|
+
}
|
2622
|
+
|
2623
|
+
/**
|
2624
|
+
* Returns color.
|
2625
|
+
*
|
2626
|
+
* @param value Value.
|
2627
|
+
* @param important Important.
|
2628
|
+
* @returns Property value.
|
2629
|
+
*/
|
2630
|
+
public static getFloodColor(
|
2631
|
+
value: string,
|
2632
|
+
important: boolean
|
2633
|
+
): { [key: string]: ICSSStyleDeclarationPropertyValue } {
|
2634
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2635
|
+
if (variable) {
|
2636
|
+
return { 'flood-color': { value: variable, important } };
|
2637
|
+
}
|
2638
|
+
const color =
|
2639
|
+
CSSStyleDeclarationValueParser.getGlobal(value) ||
|
2640
|
+
CSSStyleDeclarationValueParser.getColor(value);
|
2641
|
+
|
2642
|
+
return color ? { 'flood-color': { important, value: color } } : null;
|
2643
|
+
}
|
2644
|
+
|
2645
|
+
/**
|
2646
|
+
* Returns font.
|
2647
|
+
*
|
2648
|
+
* @param value Value.
|
2649
|
+
* @param important Important.
|
2650
|
+
* @returns Property values
|
2651
|
+
*/
|
2652
|
+
public static getFont(
|
2653
|
+
value: string,
|
2654
|
+
important: boolean
|
2655
|
+
): {
|
2656
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2657
|
+
} {
|
2658
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2659
|
+
if (variable) {
|
2660
|
+
return { font: { value: variable, important } };
|
2661
|
+
}
|
2662
|
+
|
2663
|
+
const lowerValue = value.toLowerCase();
|
2664
|
+
|
2665
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) {
|
2666
|
+
return {
|
2667
|
+
...this.getFontStyle(lowerValue, important),
|
2668
|
+
...this.getFontVariant(lowerValue, important),
|
2669
|
+
...this.getFontWeight(lowerValue, important),
|
2670
|
+
...this.getFontStretch(lowerValue, important),
|
2671
|
+
...this.getFontSize(lowerValue, important),
|
2672
|
+
...this.getLineHeight(lowerValue, important),
|
2673
|
+
...this.getFontFamily(lowerValue, important)
|
2674
|
+
};
|
2675
|
+
}
|
2676
|
+
|
2677
|
+
if (SYSTEM_FONT.includes(lowerValue)) {
|
2678
|
+
return { font: { value: lowerValue, important } };
|
2679
|
+
}
|
2680
|
+
|
2681
|
+
const properties = {
|
2682
|
+
...this.getFontStyle('normal', important),
|
2683
|
+
...this.getFontVariant('normal', important),
|
2684
|
+
...this.getFontWeight('normal', important),
|
2685
|
+
...this.getFontStretch('normal', important),
|
2686
|
+
...this.getLineHeight('normal', important)
|
2687
|
+
};
|
2688
|
+
|
2689
|
+
const parts = value.replace(/ *\/ */g, '/').split(/ +/);
|
2690
|
+
|
2691
|
+
for (let i = 0, max = parts.length; i < max; i++) {
|
2692
|
+
const part = parts[i];
|
2693
|
+
if (part.includes('/')) {
|
2694
|
+
const [size, height] = part.split('/');
|
2695
|
+
const fontSize = this.getFontSize(size, important);
|
2696
|
+
const lineHeight = this.getLineHeight(height, important);
|
2697
|
+
|
2698
|
+
if (!fontSize || !lineHeight) {
|
2699
|
+
return null;
|
2700
|
+
}
|
2701
|
+
|
2702
|
+
Object.assign(properties, fontSize, lineHeight);
|
2703
|
+
} else {
|
2704
|
+
const fontStyle = this.getFontStyle(part, important);
|
2705
|
+
const fontVariant = this.getFontVariant(part, important);
|
2706
|
+
const fontWeight = this.getFontWeight(part, important);
|
2707
|
+
const fontSize = this.getFontSize(part, important);
|
2708
|
+
const fontStretch = this.getFontStretch(part, important);
|
2709
|
+
|
2710
|
+
if (fontStyle) {
|
2711
|
+
Object.assign(properties, fontStyle);
|
2712
|
+
} else if (fontVariant) {
|
2713
|
+
Object.assign(properties, fontVariant);
|
2714
|
+
} else if (fontWeight) {
|
2715
|
+
Object.assign(properties, fontWeight);
|
2716
|
+
} else if (fontSize) {
|
2717
|
+
Object.assign(properties, fontSize);
|
2718
|
+
} else if (fontStretch) {
|
2719
|
+
Object.assign(properties, fontStretch);
|
2720
|
+
} else {
|
2721
|
+
const fontFamilyValue = parts.slice(i).join(' ');
|
2722
|
+
const fontFamily = this.getFontFamily(fontFamilyValue, important);
|
2723
|
+
if (!fontFamily) {
|
2724
|
+
return null;
|
2725
|
+
}
|
2726
|
+
Object.assign(properties, fontFamily);
|
2727
|
+
break;
|
2728
|
+
}
|
2729
|
+
}
|
2730
|
+
}
|
2731
|
+
|
2732
|
+
return properties;
|
2733
|
+
}
|
2734
|
+
|
2735
|
+
/**
|
2736
|
+
* Returns font style.
|
2737
|
+
*
|
2738
|
+
* @param value Value.
|
2739
|
+
* @param important Important.
|
2740
|
+
* @returns Property values
|
2741
|
+
*/
|
2742
|
+
public static getFontStyle(
|
2743
|
+
value: string,
|
2744
|
+
important: boolean
|
2745
|
+
): {
|
2746
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2747
|
+
} {
|
2748
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2749
|
+
if (variable) {
|
2750
|
+
return { 'font-style': { value: variable, important } };
|
2751
|
+
}
|
2752
|
+
|
2753
|
+
const lowerValue = value.toLowerCase();
|
2754
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FONT_STYLE.includes(lowerValue)) {
|
2755
|
+
return { 'font-style': { value: lowerValue, important } };
|
2756
|
+
}
|
2757
|
+
const parts = value.split(/ +/);
|
2758
|
+
if (parts.length === 2 && parts[0] === 'oblique') {
|
2759
|
+
const degree = CSSStyleDeclarationValueParser.getDegree(parts[1]);
|
2760
|
+
return degree ? { 'font-style': { value: lowerValue, important } } : null;
|
2761
|
+
}
|
2762
|
+
return null;
|
2763
|
+
}
|
2764
|
+
|
2765
|
+
/**
|
2766
|
+
* Returns font variant.
|
2767
|
+
*
|
2768
|
+
* @param value Value.
|
2769
|
+
* @param important Important.
|
2770
|
+
* @returns Property values
|
2771
|
+
*/
|
2772
|
+
public static getFontVariant(
|
2773
|
+
value: string,
|
2774
|
+
important: boolean
|
2775
|
+
): {
|
2776
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2777
|
+
} {
|
2778
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2779
|
+
if (variable) {
|
2780
|
+
return { 'font-variant': { value: variable, important } };
|
2781
|
+
}
|
2782
|
+
|
2783
|
+
const lowerValue = value.toLowerCase();
|
2784
|
+
return CSSStyleDeclarationValueParser.getGlobal(lowerValue) ||
|
2785
|
+
lowerValue === 'normal' ||
|
2786
|
+
lowerValue === 'small-caps'
|
2787
|
+
? { 'font-variant': { value: lowerValue, important } }
|
2788
|
+
: null;
|
2789
|
+
}
|
2790
|
+
|
2791
|
+
/**
|
2792
|
+
* Returns font strech.
|
2793
|
+
*
|
2794
|
+
* @param value Value.
|
2795
|
+
* @param important Important.
|
2796
|
+
* @returns Property values
|
2797
|
+
*/
|
2798
|
+
public static getFontStretch(
|
2799
|
+
value: string,
|
2800
|
+
important: boolean
|
2801
|
+
): {
|
2802
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2803
|
+
} {
|
2804
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2805
|
+
if (variable) {
|
2806
|
+
return { 'font-stretch': { value: variable, important } };
|
2807
|
+
}
|
2808
|
+
|
2809
|
+
const lowerValue = value.toLowerCase();
|
2810
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FONT_STRETCH.includes(lowerValue)) {
|
2811
|
+
return { 'font-stretch': { value: lowerValue, important } };
|
2812
|
+
}
|
2813
|
+
const percentage = CSSStyleDeclarationValueParser.getPercentage(value);
|
2814
|
+
return percentage ? { 'font-stretch': { value: percentage, important } } : null;
|
2815
|
+
}
|
2816
|
+
|
2817
|
+
/**
|
2818
|
+
* Returns font weight.
|
2819
|
+
*
|
2820
|
+
* @param value Value.
|
2821
|
+
* @param important Important.
|
2822
|
+
* @returns Property values
|
2823
|
+
*/
|
2824
|
+
public static getFontWeight(
|
2825
|
+
value: string,
|
2826
|
+
important: boolean
|
2827
|
+
): {
|
2828
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2829
|
+
} {
|
2830
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2831
|
+
if (variable) {
|
2832
|
+
return { 'font-weight': { value: variable, important } };
|
2833
|
+
}
|
2834
|
+
|
2835
|
+
const lowerValue = value.toLowerCase();
|
2836
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FONT_WEIGHT.includes(lowerValue)) {
|
2837
|
+
return { 'font-weight': { value: lowerValue, important } };
|
2838
|
+
}
|
2839
|
+
const integer = CSSStyleDeclarationValueParser.getInteger(value);
|
2840
|
+
return integer ? { 'font-weight': { value: integer, important } } : null;
|
2841
|
+
}
|
2842
|
+
|
2843
|
+
/**
|
2844
|
+
* Returns font size.
|
2845
|
+
*
|
2846
|
+
* @param value Value.
|
2847
|
+
* @param important Important.
|
2848
|
+
* @returns Property values
|
2849
|
+
*/
|
2850
|
+
public static getFontSize(
|
2851
|
+
value: string,
|
2852
|
+
important: boolean
|
2853
|
+
): {
|
2854
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2855
|
+
} {
|
2856
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2857
|
+
if (variable) {
|
2858
|
+
return { 'font-size': { value: variable, important } };
|
2859
|
+
}
|
2860
|
+
|
2861
|
+
const lowerValue = value.toLowerCase();
|
2862
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FONT_SIZE.includes(lowerValue)) {
|
2863
|
+
return { 'font-size': { value: lowerValue, important } };
|
2864
|
+
}
|
2865
|
+
const measurement = CSSStyleDeclarationValueParser.getMeasurement(value);
|
2866
|
+
return measurement ? { 'font-size': { value: measurement, important } } : null;
|
2867
|
+
}
|
2868
|
+
|
2869
|
+
/**
|
2870
|
+
* Returns line height.
|
2871
|
+
*
|
2872
|
+
* @param value Value.
|
2873
|
+
* @param important Important.
|
2874
|
+
* @returns Property values
|
2875
|
+
*/
|
2876
|
+
public static getLineHeight(
|
2877
|
+
value: string,
|
2878
|
+
important: boolean
|
2879
|
+
): {
|
2880
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2881
|
+
} {
|
2882
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2883
|
+
if (variable) {
|
2884
|
+
return { 'line-height': { value: variable, important } };
|
2885
|
+
}
|
2886
|
+
|
2887
|
+
const lowerValue = value.toLowerCase();
|
2888
|
+
if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === 'normal') {
|
2889
|
+
return { 'line-height': { value: lowerValue, important } };
|
2890
|
+
}
|
2891
|
+
const lineHeight =
|
2892
|
+
CSSStyleDeclarationValueParser.getFloat(value) ||
|
2893
|
+
CSSStyleDeclarationValueParser.getMeasurement(value);
|
2894
|
+
return lineHeight ? { 'line-height': { value: lineHeight, important } } : null;
|
2895
|
+
}
|
2896
|
+
|
2897
|
+
/**
|
2898
|
+
* Returns font family.
|
2899
|
+
*
|
2900
|
+
* @param value Value.
|
2901
|
+
* @param important Important.
|
2902
|
+
* @returns Property values
|
2903
|
+
*/
|
2904
|
+
public static getFontFamily(
|
2905
|
+
value: string,
|
2906
|
+
important: boolean
|
2907
|
+
): {
|
2908
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2909
|
+
} {
|
2910
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2911
|
+
if (variable) {
|
2912
|
+
return { 'font-family': { value: variable, important } };
|
2913
|
+
}
|
2914
|
+
|
2915
|
+
const globalValue = CSSStyleDeclarationValueParser.getGlobal(value);
|
2916
|
+
|
2917
|
+
if (globalValue) {
|
2918
|
+
return { 'font-family': { value: globalValue, important } };
|
2919
|
+
}
|
2920
|
+
|
2921
|
+
const parts = value.split(',');
|
2922
|
+
let parsedValue = '';
|
2923
|
+
let endWithApostroph = false;
|
2924
|
+
|
2925
|
+
for (let i = 0, max = parts.length; i < max; i++) {
|
2926
|
+
let trimmedPart = parts[i].trim().replace(/'/g, '"');
|
2927
|
+
|
2928
|
+
if (!trimmedPart) {
|
2929
|
+
return null;
|
2930
|
+
}
|
2931
|
+
|
2932
|
+
if (trimmedPart.includes(' ')) {
|
2933
|
+
const apostrophCount = (trimmedPart.match(/"/g) || []).length;
|
2934
|
+
if ((trimmedPart[0] !== '"' || i !== 0) && apostrophCount !== 2 && apostrophCount !== 0) {
|
2935
|
+
return null;
|
2936
|
+
}
|
2937
|
+
if (trimmedPart[0] === '"' && trimmedPart[trimmedPart.length - 1] !== '"') {
|
2938
|
+
endWithApostroph = true;
|
2939
|
+
} else if (trimmedPart[0] !== '"' && trimmedPart[trimmedPart.length - 1] !== '"') {
|
2940
|
+
trimmedPart = `"${trimmedPart}"`;
|
2941
|
+
}
|
2942
|
+
}
|
2943
|
+
|
2944
|
+
if (i > 0) {
|
2945
|
+
parsedValue += ', ';
|
2946
|
+
}
|
2947
|
+
|
2948
|
+
parsedValue += trimmedPart;
|
2949
|
+
}
|
2950
|
+
|
2951
|
+
if (endWithApostroph) {
|
2952
|
+
parsedValue += '"';
|
2953
|
+
}
|
2954
|
+
|
2955
|
+
if (!parsedValue) {
|
2956
|
+
return null;
|
2957
|
+
}
|
2958
|
+
|
2959
|
+
return {
|
2960
|
+
'font-family': {
|
2961
|
+
important,
|
2962
|
+
value: parsedValue
|
2963
|
+
}
|
2964
|
+
};
|
2965
|
+
}
|
2966
|
+
|
2967
|
+
/**
|
2968
|
+
* Returns font family.
|
2969
|
+
*
|
2970
|
+
* @param value Value.
|
2971
|
+
* @param important Important.
|
2972
|
+
* @returns Property values
|
2973
|
+
*/
|
2974
|
+
public static getTextTransform(
|
2975
|
+
value: string,
|
2976
|
+
important: boolean
|
2977
|
+
): {
|
2978
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
2979
|
+
} {
|
2980
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
2981
|
+
if (variable) {
|
2982
|
+
return { 'text-transform': { value: variable, important } };
|
2983
|
+
}
|
2984
|
+
|
2985
|
+
const lowerValue = value.toLowerCase();
|
2986
|
+
const parsedValue =
|
2987
|
+
CSSStyleDeclarationValueParser.getGlobal(lowerValue) ||
|
2988
|
+
(TEXT_TRANSFORM.includes(lowerValue) && lowerValue);
|
2989
|
+
if (parsedValue) {
|
2990
|
+
return {
|
2991
|
+
'text-transform': { value: parsedValue, important }
|
2992
|
+
};
|
2993
|
+
}
|
2994
|
+
return null;
|
2995
|
+
}
|
2996
|
+
|
2997
|
+
/**
|
2998
|
+
* Returns visibility.
|
2999
|
+
*
|
3000
|
+
* @param value Value.
|
3001
|
+
* @param important Important.
|
3002
|
+
* @returns Property
|
3003
|
+
*/
|
3004
|
+
public static getVisibility(
|
3005
|
+
value: string,
|
3006
|
+
important: boolean
|
3007
|
+
): {
|
3008
|
+
[key: string]: ICSSStyleDeclarationPropertyValue;
|
3009
|
+
} {
|
3010
|
+
const variable = CSSStyleDeclarationValueParser.getVariable(value);
|
3011
|
+
if (variable) {
|
3012
|
+
return { visibility: { value: variable, important } };
|
3013
|
+
}
|
3014
|
+
|
3015
|
+
const lowerValue = value.toLowerCase();
|
3016
|
+
const parsedValue =
|
3017
|
+
CSSStyleDeclarationValueParser.getGlobal(lowerValue) ||
|
3018
|
+
(VISIBILITY.includes(lowerValue) && lowerValue);
|
3019
|
+
if (parsedValue) {
|
3020
|
+
return {
|
3021
|
+
visibility: { value: parsedValue, important }
|
3022
|
+
};
|
3023
|
+
}
|
3024
|
+
return null;
|
3025
|
+
}
|
3026
|
+
}
|