happy-dom 6.0.4 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,2303 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const CSSStyleDeclarationValueParser_1 = __importDefault(require("./CSSStyleDeclarationValueParser"));
|
7
|
+
const RECT_REGEXP = /^rect\((.*)\)$/i;
|
8
|
+
const BORDER_STYLE = [
|
9
|
+
'none',
|
10
|
+
'hidden',
|
11
|
+
'dotted',
|
12
|
+
'dashed',
|
13
|
+
'solid',
|
14
|
+
'double',
|
15
|
+
'groove',
|
16
|
+
'ridge',
|
17
|
+
'inset',
|
18
|
+
'outset'
|
19
|
+
];
|
20
|
+
const BORDER_WIDTH = ['thin', 'medium', 'thick'];
|
21
|
+
const BORDER_COLLAPSE = ['separate', 'collapse'];
|
22
|
+
const BACKGROUND_REPEAT = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'];
|
23
|
+
const BACKGROUND_ORIGIN = ['border-box', 'padding-box', 'content-box'];
|
24
|
+
const BACKGROUND_CLIP = ['border-box', 'padding-box', 'content-box'];
|
25
|
+
const BACKGROUND_ATTACHMENT = ['scroll', 'fixed'];
|
26
|
+
const FLEX_BASIS = ['auto', 'fill', 'content'];
|
27
|
+
const CLEAR = ['none', 'left', 'right', 'both'];
|
28
|
+
const FLOAT = ['none', 'left', 'right', 'inline-start', 'inline-end'];
|
29
|
+
const SYSTEM_FONT = ['caption', 'icon', 'menu', 'message-box', 'small-caption', 'status-bar'];
|
30
|
+
const FONT_WEIGHT = ['normal', 'bold', 'bolder', 'lighter'];
|
31
|
+
const FONT_STYLE = ['normal', 'italic', 'oblique'];
|
32
|
+
const FONT_SIZE = [
|
33
|
+
'xx-small',
|
34
|
+
'x-small',
|
35
|
+
'small',
|
36
|
+
'medium',
|
37
|
+
'large',
|
38
|
+
'x-large',
|
39
|
+
'xx-large',
|
40
|
+
'xxx-large',
|
41
|
+
'smaller',
|
42
|
+
'larger'
|
43
|
+
];
|
44
|
+
const FONT_STRETCH = [
|
45
|
+
'ultra-condensed',
|
46
|
+
'extra-condensed',
|
47
|
+
'condensed',
|
48
|
+
'semi-condensed',
|
49
|
+
'normal',
|
50
|
+
'semi-expanded',
|
51
|
+
'expanded',
|
52
|
+
'extra-expanded',
|
53
|
+
'ultra-expanded'
|
54
|
+
];
|
55
|
+
const DISPLAY = [
|
56
|
+
/* Legacy values */
|
57
|
+
'block',
|
58
|
+
'inline',
|
59
|
+
'inline-block',
|
60
|
+
'flex',
|
61
|
+
'inline-flex',
|
62
|
+
'grid',
|
63
|
+
'inline-grid',
|
64
|
+
'flow-root',
|
65
|
+
/* Box generation */
|
66
|
+
'none',
|
67
|
+
'contents',
|
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
|
+
/* Other values */
|
78
|
+
'table',
|
79
|
+
'table-row',
|
80
|
+
'list-item'
|
81
|
+
];
|
82
|
+
const BORDER_IMAGE_REPEAT = ['stretch', 'repeat', 'round', 'space'];
|
83
|
+
const TEXT_TRANSFORM = [
|
84
|
+
'capitalize',
|
85
|
+
'uppercase',
|
86
|
+
'lowercase',
|
87
|
+
'none',
|
88
|
+
'full-width',
|
89
|
+
'full-size-kana'
|
90
|
+
];
|
91
|
+
const VISIBILITY = ['visible', 'hidden', 'collapse'];
|
92
|
+
/**
|
93
|
+
* Computed style property parser.
|
94
|
+
*/
|
95
|
+
class CSSStyleDeclarationPropertySetParser {
|
96
|
+
/**
|
97
|
+
* Returns border collapse.
|
98
|
+
*
|
99
|
+
* @param value Value.
|
100
|
+
* @param important Important.
|
101
|
+
* @returns Property values
|
102
|
+
*/
|
103
|
+
static getBorderCollapse(value, important) {
|
104
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
105
|
+
if (variable) {
|
106
|
+
return { 'border-collapse': { value: variable, important } };
|
107
|
+
}
|
108
|
+
const lowerValue = value.toLowerCase();
|
109
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) ||
|
110
|
+
BORDER_COLLAPSE.includes(lowerValue)) {
|
111
|
+
return { 'border-collapse': { value: lowerValue, important } };
|
112
|
+
}
|
113
|
+
return null;
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* Returns display.
|
117
|
+
*
|
118
|
+
* @param value Value.
|
119
|
+
* @param important Important.
|
120
|
+
* @returns Property values
|
121
|
+
*/
|
122
|
+
static getDisplay(value, important) {
|
123
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
124
|
+
if (variable) {
|
125
|
+
return { display: { value: variable, important } };
|
126
|
+
}
|
127
|
+
const lowerValue = value.toLowerCase();
|
128
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || DISPLAY.includes(lowerValue)) {
|
129
|
+
return { display: { value: lowerValue, important } };
|
130
|
+
}
|
131
|
+
return null;
|
132
|
+
}
|
133
|
+
/**
|
134
|
+
* Returns direction.
|
135
|
+
*
|
136
|
+
* @param value Value.
|
137
|
+
* @param important Important.
|
138
|
+
* @returns Property values
|
139
|
+
*/
|
140
|
+
static getDirection(value, important) {
|
141
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
142
|
+
if (variable) {
|
143
|
+
return { direction: { value: variable, important } };
|
144
|
+
}
|
145
|
+
const lowerValue = value.toLowerCase();
|
146
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) ||
|
147
|
+
lowerValue === 'ltr' ||
|
148
|
+
lowerValue === 'rtl') {
|
149
|
+
return { direction: { value: lowerValue, important } };
|
150
|
+
}
|
151
|
+
return null;
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
* Returns width.
|
155
|
+
*
|
156
|
+
* @param value Value.
|
157
|
+
* @param important Important.
|
158
|
+
* @returns Property values
|
159
|
+
*/
|
160
|
+
static getWidth(value, important) {
|
161
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
162
|
+
if (variable) {
|
163
|
+
return { width: { value: variable, important } };
|
164
|
+
}
|
165
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
166
|
+
CSSStyleDeclarationValueParser_1.default.getContentMeasurement(value);
|
167
|
+
return parsedValue ? { width: { value: parsedValue, important } } : null;
|
168
|
+
}
|
169
|
+
/**
|
170
|
+
* Returns top.
|
171
|
+
*
|
172
|
+
* @param value Value.
|
173
|
+
* @param important Important.
|
174
|
+
* @returns Property values
|
175
|
+
*/
|
176
|
+
static getTop(value, important) {
|
177
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
178
|
+
if (variable) {
|
179
|
+
return { top: { value: variable, important } };
|
180
|
+
}
|
181
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
182
|
+
CSSStyleDeclarationValueParser_1.default.getContentMeasurement(value);
|
183
|
+
return parsedValue ? { top: { value: parsedValue, important } } : null;
|
184
|
+
}
|
185
|
+
/**
|
186
|
+
* Returns top.
|
187
|
+
*
|
188
|
+
* @param value Value.
|
189
|
+
* @param important Important.
|
190
|
+
* @returns Property values
|
191
|
+
*/
|
192
|
+
static getRight(value, important) {
|
193
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
194
|
+
if (variable) {
|
195
|
+
return { right: { value: variable, important } };
|
196
|
+
}
|
197
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
198
|
+
CSSStyleDeclarationValueParser_1.default.getContentMeasurement(value);
|
199
|
+
return parsedValue ? { right: { value: parsedValue, important } } : null;
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* Returns top.
|
203
|
+
*
|
204
|
+
* @param value Value.
|
205
|
+
* @param important Important.
|
206
|
+
* @returns Property values
|
207
|
+
*/
|
208
|
+
static getBottom(value, important) {
|
209
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
210
|
+
if (variable) {
|
211
|
+
return { bottom: { value: variable, important } };
|
212
|
+
}
|
213
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
214
|
+
CSSStyleDeclarationValueParser_1.default.getContentMeasurement(value);
|
215
|
+
return parsedValue ? { bottom: { value: parsedValue, important } } : null;
|
216
|
+
}
|
217
|
+
/**
|
218
|
+
* Returns top.
|
219
|
+
*
|
220
|
+
* @param value Value.
|
221
|
+
* @param important Important.
|
222
|
+
* @returns Property values
|
223
|
+
*/
|
224
|
+
static getLeft(value, important) {
|
225
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
226
|
+
if (variable) {
|
227
|
+
return { left: { value: variable, important } };
|
228
|
+
}
|
229
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
230
|
+
CSSStyleDeclarationValueParser_1.default.getContentMeasurement(value);
|
231
|
+
return parsedValue ? { left: { value: parsedValue, important } } : null;
|
232
|
+
}
|
233
|
+
/**
|
234
|
+
* Returns clear.
|
235
|
+
*
|
236
|
+
* @param value Value.
|
237
|
+
* @param important Important.
|
238
|
+
* @returns Property values
|
239
|
+
*/
|
240
|
+
static getClear(value, important) {
|
241
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
242
|
+
if (variable) {
|
243
|
+
return { clear: { value: variable, important } };
|
244
|
+
}
|
245
|
+
const lowerValue = value.toLowerCase();
|
246
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || CLEAR.includes(lowerValue)) {
|
247
|
+
return { clear: { value: lowerValue, important } };
|
248
|
+
}
|
249
|
+
return null;
|
250
|
+
}
|
251
|
+
/**
|
252
|
+
* Returns clip
|
253
|
+
*
|
254
|
+
* Based on:
|
255
|
+
* https://github.com/jsdom/cssstyle/blob/master/lib/properties/clip.js
|
256
|
+
*
|
257
|
+
* @param value Value.
|
258
|
+
* @param important Important.
|
259
|
+
* @returns Property values
|
260
|
+
*/
|
261
|
+
static getClip(value, important) {
|
262
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
263
|
+
if (variable) {
|
264
|
+
return { clip: { value: variable, important } };
|
265
|
+
}
|
266
|
+
const lowerValue = value.toLowerCase();
|
267
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || lowerValue === 'auto') {
|
268
|
+
return { clip: { value: lowerValue, important } };
|
269
|
+
}
|
270
|
+
const matches = lowerValue.match(RECT_REGEXP);
|
271
|
+
if (!matches) {
|
272
|
+
return null;
|
273
|
+
}
|
274
|
+
const parts = matches[1].split(/\s*,\s*/);
|
275
|
+
if (parts.length !== 4) {
|
276
|
+
return null;
|
277
|
+
}
|
278
|
+
for (const part of parts) {
|
279
|
+
if (!CSSStyleDeclarationValueParser_1.default.getMeasurement(part)) {
|
280
|
+
return null;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
return { clip: { value, important } };
|
284
|
+
}
|
285
|
+
/**
|
286
|
+
* Returns float.
|
287
|
+
*
|
288
|
+
* @param value Value.
|
289
|
+
* @param important Important.
|
290
|
+
* @returns Property values
|
291
|
+
*/
|
292
|
+
static getFloat(value, important) {
|
293
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
294
|
+
if (variable) {
|
295
|
+
return { float: { value: variable, important } };
|
296
|
+
}
|
297
|
+
const lowerValue = value.toLowerCase();
|
298
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || FLOAT.includes(lowerValue)) {
|
299
|
+
return { float: { value: lowerValue, important } };
|
300
|
+
}
|
301
|
+
return null;
|
302
|
+
}
|
303
|
+
/**
|
304
|
+
* Returns float.
|
305
|
+
*
|
306
|
+
* @param value Value.
|
307
|
+
* @param important Important.
|
308
|
+
* @returns Property values
|
309
|
+
*/
|
310
|
+
static getCSSFloat(value, important) {
|
311
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
312
|
+
if (variable) {
|
313
|
+
return { 'css-float': { value: variable, important } };
|
314
|
+
}
|
315
|
+
const float = this.getFloat(value, important);
|
316
|
+
return float ? { 'css-float': float['float'] } : null;
|
317
|
+
}
|
318
|
+
/**
|
319
|
+
* Returns border.
|
320
|
+
*
|
321
|
+
* @param value Value.
|
322
|
+
* @param important Important.
|
323
|
+
* @returns Property values.
|
324
|
+
*/
|
325
|
+
static getBorder(value, important) {
|
326
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
327
|
+
if (variable) {
|
328
|
+
return { border: { value: variable, important } };
|
329
|
+
}
|
330
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
331
|
+
if (globalValue) {
|
332
|
+
return {
|
333
|
+
...this.getBorderWidth(globalValue, important),
|
334
|
+
...this.getBorderStyle(globalValue, important),
|
335
|
+
...this.getBorderColor(globalValue, important),
|
336
|
+
...this.getBorderImage(globalValue, important)
|
337
|
+
};
|
338
|
+
}
|
339
|
+
const properties = {
|
340
|
+
...this.getBorderWidth('initial', important),
|
341
|
+
...this.getBorderStyle('initial', important),
|
342
|
+
...this.getBorderColor('initial', important),
|
343
|
+
...this.getBorderImage('initial', important)
|
344
|
+
};
|
345
|
+
const parts = value.replace(/ *, */g, ',').split(/ +/);
|
346
|
+
for (const part of parts) {
|
347
|
+
const width = this.getBorderWidth(part, important);
|
348
|
+
const style = this.getBorderStyle(part, important);
|
349
|
+
const color = this.getBorderColor(part, important);
|
350
|
+
if (width === null && style === null && color === null) {
|
351
|
+
return null;
|
352
|
+
}
|
353
|
+
Object.assign(properties, width, style, color);
|
354
|
+
}
|
355
|
+
return properties;
|
356
|
+
}
|
357
|
+
/**
|
358
|
+
* Returns border width.
|
359
|
+
*
|
360
|
+
* @param value Value.
|
361
|
+
* @param important Important.
|
362
|
+
* @returns Property values
|
363
|
+
*/
|
364
|
+
static getBorderWidth(value, important) {
|
365
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
366
|
+
if (variable) {
|
367
|
+
return { 'border-width': { value: variable, important } };
|
368
|
+
}
|
369
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
370
|
+
if (globalValue) {
|
371
|
+
return {
|
372
|
+
...this.getBorderTopWidth(globalValue, important),
|
373
|
+
...this.getBorderRightWidth(globalValue, important),
|
374
|
+
...this.getBorderBottomWidth(globalValue, important),
|
375
|
+
...this.getBorderLeftWidth(globalValue, important)
|
376
|
+
};
|
377
|
+
}
|
378
|
+
const parts = value.split(/ +/);
|
379
|
+
const top = this.getBorderTopWidth(parts[0], important);
|
380
|
+
const right = this.getBorderRightWidth(parts[1] || parts[0], important);
|
381
|
+
const bottom = this.getBorderBottomWidth(parts[2] || parts[0], important);
|
382
|
+
const left = this.getBorderLeftWidth(parts[3] || parts[1] || parts[0], important);
|
383
|
+
if (!top || !right || !bottom || !left) {
|
384
|
+
return null;
|
385
|
+
}
|
386
|
+
return {
|
387
|
+
...top,
|
388
|
+
...right,
|
389
|
+
...bottom,
|
390
|
+
...left
|
391
|
+
};
|
392
|
+
}
|
393
|
+
/**
|
394
|
+
* Returns border style.
|
395
|
+
*
|
396
|
+
* @param value Value.
|
397
|
+
* @param important Important.
|
398
|
+
* @returns Property values
|
399
|
+
*/
|
400
|
+
static getBorderStyle(value, important) {
|
401
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
402
|
+
if (variable) {
|
403
|
+
return { 'border-style': { value: variable, important } };
|
404
|
+
}
|
405
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
406
|
+
if (globalValue) {
|
407
|
+
return {
|
408
|
+
...this.getBorderTopStyle(globalValue, important),
|
409
|
+
...this.getBorderRightStyle(globalValue, important),
|
410
|
+
...this.getBorderBottomStyle(globalValue, important),
|
411
|
+
...this.getBorderLeftStyle(globalValue, important)
|
412
|
+
};
|
413
|
+
}
|
414
|
+
const parts = value.split(/ +/);
|
415
|
+
const top = this.getBorderTopStyle(parts[0], important);
|
416
|
+
const right = this.getBorderRightStyle(parts[1] || parts[0], important);
|
417
|
+
const bottom = this.getBorderBottomStyle(parts[2] || parts[0], important);
|
418
|
+
const left = this.getBorderLeftStyle(parts[3] || parts[1] || parts[0], important);
|
419
|
+
if (!top || !right || !bottom || !left) {
|
420
|
+
return null;
|
421
|
+
}
|
422
|
+
return {
|
423
|
+
...top,
|
424
|
+
...right,
|
425
|
+
...bottom,
|
426
|
+
...left
|
427
|
+
};
|
428
|
+
}
|
429
|
+
/**
|
430
|
+
* Returns border color.
|
431
|
+
*
|
432
|
+
* @param value Value.
|
433
|
+
* @param important Important.
|
434
|
+
* @returns Property values
|
435
|
+
*/
|
436
|
+
static getBorderColor(value, important) {
|
437
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
438
|
+
if (variable) {
|
439
|
+
return { 'border-color': { value: variable, important } };
|
440
|
+
}
|
441
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
442
|
+
if (globalValue) {
|
443
|
+
return {
|
444
|
+
...this.getBorderTopColor(globalValue, important),
|
445
|
+
...this.getBorderRightColor(globalValue, important),
|
446
|
+
...this.getBorderBottomColor(globalValue, important),
|
447
|
+
...this.getBorderLeftColor(globalValue, important)
|
448
|
+
};
|
449
|
+
}
|
450
|
+
const parts = value.split(/ +/);
|
451
|
+
const top = this.getBorderTopColor(parts[0], important);
|
452
|
+
const right = this.getBorderRightColor(parts[1] || parts[0], important);
|
453
|
+
const bottom = this.getBorderBottomColor(parts[2] || parts[0], important);
|
454
|
+
const left = this.getBorderLeftColor(parts[3] || parts[1] || parts[0], important);
|
455
|
+
if (!top || !right || !bottom || !left) {
|
456
|
+
return null;
|
457
|
+
}
|
458
|
+
return {
|
459
|
+
...top,
|
460
|
+
...right,
|
461
|
+
...bottom,
|
462
|
+
...left
|
463
|
+
};
|
464
|
+
}
|
465
|
+
/**
|
466
|
+
* Returns border image.
|
467
|
+
*
|
468
|
+
* @param value Value.
|
469
|
+
* @param important Important.
|
470
|
+
* @returns Property values
|
471
|
+
*/
|
472
|
+
static getBorderImage(value, important) {
|
473
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
474
|
+
if (variable) {
|
475
|
+
return { 'border-image': { value: variable, important } };
|
476
|
+
}
|
477
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
478
|
+
if (globalValue) {
|
479
|
+
return {
|
480
|
+
...this.getBorderImageSource(globalValue, important),
|
481
|
+
...this.getBorderImageSlice(globalValue, important),
|
482
|
+
...this.getBorderImageWidth(globalValue, important),
|
483
|
+
...this.getBorderImageOutset(globalValue, important),
|
484
|
+
...this.getBorderImageRepeat(globalValue, important)
|
485
|
+
};
|
486
|
+
}
|
487
|
+
let parsedValue = value.replace(/[ ]*\/[ ]*/g, '/');
|
488
|
+
const sourceMatch = parsedValue.match(/ *([a-zA-Z-]+\([^)]*\)) */);
|
489
|
+
if (sourceMatch) {
|
490
|
+
parsedValue = parsedValue.replace(sourceMatch[0], '');
|
491
|
+
}
|
492
|
+
const parts = parsedValue.split(/ +/);
|
493
|
+
if (sourceMatch) {
|
494
|
+
parts.push(sourceMatch[1]);
|
495
|
+
}
|
496
|
+
const properties = {
|
497
|
+
...this.getBorderImageSource('none', important),
|
498
|
+
...this.getBorderImageSlice('100%', important),
|
499
|
+
...this.getBorderImageWidth('1', important),
|
500
|
+
...this.getBorderImageOutset('0', important),
|
501
|
+
...this.getBorderImageRepeat('stretch', important)
|
502
|
+
};
|
503
|
+
for (let i = 0, max = parts.length; i < max; i++) {
|
504
|
+
const part = parts[i];
|
505
|
+
const previousPart = i > 0 ? parts[i - 1] : '';
|
506
|
+
if (!part.startsWith('url') && part.includes('/')) {
|
507
|
+
const [slice, width, outset] = part.split('/');
|
508
|
+
const borderImageSlice = this.getBorderImageSlice(`${previousPart} ${slice}`, important) ||
|
509
|
+
this.getBorderImageSlice(slice, important);
|
510
|
+
const borderImageWidth = this.getBorderImageWidth(width, important);
|
511
|
+
const borderImageOutset = outset && this.getBorderImageOutset(outset, important);
|
512
|
+
if (!borderImageSlice || !borderImageWidth || borderImageOutset === null) {
|
513
|
+
return null;
|
514
|
+
}
|
515
|
+
Object.assign(properties, borderImageSlice, borderImageWidth, borderImageOutset);
|
516
|
+
}
|
517
|
+
else {
|
518
|
+
const slice = this.getBorderImageSlice(`${previousPart} ${part}`, important) ||
|
519
|
+
this.getBorderImageSlice(part, important);
|
520
|
+
const source = this.getBorderImageSource(part, important);
|
521
|
+
const repeat = this.getBorderImageRepeat(part, important);
|
522
|
+
if (!slice && !source && !repeat) {
|
523
|
+
return null;
|
524
|
+
}
|
525
|
+
Object.assign(properties, slice, source, repeat);
|
526
|
+
}
|
527
|
+
}
|
528
|
+
return properties;
|
529
|
+
}
|
530
|
+
/**
|
531
|
+
* Returns border source.
|
532
|
+
*
|
533
|
+
* @param value Value.
|
534
|
+
* @param important Important.
|
535
|
+
* @returns Property values
|
536
|
+
*/
|
537
|
+
static getBorderImageSource(value, important) {
|
538
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
539
|
+
if (variable) {
|
540
|
+
return { 'border-image-source': { value: variable, important } };
|
541
|
+
}
|
542
|
+
const lowerValue = value.toLowerCase();
|
543
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || lowerValue === 'none') {
|
544
|
+
return {
|
545
|
+
'border-image-source': {
|
546
|
+
important,
|
547
|
+
value: lowerValue
|
548
|
+
}
|
549
|
+
};
|
550
|
+
}
|
551
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getURL(value) ||
|
552
|
+
CSSStyleDeclarationValueParser_1.default.getGradient(value);
|
553
|
+
if (!parsedValue) {
|
554
|
+
return null;
|
555
|
+
}
|
556
|
+
return {
|
557
|
+
'border-image-source': {
|
558
|
+
important,
|
559
|
+
value: parsedValue
|
560
|
+
}
|
561
|
+
};
|
562
|
+
}
|
563
|
+
/**
|
564
|
+
* Returns border slice.
|
565
|
+
*
|
566
|
+
* @param value Value.
|
567
|
+
* @param important Important.
|
568
|
+
* @returns Property values
|
569
|
+
*/
|
570
|
+
static getBorderImageSlice(value, important) {
|
571
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
572
|
+
if (variable) {
|
573
|
+
return { 'border-image-slice': { value: variable, important } };
|
574
|
+
}
|
575
|
+
const lowerValue = value.toLowerCase();
|
576
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)) {
|
577
|
+
return {
|
578
|
+
'border-image-slice': {
|
579
|
+
important,
|
580
|
+
value: lowerValue
|
581
|
+
}
|
582
|
+
};
|
583
|
+
}
|
584
|
+
if (lowerValue !== lowerValue.trim()) {
|
585
|
+
return null;
|
586
|
+
}
|
587
|
+
const regexp = /(fill)|(calc\([^^)]+\))|([0-9]+%)|([0-9]+)/g;
|
588
|
+
const values = [];
|
589
|
+
let match;
|
590
|
+
while ((match = regexp.exec(lowerValue))) {
|
591
|
+
const previousCharacter = lowerValue[match.index - 1];
|
592
|
+
const nextCharacter = lowerValue[match.index + match[0].length];
|
593
|
+
if ((previousCharacter && previousCharacter !== ' ') ||
|
594
|
+
(nextCharacter && nextCharacter !== ' ')) {
|
595
|
+
return null;
|
596
|
+
}
|
597
|
+
const fill = match[1] && 'fill';
|
598
|
+
const calc = match[2] && CSSStyleDeclarationValueParser_1.default.getCalc(match[2]);
|
599
|
+
const percentage = match[3] && CSSStyleDeclarationValueParser_1.default.getPercentage(match[3]);
|
600
|
+
const integer = match[4] && CSSStyleDeclarationValueParser_1.default.getInteger(match[4]);
|
601
|
+
if (!fill && !calc && !percentage && !integer) {
|
602
|
+
return null;
|
603
|
+
}
|
604
|
+
values.push(fill || calc || percentage || integer);
|
605
|
+
}
|
606
|
+
if (!values.length || values.length > 4) {
|
607
|
+
return null;
|
608
|
+
}
|
609
|
+
return {
|
610
|
+
'border-image-slice': {
|
611
|
+
important,
|
612
|
+
value: values.join(' ')
|
613
|
+
}
|
614
|
+
};
|
615
|
+
}
|
616
|
+
/**
|
617
|
+
* Returns border width.
|
618
|
+
*
|
619
|
+
* @param value Value.
|
620
|
+
* @param important Important.
|
621
|
+
* @returns Property values
|
622
|
+
*/
|
623
|
+
static getBorderImageWidth(value, important) {
|
624
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
625
|
+
if (variable) {
|
626
|
+
return { 'border-image-width': { value: variable, important } };
|
627
|
+
}
|
628
|
+
const lowerValue = value.toLowerCase();
|
629
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)) {
|
630
|
+
return {
|
631
|
+
'border-image-width': {
|
632
|
+
important,
|
633
|
+
value: lowerValue
|
634
|
+
}
|
635
|
+
};
|
636
|
+
}
|
637
|
+
const parts = lowerValue.split(/ +/);
|
638
|
+
if (parts.length > 4) {
|
639
|
+
return null;
|
640
|
+
}
|
641
|
+
for (const part of parts) {
|
642
|
+
if (!CSSStyleDeclarationValueParser_1.default.getInteger(part) &&
|
643
|
+
!CSSStyleDeclarationValueParser_1.default.getAutoMeasurement(part)) {
|
644
|
+
return null;
|
645
|
+
}
|
646
|
+
}
|
647
|
+
return {
|
648
|
+
'border-image-width': {
|
649
|
+
important,
|
650
|
+
value
|
651
|
+
}
|
652
|
+
};
|
653
|
+
}
|
654
|
+
/**
|
655
|
+
* Returns border outset.
|
656
|
+
*
|
657
|
+
* @param value Value.
|
658
|
+
* @param important Important.
|
659
|
+
* @returns Property values
|
660
|
+
*/
|
661
|
+
static getBorderImageOutset(value, important) {
|
662
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
663
|
+
if (variable) {
|
664
|
+
return { 'border-image-outset': { value: variable, important } };
|
665
|
+
}
|
666
|
+
const lowerValue = value.toLowerCase();
|
667
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)) {
|
668
|
+
return {
|
669
|
+
'border-image-outset': {
|
670
|
+
important,
|
671
|
+
value: lowerValue
|
672
|
+
}
|
673
|
+
};
|
674
|
+
}
|
675
|
+
const parts = value.split(/ +/);
|
676
|
+
if (parts.length > 4) {
|
677
|
+
return null;
|
678
|
+
}
|
679
|
+
for (const part of parts) {
|
680
|
+
if (!CSSStyleDeclarationValueParser_1.default.getLength(part) &&
|
681
|
+
!CSSStyleDeclarationValueParser_1.default.getFloat(part)) {
|
682
|
+
return null;
|
683
|
+
}
|
684
|
+
}
|
685
|
+
return {
|
686
|
+
'border-image-outset': {
|
687
|
+
important,
|
688
|
+
value
|
689
|
+
}
|
690
|
+
};
|
691
|
+
}
|
692
|
+
/**
|
693
|
+
* Returns border repeat.
|
694
|
+
*
|
695
|
+
* @param value Value.
|
696
|
+
* @param important Important.
|
697
|
+
* @returns Property values
|
698
|
+
*/
|
699
|
+
static getBorderImageRepeat(value, important) {
|
700
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
701
|
+
if (variable) {
|
702
|
+
return { 'border-image-repeat': { value: variable, important } };
|
703
|
+
}
|
704
|
+
const lowerValue = value.toLowerCase();
|
705
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)) {
|
706
|
+
return {
|
707
|
+
'border-image-repeat': {
|
708
|
+
important,
|
709
|
+
value: lowerValue
|
710
|
+
}
|
711
|
+
};
|
712
|
+
}
|
713
|
+
const parts = lowerValue.split(/ +/);
|
714
|
+
if (parts.length > 2) {
|
715
|
+
return null;
|
716
|
+
}
|
717
|
+
for (const part of parts) {
|
718
|
+
if (!BORDER_IMAGE_REPEAT.includes(part)) {
|
719
|
+
return null;
|
720
|
+
}
|
721
|
+
}
|
722
|
+
return {
|
723
|
+
'border-image-repeat': {
|
724
|
+
important,
|
725
|
+
value
|
726
|
+
}
|
727
|
+
};
|
728
|
+
}
|
729
|
+
/**
|
730
|
+
* Returns border width.
|
731
|
+
*
|
732
|
+
* @param value Value.
|
733
|
+
* @param important Important.
|
734
|
+
* @returns Property values
|
735
|
+
*/
|
736
|
+
static getBorderTopWidth(value, important) {
|
737
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
738
|
+
if (variable) {
|
739
|
+
return { 'border-top-width': { value: variable, important } };
|
740
|
+
}
|
741
|
+
const lowerValue = value.toLowerCase();
|
742
|
+
const parsedValue = BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)
|
743
|
+
? lowerValue
|
744
|
+
: CSSStyleDeclarationValueParser_1.default.getLength(value);
|
745
|
+
if (parsedValue) {
|
746
|
+
return {
|
747
|
+
'border-top-width': { value: parsedValue, important }
|
748
|
+
};
|
749
|
+
}
|
750
|
+
return null;
|
751
|
+
}
|
752
|
+
/**
|
753
|
+
* Returns border width.
|
754
|
+
*
|
755
|
+
* @param value Value.
|
756
|
+
* @param important Important.
|
757
|
+
* @returns Property values
|
758
|
+
*/
|
759
|
+
static getBorderRightWidth(value, important) {
|
760
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
761
|
+
if (variable) {
|
762
|
+
return { 'border-right-width': { value: variable, important } };
|
763
|
+
}
|
764
|
+
const lowerValue = value.toLowerCase();
|
765
|
+
const parsedValue = BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)
|
766
|
+
? lowerValue
|
767
|
+
: CSSStyleDeclarationValueParser_1.default.getLength(value);
|
768
|
+
if (parsedValue) {
|
769
|
+
return {
|
770
|
+
'border-right-width': { value: parsedValue, important }
|
771
|
+
};
|
772
|
+
}
|
773
|
+
return null;
|
774
|
+
}
|
775
|
+
/**
|
776
|
+
* Returns border width.
|
777
|
+
*
|
778
|
+
* @param value Value.
|
779
|
+
* @param important Important.
|
780
|
+
* @returns Property values
|
781
|
+
*/
|
782
|
+
static getBorderBottomWidth(value, important) {
|
783
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
784
|
+
if (variable) {
|
785
|
+
return { 'border-bottom-width': { value: variable, important } };
|
786
|
+
}
|
787
|
+
const lowerValue = value.toLowerCase();
|
788
|
+
const parsedValue = BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)
|
789
|
+
? lowerValue
|
790
|
+
: CSSStyleDeclarationValueParser_1.default.getLength(value);
|
791
|
+
if (parsedValue) {
|
792
|
+
return {
|
793
|
+
'border-bottom-width': { value: parsedValue, important }
|
794
|
+
};
|
795
|
+
}
|
796
|
+
return null;
|
797
|
+
}
|
798
|
+
/**
|
799
|
+
* Returns border width.
|
800
|
+
*
|
801
|
+
* @param value Value.
|
802
|
+
* @param important Important.
|
803
|
+
* @returns Property values
|
804
|
+
*/
|
805
|
+
static getBorderLeftWidth(value, important) {
|
806
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
807
|
+
if (variable) {
|
808
|
+
return { 'border-left-width': { value: variable, important } };
|
809
|
+
}
|
810
|
+
const lowerValue = value.toLowerCase();
|
811
|
+
const parsedValue = BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)
|
812
|
+
? lowerValue
|
813
|
+
: CSSStyleDeclarationValueParser_1.default.getLength(value);
|
814
|
+
if (parsedValue) {
|
815
|
+
return {
|
816
|
+
'border-left-width': { value: parsedValue, important }
|
817
|
+
};
|
818
|
+
}
|
819
|
+
return null;
|
820
|
+
}
|
821
|
+
/**
|
822
|
+
* Returns border style.
|
823
|
+
*
|
824
|
+
* @param value Value.
|
825
|
+
* @param important Important.
|
826
|
+
* @returns Property values
|
827
|
+
*/
|
828
|
+
static getBorderTopStyle(value, important) {
|
829
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
830
|
+
if (variable) {
|
831
|
+
return { 'border-top-style': { value: variable, important } };
|
832
|
+
}
|
833
|
+
const lowerValue = value.toLowerCase();
|
834
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) {
|
835
|
+
return {
|
836
|
+
'border-top-style': { value: lowerValue, important }
|
837
|
+
};
|
838
|
+
}
|
839
|
+
return null;
|
840
|
+
}
|
841
|
+
/**
|
842
|
+
* Returns border style.
|
843
|
+
*
|
844
|
+
* @param value Value.
|
845
|
+
* @param important Important.
|
846
|
+
* @returns Property values
|
847
|
+
*/
|
848
|
+
static getBorderRightStyle(value, important) {
|
849
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
850
|
+
if (variable) {
|
851
|
+
return { 'border-right-style': { value: variable, important } };
|
852
|
+
}
|
853
|
+
const lowerValue = value.toLowerCase();
|
854
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) {
|
855
|
+
return {
|
856
|
+
'border-right-style': { value: lowerValue, important }
|
857
|
+
};
|
858
|
+
}
|
859
|
+
return null;
|
860
|
+
}
|
861
|
+
/**
|
862
|
+
* Returns border style.
|
863
|
+
*
|
864
|
+
* @param value Value.
|
865
|
+
* @param important Important.
|
866
|
+
* @returns Property values
|
867
|
+
*/
|
868
|
+
static getBorderBottomStyle(value, important) {
|
869
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
870
|
+
if (variable) {
|
871
|
+
return { 'border-bottom-style': { value: variable, important } };
|
872
|
+
}
|
873
|
+
const lowerValue = value.toLowerCase();
|
874
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) {
|
875
|
+
return {
|
876
|
+
'border-bottom-style': { value: lowerValue, important }
|
877
|
+
};
|
878
|
+
}
|
879
|
+
return null;
|
880
|
+
}
|
881
|
+
/**
|
882
|
+
* Returns border style.
|
883
|
+
*
|
884
|
+
* @param value Value.
|
885
|
+
* @param important Important.
|
886
|
+
* @returns Property values
|
887
|
+
*/
|
888
|
+
static getBorderLeftStyle(value, important) {
|
889
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
890
|
+
if (variable) {
|
891
|
+
return { 'border-left-style': { value: variable, important } };
|
892
|
+
}
|
893
|
+
const lowerValue = value.toLowerCase();
|
894
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) {
|
895
|
+
return {
|
896
|
+
'border-left-style': { value: lowerValue, important }
|
897
|
+
};
|
898
|
+
}
|
899
|
+
return null;
|
900
|
+
}
|
901
|
+
/**
|
902
|
+
* Returns border color.
|
903
|
+
*
|
904
|
+
* @param value Value.
|
905
|
+
* @param important Important.
|
906
|
+
* @returns Property values
|
907
|
+
*/
|
908
|
+
static getBorderTopColor(value, important) {
|
909
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
910
|
+
if (variable) {
|
911
|
+
return { 'border-top-color': { value: variable, important } };
|
912
|
+
}
|
913
|
+
const color = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
914
|
+
CSSStyleDeclarationValueParser_1.default.getColor(value);
|
915
|
+
return color
|
916
|
+
? {
|
917
|
+
'border-top-color': { value: color, important }
|
918
|
+
}
|
919
|
+
: null;
|
920
|
+
}
|
921
|
+
/**
|
922
|
+
* Returns border color.
|
923
|
+
*
|
924
|
+
* @param value Value.
|
925
|
+
* @param important Important.
|
926
|
+
* @returns Property values
|
927
|
+
*/
|
928
|
+
static getBorderRightColor(value, important) {
|
929
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
930
|
+
if (variable) {
|
931
|
+
return { 'border-right-color': { value: variable, important } };
|
932
|
+
}
|
933
|
+
const color = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
934
|
+
CSSStyleDeclarationValueParser_1.default.getColor(value);
|
935
|
+
return color
|
936
|
+
? {
|
937
|
+
'border-right-color': { value: color, important }
|
938
|
+
}
|
939
|
+
: null;
|
940
|
+
}
|
941
|
+
/**
|
942
|
+
* Returns border color.
|
943
|
+
*
|
944
|
+
* @param value Value.
|
945
|
+
* @param important Important.
|
946
|
+
* @returns Property values
|
947
|
+
*/
|
948
|
+
static getBorderBottomColor(value, important) {
|
949
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
950
|
+
if (variable) {
|
951
|
+
return { 'border-bottom-color': { value: variable, important } };
|
952
|
+
}
|
953
|
+
const color = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
954
|
+
CSSStyleDeclarationValueParser_1.default.getColor(value);
|
955
|
+
return color
|
956
|
+
? {
|
957
|
+
'border-bottom-color': { value: color, important }
|
958
|
+
}
|
959
|
+
: null;
|
960
|
+
}
|
961
|
+
/**
|
962
|
+
* Returns border color.
|
963
|
+
*
|
964
|
+
* @param value Value.
|
965
|
+
* @param important Important.
|
966
|
+
* @returns Property values
|
967
|
+
*/
|
968
|
+
static getBorderLeftColor(value, important) {
|
969
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
970
|
+
if (variable) {
|
971
|
+
return { 'border-left-color': { value: variable, important } };
|
972
|
+
}
|
973
|
+
const color = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
974
|
+
CSSStyleDeclarationValueParser_1.default.getColor(value);
|
975
|
+
return color
|
976
|
+
? {
|
977
|
+
'border-left-color': { value: color, important }
|
978
|
+
}
|
979
|
+
: null;
|
980
|
+
}
|
981
|
+
/**
|
982
|
+
* Returns border radius.
|
983
|
+
*
|
984
|
+
* @param value Value.
|
985
|
+
* @param important Important.
|
986
|
+
* @returns Property values.
|
987
|
+
*/
|
988
|
+
static getBorderRadius(value, important) {
|
989
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
990
|
+
if (variable) {
|
991
|
+
return { 'border-radius': { value: variable, important } };
|
992
|
+
}
|
993
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
994
|
+
if (globalValue) {
|
995
|
+
return {
|
996
|
+
...this.getBorderTopLeftRadius(globalValue, important),
|
997
|
+
...this.getBorderTopRightRadius(globalValue, important),
|
998
|
+
...this.getBorderBottomRightRadius(globalValue, important),
|
999
|
+
...this.getBorderBottomLeftRadius(globalValue, important)
|
1000
|
+
};
|
1001
|
+
}
|
1002
|
+
const parts = value.split(/ +/);
|
1003
|
+
const topLeft = this.getBorderTopLeftRadius(parts[0], important);
|
1004
|
+
const topRight = this.getBorderTopRightRadius(parts[1] || parts[0], important);
|
1005
|
+
const bottomRight = this.getBorderBottomRightRadius(parts[2] || parts[0], important);
|
1006
|
+
const bottomLeft = this.getBorderBottomLeftRadius(parts[3] || parts[1] || parts[0], important);
|
1007
|
+
if (!topLeft || !topRight || !bottomRight || !bottomLeft) {
|
1008
|
+
return null;
|
1009
|
+
}
|
1010
|
+
return {
|
1011
|
+
...topLeft,
|
1012
|
+
...topRight,
|
1013
|
+
...bottomRight,
|
1014
|
+
...bottomLeft
|
1015
|
+
};
|
1016
|
+
}
|
1017
|
+
/**
|
1018
|
+
* Returns border radius.
|
1019
|
+
*
|
1020
|
+
* @param value Value.
|
1021
|
+
* @param important Important.
|
1022
|
+
* @returns Property values.
|
1023
|
+
*/
|
1024
|
+
static getBorderTopLeftRadius(value, important) {
|
1025
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1026
|
+
if (variable) {
|
1027
|
+
return { 'border-top-left-radius': { value: variable, important } };
|
1028
|
+
}
|
1029
|
+
const radius = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1030
|
+
CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
1031
|
+
return radius ? { 'border-top-left-radius': { important, value: radius } } : null;
|
1032
|
+
}
|
1033
|
+
/**
|
1034
|
+
* Returns border radius.
|
1035
|
+
*
|
1036
|
+
* @param value Value.
|
1037
|
+
* @param important Important.
|
1038
|
+
* @returns Property values.
|
1039
|
+
*/
|
1040
|
+
static getBorderTopRightRadius(value, important) {
|
1041
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1042
|
+
if (variable) {
|
1043
|
+
return { 'border-top-right-radius': { value: variable, important } };
|
1044
|
+
}
|
1045
|
+
const radius = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1046
|
+
CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
1047
|
+
return radius ? { 'border-top-right-radius': { important, value: radius } } : null;
|
1048
|
+
}
|
1049
|
+
/**
|
1050
|
+
* Returns border radius.
|
1051
|
+
*
|
1052
|
+
* @param value Value.
|
1053
|
+
* @param important Important.
|
1054
|
+
* @returns Property values.
|
1055
|
+
*/
|
1056
|
+
static getBorderBottomRightRadius(value, important) {
|
1057
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1058
|
+
if (variable) {
|
1059
|
+
return { 'border-bottom-right-radius': { value: variable, important } };
|
1060
|
+
}
|
1061
|
+
const radius = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1062
|
+
CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
1063
|
+
return radius ? { 'border-bottom-right-radius': { important, value: radius } } : null;
|
1064
|
+
}
|
1065
|
+
/**
|
1066
|
+
* Returns border radius.
|
1067
|
+
*
|
1068
|
+
* @param value Value.
|
1069
|
+
* @param important Important.
|
1070
|
+
* @returns Property values.
|
1071
|
+
*/
|
1072
|
+
static getBorderBottomLeftRadius(value, important) {
|
1073
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1074
|
+
if (variable) {
|
1075
|
+
return { 'border-bottom-left-radius': { value: variable, important } };
|
1076
|
+
}
|
1077
|
+
const radius = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1078
|
+
CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
1079
|
+
return radius ? { 'border-bottom-left-radius': { important, value: radius } } : null;
|
1080
|
+
}
|
1081
|
+
/**
|
1082
|
+
* Returns border top, right, bottom or left.
|
1083
|
+
*
|
1084
|
+
* @param value Value.
|
1085
|
+
* @param important Important.
|
1086
|
+
* @returns Property values.
|
1087
|
+
*/
|
1088
|
+
static getBorderTop(value, important) {
|
1089
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1090
|
+
if (variable) {
|
1091
|
+
return { 'border-top': { value: variable, important } };
|
1092
|
+
}
|
1093
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
1094
|
+
if (globalValue) {
|
1095
|
+
return {
|
1096
|
+
...this.getBorderTopWidth(globalValue, important),
|
1097
|
+
...this.getBorderTopStyle(globalValue, important),
|
1098
|
+
...this.getBorderTopColor(globalValue, important)
|
1099
|
+
};
|
1100
|
+
}
|
1101
|
+
const properties = {
|
1102
|
+
...this.getBorderTopWidth('initial', important),
|
1103
|
+
...this.getBorderTopStyle('initial', important),
|
1104
|
+
...this.getBorderTopColor('initial', important)
|
1105
|
+
};
|
1106
|
+
const parts = value.split(/ +/);
|
1107
|
+
for (const part of parts) {
|
1108
|
+
const width = this.getBorderTopWidth(part, important);
|
1109
|
+
const style = this.getBorderTopStyle(part, important);
|
1110
|
+
const color = this.getBorderTopColor(part, important);
|
1111
|
+
if (width === null && style === null && color === null) {
|
1112
|
+
return null;
|
1113
|
+
}
|
1114
|
+
Object.assign(properties, width, style, color);
|
1115
|
+
}
|
1116
|
+
return properties;
|
1117
|
+
}
|
1118
|
+
/**
|
1119
|
+
* Returns border top, right, bottom or left.
|
1120
|
+
*
|
1121
|
+
* @param value Value.
|
1122
|
+
* @param important Important.
|
1123
|
+
* @returns Property values.
|
1124
|
+
*/
|
1125
|
+
static getBorderRight(value, important) {
|
1126
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1127
|
+
if (variable) {
|
1128
|
+
return { 'border-right': { value: variable, important } };
|
1129
|
+
}
|
1130
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
1131
|
+
if (globalValue) {
|
1132
|
+
return {
|
1133
|
+
...this.getBorderRightWidth(globalValue, important),
|
1134
|
+
...this.getBorderRightStyle(globalValue, important),
|
1135
|
+
...this.getBorderRightColor(globalValue, important)
|
1136
|
+
};
|
1137
|
+
}
|
1138
|
+
const properties = {
|
1139
|
+
...this.getBorderRightWidth('initial', important),
|
1140
|
+
...this.getBorderRightStyle('initial', important),
|
1141
|
+
...this.getBorderRightColor('initial', important)
|
1142
|
+
};
|
1143
|
+
const parts = value.split(/ +/);
|
1144
|
+
for (const part of parts) {
|
1145
|
+
const width = this.getBorderRightWidth(part, important);
|
1146
|
+
const style = this.getBorderRightStyle(part, important);
|
1147
|
+
const color = this.getBorderRightColor(part, important);
|
1148
|
+
if (width === null && style === null && color === null) {
|
1149
|
+
return null;
|
1150
|
+
}
|
1151
|
+
Object.assign(properties, width, style, color);
|
1152
|
+
}
|
1153
|
+
return properties;
|
1154
|
+
}
|
1155
|
+
/**
|
1156
|
+
* Returns border top, right, bottom or left.
|
1157
|
+
*
|
1158
|
+
* @param value Value.
|
1159
|
+
* @param important Important.
|
1160
|
+
* @returns Property values.
|
1161
|
+
*/
|
1162
|
+
static getBorderBottom(value, important) {
|
1163
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1164
|
+
if (variable) {
|
1165
|
+
return { 'border-bottom': { value: variable, important } };
|
1166
|
+
}
|
1167
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
1168
|
+
if (globalValue) {
|
1169
|
+
return {
|
1170
|
+
...this.getBorderBottomWidth(globalValue, important),
|
1171
|
+
...this.getBorderBottomStyle(globalValue, important),
|
1172
|
+
...this.getBorderBottomColor(globalValue, important)
|
1173
|
+
};
|
1174
|
+
}
|
1175
|
+
const properties = {
|
1176
|
+
...this.getBorderBottomWidth('initial', important),
|
1177
|
+
...this.getBorderBottomStyle('initial', important),
|
1178
|
+
...this.getBorderBottomColor('initial', important)
|
1179
|
+
};
|
1180
|
+
const parts = value.split(/ +/);
|
1181
|
+
for (const part of parts) {
|
1182
|
+
const width = this.getBorderBottomWidth(part, important);
|
1183
|
+
const style = this.getBorderBottomStyle(part, important);
|
1184
|
+
const color = this.getBorderBottomColor(part, important);
|
1185
|
+
if (width === null && style === null && color === null) {
|
1186
|
+
return null;
|
1187
|
+
}
|
1188
|
+
Object.assign(properties, width, style, color);
|
1189
|
+
}
|
1190
|
+
return properties;
|
1191
|
+
}
|
1192
|
+
/**
|
1193
|
+
* Returns border top, right, bottom or left.
|
1194
|
+
*
|
1195
|
+
* @param value Value.
|
1196
|
+
* @param important Important.
|
1197
|
+
* @returns Property values.
|
1198
|
+
*/
|
1199
|
+
static getBorderLeft(value, important) {
|
1200
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1201
|
+
if (variable) {
|
1202
|
+
return { 'border-left': { value: variable, important } };
|
1203
|
+
}
|
1204
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
1205
|
+
if (globalValue) {
|
1206
|
+
return {
|
1207
|
+
...this.getBorderLeftWidth(globalValue, important),
|
1208
|
+
...this.getBorderLeftStyle(globalValue, important),
|
1209
|
+
...this.getBorderLeftColor(globalValue, important)
|
1210
|
+
};
|
1211
|
+
}
|
1212
|
+
const properties = {
|
1213
|
+
...this.getBorderLeftWidth('initial', important),
|
1214
|
+
...this.getBorderLeftStyle('initial', important),
|
1215
|
+
...this.getBorderLeftColor('initial', important)
|
1216
|
+
};
|
1217
|
+
const parts = value.split(/ +/);
|
1218
|
+
for (const part of parts) {
|
1219
|
+
const width = this.getBorderLeftWidth(part, important);
|
1220
|
+
const style = this.getBorderLeftStyle(part, important);
|
1221
|
+
const color = this.getBorderLeftColor(part, important);
|
1222
|
+
if (width === null && style === null && color === null) {
|
1223
|
+
return null;
|
1224
|
+
}
|
1225
|
+
Object.assign(properties, width, style, color);
|
1226
|
+
}
|
1227
|
+
return properties;
|
1228
|
+
}
|
1229
|
+
/**
|
1230
|
+
* Returns padding.
|
1231
|
+
*
|
1232
|
+
* @param value Value.
|
1233
|
+
* @param important Important.
|
1234
|
+
*/
|
1235
|
+
static getPadding(value, important) {
|
1236
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1237
|
+
if (variable) {
|
1238
|
+
return { padding: { value: variable, important } };
|
1239
|
+
}
|
1240
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
1241
|
+
if (globalValue) {
|
1242
|
+
return {
|
1243
|
+
...this.getPaddingTop(globalValue, important),
|
1244
|
+
...this.getPaddingRight(globalValue, important),
|
1245
|
+
...this.getPaddingBottom(globalValue, important),
|
1246
|
+
...this.getPaddingLeft(globalValue, important)
|
1247
|
+
};
|
1248
|
+
}
|
1249
|
+
const parts = value.split(/ +/);
|
1250
|
+
const top = this.getPaddingTop(parts[0], important);
|
1251
|
+
const right = this.getPaddingRight(parts[1] || parts[0], important);
|
1252
|
+
const bottom = this.getPaddingBottom(parts[2] || parts[0], important);
|
1253
|
+
const left = this.getPaddingLeft(parts[3] || parts[1] || parts[0], important);
|
1254
|
+
if (!top || !right || !bottom || !left) {
|
1255
|
+
return null;
|
1256
|
+
}
|
1257
|
+
return {
|
1258
|
+
...top,
|
1259
|
+
...right,
|
1260
|
+
...bottom,
|
1261
|
+
...left
|
1262
|
+
};
|
1263
|
+
}
|
1264
|
+
/**
|
1265
|
+
* Returns padding top.
|
1266
|
+
*
|
1267
|
+
* @param value Value.
|
1268
|
+
* @param important Important.
|
1269
|
+
* @returns Property values.
|
1270
|
+
*/
|
1271
|
+
static getPaddingTop(value, important) {
|
1272
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1273
|
+
if (variable) {
|
1274
|
+
return { 'padding-top': { value: variable, important } };
|
1275
|
+
}
|
1276
|
+
const padding = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1277
|
+
CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
1278
|
+
return padding ? { 'padding-top': { value: padding, important } } : null;
|
1279
|
+
}
|
1280
|
+
/**
|
1281
|
+
* Returns padding right.
|
1282
|
+
*
|
1283
|
+
* @param value Value.
|
1284
|
+
* @param important Important.
|
1285
|
+
* @returns Property values.
|
1286
|
+
*/
|
1287
|
+
static getPaddingRight(value, important) {
|
1288
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1289
|
+
if (variable) {
|
1290
|
+
return { 'padding-right': { value: variable, important } };
|
1291
|
+
}
|
1292
|
+
const padding = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1293
|
+
CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
1294
|
+
return padding ? { 'padding-right': { value: padding, important } } : null;
|
1295
|
+
}
|
1296
|
+
/**
|
1297
|
+
* Returns padding bottom.
|
1298
|
+
*
|
1299
|
+
* @param value Value.
|
1300
|
+
* @param important Important.
|
1301
|
+
* @returns Property values.
|
1302
|
+
*/
|
1303
|
+
static getPaddingBottom(value, important) {
|
1304
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1305
|
+
if (variable) {
|
1306
|
+
return { 'padding-bottom': { value: variable, important } };
|
1307
|
+
}
|
1308
|
+
const padding = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1309
|
+
CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
1310
|
+
return padding ? { 'padding-bottom': { value: padding, important } } : null;
|
1311
|
+
}
|
1312
|
+
/**
|
1313
|
+
* Returns padding left.
|
1314
|
+
*
|
1315
|
+
* @param value Value.
|
1316
|
+
* @param important Important.
|
1317
|
+
* @returns Property values.
|
1318
|
+
*/
|
1319
|
+
static getPaddingLeft(value, important) {
|
1320
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1321
|
+
if (variable) {
|
1322
|
+
return { 'padding-left': { value: variable, important } };
|
1323
|
+
}
|
1324
|
+
const padding = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1325
|
+
CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
1326
|
+
return padding ? { 'padding-left': { value: padding, important } } : null;
|
1327
|
+
}
|
1328
|
+
/**
|
1329
|
+
* Returns margin.
|
1330
|
+
*
|
1331
|
+
* @param value Value.
|
1332
|
+
* @param important Important.
|
1333
|
+
* @returns Property values.
|
1334
|
+
*/
|
1335
|
+
static getMargin(value, important) {
|
1336
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1337
|
+
if (variable) {
|
1338
|
+
return { margin: { value: variable, important } };
|
1339
|
+
}
|
1340
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
1341
|
+
if (globalValue) {
|
1342
|
+
return {
|
1343
|
+
...this.getMarginTop(globalValue, important),
|
1344
|
+
...this.getMarginRight(globalValue, important),
|
1345
|
+
...this.getMarginBottom(globalValue, important),
|
1346
|
+
...this.getMarginLeft(globalValue, important)
|
1347
|
+
};
|
1348
|
+
}
|
1349
|
+
const parts = value.split(/ +/);
|
1350
|
+
const top = this.getMarginTop(parts[0], important);
|
1351
|
+
const right = this.getMarginRight(parts[1] || parts[0], important);
|
1352
|
+
const bottom = this.getMarginBottom(parts[2] || parts[0], important);
|
1353
|
+
const left = this.getMarginLeft(parts[3] || parts[1] || parts[0], important);
|
1354
|
+
if (!top || !right || !bottom || !left) {
|
1355
|
+
return null;
|
1356
|
+
}
|
1357
|
+
return {
|
1358
|
+
...top,
|
1359
|
+
...right,
|
1360
|
+
...bottom,
|
1361
|
+
...left
|
1362
|
+
};
|
1363
|
+
}
|
1364
|
+
/**
|
1365
|
+
* Returns margin top.
|
1366
|
+
*
|
1367
|
+
* @param value Value.
|
1368
|
+
* @param important Important.
|
1369
|
+
* @returns Property values.
|
1370
|
+
*/
|
1371
|
+
static getMarginTop(value, important) {
|
1372
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1373
|
+
if (variable) {
|
1374
|
+
return { 'margin-top': { value: variable, important } };
|
1375
|
+
}
|
1376
|
+
const margin = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1377
|
+
CSSStyleDeclarationValueParser_1.default.getAutoMeasurement(value);
|
1378
|
+
return margin ? { 'margin-top': { value: margin, important } } : null;
|
1379
|
+
}
|
1380
|
+
/**
|
1381
|
+
* Returns margin right.
|
1382
|
+
*
|
1383
|
+
* @param value Value.
|
1384
|
+
* @param important Important.
|
1385
|
+
* @returns Property values.
|
1386
|
+
*/
|
1387
|
+
static getMarginRight(value, important) {
|
1388
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1389
|
+
if (variable) {
|
1390
|
+
return { 'margin-right': { value: variable, important } };
|
1391
|
+
}
|
1392
|
+
const margin = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1393
|
+
CSSStyleDeclarationValueParser_1.default.getAutoMeasurement(value);
|
1394
|
+
return margin ? { 'margin-right': { value: margin, important } } : null;
|
1395
|
+
}
|
1396
|
+
/**
|
1397
|
+
* Returns margin right.
|
1398
|
+
*
|
1399
|
+
* @param value Value.
|
1400
|
+
* @param important Important.
|
1401
|
+
* @returns Property values.
|
1402
|
+
*/
|
1403
|
+
static getMarginBottom(value, important) {
|
1404
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1405
|
+
if (variable) {
|
1406
|
+
return { 'margin-bottom': { value: variable, important } };
|
1407
|
+
}
|
1408
|
+
const margin = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1409
|
+
CSSStyleDeclarationValueParser_1.default.getAutoMeasurement(value);
|
1410
|
+
return margin ? { 'margin-bottom': { value: margin, important } } : null;
|
1411
|
+
}
|
1412
|
+
/**
|
1413
|
+
* Returns margin left.
|
1414
|
+
*
|
1415
|
+
* @param value Value.
|
1416
|
+
* @param important Important.
|
1417
|
+
* @returns Property values.
|
1418
|
+
*/
|
1419
|
+
static getMarginLeft(value, important) {
|
1420
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1421
|
+
if (variable) {
|
1422
|
+
return { 'margin-left': { value: variable, important } };
|
1423
|
+
}
|
1424
|
+
const margin = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1425
|
+
CSSStyleDeclarationValueParser_1.default.getAutoMeasurement(value);
|
1426
|
+
return margin ? { 'margin-left': { value: margin, important } } : null;
|
1427
|
+
}
|
1428
|
+
/**
|
1429
|
+
* Returns flex.
|
1430
|
+
*
|
1431
|
+
* @param value Value.
|
1432
|
+
* @param important Important.
|
1433
|
+
* @returns Property values.
|
1434
|
+
*/
|
1435
|
+
static getFlex(value, important) {
|
1436
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1437
|
+
if (variable) {
|
1438
|
+
return { flex: { value: variable, important } };
|
1439
|
+
}
|
1440
|
+
const lowerValue = value.trim().toLowerCase();
|
1441
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
1442
|
+
if (globalValue) {
|
1443
|
+
return {
|
1444
|
+
...this.getFlexGrow(globalValue, important),
|
1445
|
+
...this.getFlexShrink(globalValue, important),
|
1446
|
+
...this.getFlexBasis(globalValue, important)
|
1447
|
+
};
|
1448
|
+
}
|
1449
|
+
switch (lowerValue) {
|
1450
|
+
case 'none':
|
1451
|
+
return {
|
1452
|
+
...this.getFlexGrow('0', important),
|
1453
|
+
...this.getFlexShrink('0', important),
|
1454
|
+
...this.getFlexBasis('auto', important)
|
1455
|
+
};
|
1456
|
+
case 'auto':
|
1457
|
+
return {
|
1458
|
+
...this.getFlexGrow('1', important),
|
1459
|
+
...this.getFlexShrink('1', important),
|
1460
|
+
...this.getFlexBasis('auto', important)
|
1461
|
+
};
|
1462
|
+
}
|
1463
|
+
const measurement = CSSStyleDeclarationValueParser_1.default.getContentMeasurement(lowerValue);
|
1464
|
+
if (measurement) {
|
1465
|
+
return {
|
1466
|
+
...this.getFlexGrow('1', important),
|
1467
|
+
...this.getFlexShrink('1', important),
|
1468
|
+
...this.getFlexBasis(measurement, important)
|
1469
|
+
};
|
1470
|
+
}
|
1471
|
+
const parts = value.split(/ +/);
|
1472
|
+
const flexGrow = this.getFlexGrow(parts[0], important);
|
1473
|
+
const flexShrink = this.getFlexShrink(parts[1] || '1', important);
|
1474
|
+
const flexBasis = this.getFlexBasis(parts[2] || '0%', important);
|
1475
|
+
if (!flexGrow || !flexShrink || !flexBasis) {
|
1476
|
+
return null;
|
1477
|
+
}
|
1478
|
+
return {
|
1479
|
+
...flexGrow,
|
1480
|
+
...flexShrink,
|
1481
|
+
...flexBasis
|
1482
|
+
};
|
1483
|
+
}
|
1484
|
+
/**
|
1485
|
+
* Returns flex basis.
|
1486
|
+
*
|
1487
|
+
* @param value Value.
|
1488
|
+
* @param important Important.
|
1489
|
+
* @returns Property values
|
1490
|
+
*/
|
1491
|
+
static getFlexBasis(value, important) {
|
1492
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1493
|
+
if (variable) {
|
1494
|
+
return { 'flex-basis': { value: variable, important } };
|
1495
|
+
}
|
1496
|
+
const lowerValue = value.toLowerCase();
|
1497
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || FLEX_BASIS.includes(lowerValue)) {
|
1498
|
+
return { 'flex-basis': { value: lowerValue, important } };
|
1499
|
+
}
|
1500
|
+
const measurement = CSSStyleDeclarationValueParser_1.default.getContentMeasurement(lowerValue);
|
1501
|
+
return measurement ? { 'flex-basis': { value: measurement, important } } : null;
|
1502
|
+
}
|
1503
|
+
/**
|
1504
|
+
* Returns flex shrink.
|
1505
|
+
*
|
1506
|
+
* @param value Value.
|
1507
|
+
* @param important Important.
|
1508
|
+
* @returns Property values
|
1509
|
+
*/
|
1510
|
+
static getFlexShrink(value, important) {
|
1511
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1512
|
+
if (variable) {
|
1513
|
+
return { 'flex-shrink': { value: variable, important } };
|
1514
|
+
}
|
1515
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1516
|
+
CSSStyleDeclarationValueParser_1.default.getFloat(value);
|
1517
|
+
return parsedValue ? { 'flex-shrink': { value: parsedValue, important } } : null;
|
1518
|
+
}
|
1519
|
+
/**
|
1520
|
+
* Returns flex grow.
|
1521
|
+
*
|
1522
|
+
* @param value Value.
|
1523
|
+
* @param important Important.
|
1524
|
+
* @returns Property values
|
1525
|
+
*/
|
1526
|
+
static getFlexGrow(value, important) {
|
1527
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1528
|
+
if (variable) {
|
1529
|
+
return { 'flex-grow': { value: variable, important } };
|
1530
|
+
}
|
1531
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1532
|
+
CSSStyleDeclarationValueParser_1.default.getFloat(value);
|
1533
|
+
return parsedValue ? { 'flex-grow': { value: parsedValue, important } } : null;
|
1534
|
+
}
|
1535
|
+
/**
|
1536
|
+
* Returns background.
|
1537
|
+
*
|
1538
|
+
* @param name Name.
|
1539
|
+
* @param value Value.
|
1540
|
+
* @param important Important.
|
1541
|
+
* @returns Property values.
|
1542
|
+
*/
|
1543
|
+
static getBackground(value, important) {
|
1544
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1545
|
+
if (variable) {
|
1546
|
+
return { background: { value: variable, important } };
|
1547
|
+
}
|
1548
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
1549
|
+
if (globalValue) {
|
1550
|
+
return {
|
1551
|
+
...this.getBackgroundImage(globalValue, important),
|
1552
|
+
...this.getBackgroundPosition(globalValue, important),
|
1553
|
+
...this.getBackgroundSize(globalValue, important),
|
1554
|
+
...this.getBackgroundRepeat(globalValue, important),
|
1555
|
+
...this.getBackgroundAttachment(globalValue, important),
|
1556
|
+
...this.getBackgroundOrigin(globalValue, important),
|
1557
|
+
...this.getBackgroundClip(globalValue, important),
|
1558
|
+
...this.getBackgroundColor(globalValue, important)
|
1559
|
+
};
|
1560
|
+
}
|
1561
|
+
const properties = {
|
1562
|
+
...this.getBackgroundImage('initial', important),
|
1563
|
+
...this.getBackgroundPosition('initial', important),
|
1564
|
+
...this.getBackgroundSize('initial', important),
|
1565
|
+
...this.getBackgroundRepeat('initial', important),
|
1566
|
+
...this.getBackgroundAttachment('initial', important),
|
1567
|
+
...this.getBackgroundOrigin('initial', important),
|
1568
|
+
...this.getBackgroundClip('initial', important),
|
1569
|
+
...this.getBackgroundColor('initial', important)
|
1570
|
+
};
|
1571
|
+
const parts = value
|
1572
|
+
.replace(/[ ]*,[ ]*/g, ',')
|
1573
|
+
.replace(/[ ]*\/[ ]*/g, '/')
|
1574
|
+
.split(/ +/);
|
1575
|
+
const backgroundPositions = [];
|
1576
|
+
for (const part of parts) {
|
1577
|
+
if (!part.startsWith('url') && part.includes('/')) {
|
1578
|
+
const [position, size] = part.split('/');
|
1579
|
+
const backgroundPositionX = this.getBackgroundPositionX(position, important);
|
1580
|
+
const backgroundPositionY = this.getBackgroundPositionY(position, important);
|
1581
|
+
const backgroundSize = this.getBackgroundSize(size, important);
|
1582
|
+
if ((!backgroundPositionX && !backgroundPositionY) || !backgroundSize) {
|
1583
|
+
return null;
|
1584
|
+
}
|
1585
|
+
if (backgroundPositionY) {
|
1586
|
+
backgroundPositions.push(backgroundPositionY['background-position-y'].value);
|
1587
|
+
}
|
1588
|
+
else if (backgroundPositionX) {
|
1589
|
+
backgroundPositions.push(backgroundPositionX['background-position-x'].value);
|
1590
|
+
}
|
1591
|
+
Object.assign(properties, backgroundSize);
|
1592
|
+
}
|
1593
|
+
else {
|
1594
|
+
const backgroundImage = this.getBackgroundImage(part, important);
|
1595
|
+
const backgroundRepeat = this.getBackgroundRepeat(part, important);
|
1596
|
+
const backgroundAttachment = this.getBackgroundAttachment(part, important);
|
1597
|
+
const backgroundPositionX = this.getBackgroundPositionX(part, important);
|
1598
|
+
const backgroundPositionY = this.getBackgroundPositionY(part, important);
|
1599
|
+
const backgroundColor = this.getBackgroundColor(part, important);
|
1600
|
+
const backgroundOrigin = this.getBackgroundOrigin(part, important);
|
1601
|
+
const backgroundClip = this.getBackgroundClip(part, important);
|
1602
|
+
if (!backgroundImage &&
|
1603
|
+
!backgroundRepeat &&
|
1604
|
+
!backgroundAttachment &&
|
1605
|
+
!backgroundPositionX &&
|
1606
|
+
!backgroundPositionY &&
|
1607
|
+
!backgroundColor &&
|
1608
|
+
!backgroundOrigin &&
|
1609
|
+
!backgroundClip) {
|
1610
|
+
return null;
|
1611
|
+
}
|
1612
|
+
if (backgroundPositionX) {
|
1613
|
+
backgroundPositions.push(backgroundPositionX['background-position-x'].value);
|
1614
|
+
}
|
1615
|
+
else if (backgroundPositionY) {
|
1616
|
+
backgroundPositions.push(backgroundPositionY['background-position-y'].value);
|
1617
|
+
}
|
1618
|
+
Object.assign(properties, backgroundImage, backgroundRepeat, backgroundAttachment, backgroundColor, backgroundOrigin, backgroundClip);
|
1619
|
+
}
|
1620
|
+
}
|
1621
|
+
if (backgroundPositions.length) {
|
1622
|
+
Object.assign(properties, this.getBackgroundPosition(backgroundPositions.join(' '), important));
|
1623
|
+
}
|
1624
|
+
return properties;
|
1625
|
+
}
|
1626
|
+
/**
|
1627
|
+
* Returns background size.
|
1628
|
+
*
|
1629
|
+
* @param value Value.
|
1630
|
+
* @param important Important.
|
1631
|
+
* @returns Property values
|
1632
|
+
*/
|
1633
|
+
static getBackgroundSize(value, important) {
|
1634
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1635
|
+
if (variable) {
|
1636
|
+
return { 'background-size': { value: variable, important } };
|
1637
|
+
}
|
1638
|
+
const lowerValue = value.toLowerCase();
|
1639
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)) {
|
1640
|
+
return { 'background-size': { value: lowerValue, important } };
|
1641
|
+
}
|
1642
|
+
const imageParts = lowerValue.split(',');
|
1643
|
+
const parsed = [];
|
1644
|
+
for (const imagePart of imageParts) {
|
1645
|
+
const parts = imagePart.trim().split(' ');
|
1646
|
+
if (parts.length !== 1 && parts.length !== 2) {
|
1647
|
+
return null;
|
1648
|
+
}
|
1649
|
+
if (parts.length === 1) {
|
1650
|
+
if (parts[0] !== 'cover' &&
|
1651
|
+
parts[0] !== 'contain' &&
|
1652
|
+
!CSSStyleDeclarationValueParser_1.default.getAutoMeasurement(parts[0])) {
|
1653
|
+
return null;
|
1654
|
+
}
|
1655
|
+
parsed.push(parts[0]);
|
1656
|
+
}
|
1657
|
+
else {
|
1658
|
+
if (!CSSStyleDeclarationValueParser_1.default.getAutoMeasurement(parts[0]) ||
|
1659
|
+
!CSSStyleDeclarationValueParser_1.default.getAutoMeasurement(parts[1])) {
|
1660
|
+
return null;
|
1661
|
+
}
|
1662
|
+
parsed.push(`${parts[0]} ${parts[1]}`);
|
1663
|
+
}
|
1664
|
+
}
|
1665
|
+
if (parsed.length === 1) {
|
1666
|
+
return { 'background-size': { value: parsed.join(', '), important } };
|
1667
|
+
}
|
1668
|
+
return null;
|
1669
|
+
}
|
1670
|
+
/**
|
1671
|
+
* Returns background origin.
|
1672
|
+
*
|
1673
|
+
* @param value Value.
|
1674
|
+
* @param important Important.
|
1675
|
+
* @returns Property values
|
1676
|
+
*/
|
1677
|
+
static getBackgroundOrigin(value, important) {
|
1678
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1679
|
+
if (variable) {
|
1680
|
+
return { 'background-origin': { value: variable, important } };
|
1681
|
+
}
|
1682
|
+
const lowerValue = value.toLowerCase();
|
1683
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) ||
|
1684
|
+
BACKGROUND_ORIGIN.includes(lowerValue)) {
|
1685
|
+
return { 'background-origin': { value: lowerValue, important } };
|
1686
|
+
}
|
1687
|
+
return null;
|
1688
|
+
}
|
1689
|
+
/**
|
1690
|
+
* Returns background clip.
|
1691
|
+
*
|
1692
|
+
* @param value Value.
|
1693
|
+
* @param important Important.
|
1694
|
+
* @returns Property values
|
1695
|
+
*/
|
1696
|
+
static getBackgroundClip(value, important) {
|
1697
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1698
|
+
if (variable) {
|
1699
|
+
return { 'background-clip': { value: variable, important } };
|
1700
|
+
}
|
1701
|
+
const lowerValue = value.toLowerCase();
|
1702
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) ||
|
1703
|
+
BACKGROUND_CLIP.includes(lowerValue)) {
|
1704
|
+
return { 'background-clip': { value: lowerValue, important } };
|
1705
|
+
}
|
1706
|
+
return null;
|
1707
|
+
}
|
1708
|
+
/**
|
1709
|
+
* Returns background repeat.
|
1710
|
+
*
|
1711
|
+
* @param value Value.
|
1712
|
+
* @param important Important.
|
1713
|
+
* @returns Property values
|
1714
|
+
*/
|
1715
|
+
static getBackgroundRepeat(value, important) {
|
1716
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1717
|
+
if (variable) {
|
1718
|
+
return { 'background-repeat': { value: variable, important } };
|
1719
|
+
}
|
1720
|
+
const lowerValue = value.toLowerCase();
|
1721
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) ||
|
1722
|
+
BACKGROUND_REPEAT.includes(lowerValue)) {
|
1723
|
+
return { 'background-repeat': { value: lowerValue, important } };
|
1724
|
+
}
|
1725
|
+
return null;
|
1726
|
+
}
|
1727
|
+
/**
|
1728
|
+
* Returns background attachment.
|
1729
|
+
*
|
1730
|
+
* @param value Value.
|
1731
|
+
* @param important Important.
|
1732
|
+
* @returns Property values
|
1733
|
+
*/
|
1734
|
+
static getBackgroundAttachment(value, important) {
|
1735
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1736
|
+
if (variable) {
|
1737
|
+
return { 'background-attachment': { value: variable, important } };
|
1738
|
+
}
|
1739
|
+
const lowerValue = value.toLowerCase();
|
1740
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) ||
|
1741
|
+
BACKGROUND_ATTACHMENT.includes(lowerValue)) {
|
1742
|
+
return { 'background-attachment': { value: lowerValue, important } };
|
1743
|
+
}
|
1744
|
+
return null;
|
1745
|
+
}
|
1746
|
+
/**
|
1747
|
+
* Returns background position.
|
1748
|
+
*
|
1749
|
+
* @param value Value.
|
1750
|
+
* @param important Important.
|
1751
|
+
* @returns Property values
|
1752
|
+
*/
|
1753
|
+
static getBackgroundPosition(value, important) {
|
1754
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1755
|
+
if (variable) {
|
1756
|
+
return { 'background-position': { value: variable, important } };
|
1757
|
+
}
|
1758
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
1759
|
+
if (globalValue) {
|
1760
|
+
return {
|
1761
|
+
...this.getBackgroundPositionX(globalValue, important),
|
1762
|
+
...this.getBackgroundPositionY(globalValue, important)
|
1763
|
+
};
|
1764
|
+
}
|
1765
|
+
const imageParts = value.replace(/ *, */g, ',').split(',');
|
1766
|
+
let x = '';
|
1767
|
+
let y = '';
|
1768
|
+
for (const imagePart of imageParts) {
|
1769
|
+
const parts = imagePart.trim().split(/ +/);
|
1770
|
+
if (x) {
|
1771
|
+
x += ',';
|
1772
|
+
y += ',';
|
1773
|
+
}
|
1774
|
+
switch (parts.length) {
|
1775
|
+
case 1:
|
1776
|
+
if (parts[0] === 'top' || parts[0] === 'bottom') {
|
1777
|
+
x += 'center';
|
1778
|
+
y += parts[0];
|
1779
|
+
}
|
1780
|
+
else if (parts[0] === 'left' || parts[0] === 'right') {
|
1781
|
+
x += parts[0];
|
1782
|
+
y += 'center';
|
1783
|
+
}
|
1784
|
+
else if (parts[0] === 'center') {
|
1785
|
+
x += 'center';
|
1786
|
+
y += 'center';
|
1787
|
+
}
|
1788
|
+
break;
|
1789
|
+
case 2:
|
1790
|
+
x += parts[0] === 'top' || parts[0] === 'bottom' ? parts[1] : parts[0];
|
1791
|
+
y += parts[0] === 'top' || parts[0] === 'bottom' ? parts[0] : parts[1];
|
1792
|
+
break;
|
1793
|
+
case 3:
|
1794
|
+
if (parts[0] === 'top' ||
|
1795
|
+
parts[0] === 'bottom' ||
|
1796
|
+
parts[1] === 'left' ||
|
1797
|
+
parts[1] === 'right' ||
|
1798
|
+
parts[2] === 'left' ||
|
1799
|
+
parts[2] === 'right') {
|
1800
|
+
if (CSSStyleDeclarationValueParser_1.default.getMeasurement(parts[1])) {
|
1801
|
+
x += parts[2];
|
1802
|
+
y += `${parts[0]} ${parts[1]}`;
|
1803
|
+
}
|
1804
|
+
else {
|
1805
|
+
x += `${parts[1]} ${parts[2]}`;
|
1806
|
+
y += parts[0];
|
1807
|
+
}
|
1808
|
+
}
|
1809
|
+
else {
|
1810
|
+
if (CSSStyleDeclarationValueParser_1.default.getMeasurement(parts[1])) {
|
1811
|
+
x += `${parts[0]} ${parts[1]}`;
|
1812
|
+
y += parts[2];
|
1813
|
+
}
|
1814
|
+
else {
|
1815
|
+
x += parts[0];
|
1816
|
+
y += `${parts[1]} ${parts[2]}`;
|
1817
|
+
}
|
1818
|
+
}
|
1819
|
+
break;
|
1820
|
+
case 4:
|
1821
|
+
x +=
|
1822
|
+
parts[0] === 'top' ||
|
1823
|
+
parts[0] === 'bottom' ||
|
1824
|
+
parts[1] === 'top' ||
|
1825
|
+
parts[1] === 'bottom'
|
1826
|
+
? `${parts[2]} ${parts[3]}`
|
1827
|
+
: `${parts[0]} ${parts[1]}`;
|
1828
|
+
y +=
|
1829
|
+
parts[0] === 'top' ||
|
1830
|
+
parts[0] === 'bottom' ||
|
1831
|
+
parts[1] === 'top' ||
|
1832
|
+
parts[1] === 'bottom'
|
1833
|
+
? `${parts[0]} ${parts[1]}`
|
1834
|
+
: `${parts[2]} ${parts[3]}`;
|
1835
|
+
break;
|
1836
|
+
default:
|
1837
|
+
return null;
|
1838
|
+
}
|
1839
|
+
}
|
1840
|
+
const xValue = this.getBackgroundPositionX(x, important);
|
1841
|
+
const yValue = this.getBackgroundPositionY(y, important);
|
1842
|
+
if (xValue && yValue) {
|
1843
|
+
return {
|
1844
|
+
...xValue,
|
1845
|
+
...yValue
|
1846
|
+
};
|
1847
|
+
}
|
1848
|
+
return null;
|
1849
|
+
}
|
1850
|
+
/**
|
1851
|
+
* Returns background position.
|
1852
|
+
*
|
1853
|
+
* @param value Value.
|
1854
|
+
* @param important Important.
|
1855
|
+
* @returns Property values
|
1856
|
+
*/
|
1857
|
+
static getBackgroundPositionX(value, important) {
|
1858
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1859
|
+
if (variable) {
|
1860
|
+
return { 'background-position-x': { value: variable, important } };
|
1861
|
+
}
|
1862
|
+
const lowerValue = value.toLowerCase();
|
1863
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)) {
|
1864
|
+
return { 'background-position-x': { value: lowerValue, important } };
|
1865
|
+
}
|
1866
|
+
const imageParts = lowerValue.replace(/ *, */g, ',').split(',');
|
1867
|
+
let parsedValue = '';
|
1868
|
+
for (const imagePart of imageParts) {
|
1869
|
+
const parts = imagePart.trim().split(/ +/);
|
1870
|
+
if (parsedValue) {
|
1871
|
+
parsedValue += ',';
|
1872
|
+
}
|
1873
|
+
for (const part of parts) {
|
1874
|
+
const measurement = CSSStyleDeclarationValueParser_1.default.getMeasurement(part);
|
1875
|
+
if (!measurement && part !== 'left' && part !== 'right' && part !== 'center') {
|
1876
|
+
return null;
|
1877
|
+
}
|
1878
|
+
if (parsedValue) {
|
1879
|
+
parsedValue += ' ';
|
1880
|
+
}
|
1881
|
+
parsedValue += measurement || part;
|
1882
|
+
}
|
1883
|
+
}
|
1884
|
+
return { 'background-position-x': { value: parsedValue, important } };
|
1885
|
+
}
|
1886
|
+
/**
|
1887
|
+
* Returns background position.
|
1888
|
+
*
|
1889
|
+
* @param value Value.
|
1890
|
+
* @param important Important.
|
1891
|
+
* @returns Property values
|
1892
|
+
*/
|
1893
|
+
static getBackgroundPositionY(value, important) {
|
1894
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1895
|
+
if (variable) {
|
1896
|
+
return { 'background-position-y': { value: variable, important } };
|
1897
|
+
}
|
1898
|
+
const lowerValue = value.toLowerCase();
|
1899
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)) {
|
1900
|
+
return { 'background-position-y': { value: lowerValue, important } };
|
1901
|
+
}
|
1902
|
+
const imageParts = lowerValue.replace(/ *, */g, ',').split(',');
|
1903
|
+
let parsedValue = '';
|
1904
|
+
for (const imagePart of imageParts) {
|
1905
|
+
const parts = imagePart.trim().split(/ +/);
|
1906
|
+
if (parsedValue) {
|
1907
|
+
parsedValue += ',';
|
1908
|
+
}
|
1909
|
+
for (const part of parts) {
|
1910
|
+
const measurement = CSSStyleDeclarationValueParser_1.default.getMeasurement(part);
|
1911
|
+
if (!measurement && part !== 'top' && part !== 'bottom' && part !== 'center') {
|
1912
|
+
return null;
|
1913
|
+
}
|
1914
|
+
if (parsedValue) {
|
1915
|
+
parsedValue += ' ';
|
1916
|
+
}
|
1917
|
+
parsedValue += measurement || part;
|
1918
|
+
}
|
1919
|
+
}
|
1920
|
+
return { 'background-position-y': { value: parsedValue, important } };
|
1921
|
+
}
|
1922
|
+
/**
|
1923
|
+
* Returns background color.
|
1924
|
+
*
|
1925
|
+
* @param value Value.
|
1926
|
+
* @param important Important.
|
1927
|
+
* @returns Property value.
|
1928
|
+
*/
|
1929
|
+
static getBackgroundColor(value, important) {
|
1930
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1931
|
+
if (variable) {
|
1932
|
+
return { 'background-color': { value: variable, important } };
|
1933
|
+
}
|
1934
|
+
const color = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1935
|
+
CSSStyleDeclarationValueParser_1.default.getColor(value);
|
1936
|
+
return color
|
1937
|
+
? {
|
1938
|
+
['background-color']: { important, value: color }
|
1939
|
+
}
|
1940
|
+
: null;
|
1941
|
+
}
|
1942
|
+
/**
|
1943
|
+
* Returns background image.
|
1944
|
+
*
|
1945
|
+
* @param value Value.
|
1946
|
+
* @param important Important.
|
1947
|
+
* @returns Property value.
|
1948
|
+
*/
|
1949
|
+
static getBackgroundImage(value, important) {
|
1950
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1951
|
+
if (variable) {
|
1952
|
+
return { 'background-image': { value: variable, important } };
|
1953
|
+
}
|
1954
|
+
const lowerValue = value.toLowerCase();
|
1955
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || lowerValue === 'none') {
|
1956
|
+
return { 'background-image': { value: lowerValue, important } };
|
1957
|
+
}
|
1958
|
+
const parts = value.replace(/ *, */g, ',').split(',');
|
1959
|
+
const parsed = [];
|
1960
|
+
for (const part of parts) {
|
1961
|
+
const url = CSSStyleDeclarationValueParser_1.default.getURL(part.trim());
|
1962
|
+
if (!url) {
|
1963
|
+
return null;
|
1964
|
+
}
|
1965
|
+
parsed.push(url);
|
1966
|
+
}
|
1967
|
+
if (parsed.length) {
|
1968
|
+
return { 'background-image': { value: parsed.join(', '), important } };
|
1969
|
+
}
|
1970
|
+
return null;
|
1971
|
+
}
|
1972
|
+
/**
|
1973
|
+
* Returns color.
|
1974
|
+
*
|
1975
|
+
* @param value Value.
|
1976
|
+
* @param important Important.
|
1977
|
+
* @returns Property value.
|
1978
|
+
*/
|
1979
|
+
static getColor(value, important) {
|
1980
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1981
|
+
if (variable) {
|
1982
|
+
return { color: { value: variable, important } };
|
1983
|
+
}
|
1984
|
+
const color = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
1985
|
+
CSSStyleDeclarationValueParser_1.default.getColor(value);
|
1986
|
+
return color ? { color: { important, value: color } } : null;
|
1987
|
+
}
|
1988
|
+
/**
|
1989
|
+
* Returns color.
|
1990
|
+
*
|
1991
|
+
* @param value Value.
|
1992
|
+
* @param important Important.
|
1993
|
+
* @returns Property value.
|
1994
|
+
*/
|
1995
|
+
static getFloodColor(value, important) {
|
1996
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
1997
|
+
if (variable) {
|
1998
|
+
return { 'flood-color': { value: variable, important } };
|
1999
|
+
}
|
2000
|
+
const color = CSSStyleDeclarationValueParser_1.default.getGlobal(value) ||
|
2001
|
+
CSSStyleDeclarationValueParser_1.default.getColor(value);
|
2002
|
+
return color ? { 'flood-color': { important, value: color } } : null;
|
2003
|
+
}
|
2004
|
+
/**
|
2005
|
+
* Returns font.
|
2006
|
+
*
|
2007
|
+
* @param value Value.
|
2008
|
+
* @param important Important.
|
2009
|
+
* @returns Property values
|
2010
|
+
*/
|
2011
|
+
static getFont(value, important) {
|
2012
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2013
|
+
if (variable) {
|
2014
|
+
return { font: { value: variable, important } };
|
2015
|
+
}
|
2016
|
+
const lowerValue = value.toLowerCase();
|
2017
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue)) {
|
2018
|
+
return {
|
2019
|
+
...this.getFontStyle(lowerValue, important),
|
2020
|
+
...this.getFontVariant(lowerValue, important),
|
2021
|
+
...this.getFontWeight(lowerValue, important),
|
2022
|
+
...this.getFontStretch(lowerValue, important),
|
2023
|
+
...this.getFontSize(lowerValue, important),
|
2024
|
+
...this.getLineHeight(lowerValue, important),
|
2025
|
+
...this.getFontFamily(lowerValue, important)
|
2026
|
+
};
|
2027
|
+
}
|
2028
|
+
if (SYSTEM_FONT.includes(lowerValue)) {
|
2029
|
+
return { font: { value: lowerValue, important } };
|
2030
|
+
}
|
2031
|
+
const properties = {
|
2032
|
+
...this.getFontStyle('normal', important),
|
2033
|
+
...this.getFontVariant('normal', important),
|
2034
|
+
...this.getFontWeight('normal', important),
|
2035
|
+
...this.getFontStretch('normal', important),
|
2036
|
+
...this.getLineHeight('normal', important)
|
2037
|
+
};
|
2038
|
+
const parts = value.replace(/ *\/ */g, '/').split(/ +/);
|
2039
|
+
for (let i = 0, max = parts.length; i < max; i++) {
|
2040
|
+
const part = parts[i];
|
2041
|
+
if (part.includes('/')) {
|
2042
|
+
const [size, height] = part.split('/');
|
2043
|
+
const fontSize = this.getFontSize(size, important);
|
2044
|
+
const lineHeight = this.getLineHeight(height, important);
|
2045
|
+
if (!fontSize || !lineHeight) {
|
2046
|
+
return null;
|
2047
|
+
}
|
2048
|
+
Object.assign(properties, fontSize, lineHeight);
|
2049
|
+
}
|
2050
|
+
else {
|
2051
|
+
const fontStyle = this.getFontStyle(part, important);
|
2052
|
+
const fontVariant = this.getFontVariant(part, important);
|
2053
|
+
const fontWeight = this.getFontWeight(part, important);
|
2054
|
+
const fontSize = this.getFontSize(part, important);
|
2055
|
+
const fontStretch = this.getFontStretch(part, important);
|
2056
|
+
if (fontStyle) {
|
2057
|
+
Object.assign(properties, fontStyle);
|
2058
|
+
}
|
2059
|
+
else if (fontVariant) {
|
2060
|
+
Object.assign(properties, fontVariant);
|
2061
|
+
}
|
2062
|
+
else if (fontWeight) {
|
2063
|
+
Object.assign(properties, fontWeight);
|
2064
|
+
}
|
2065
|
+
else if (fontSize) {
|
2066
|
+
Object.assign(properties, fontSize);
|
2067
|
+
}
|
2068
|
+
else if (fontStretch) {
|
2069
|
+
Object.assign(properties, fontStretch);
|
2070
|
+
}
|
2071
|
+
else {
|
2072
|
+
const fontFamilyValue = parts.slice(i).join(' ');
|
2073
|
+
const fontFamily = this.getFontFamily(fontFamilyValue, important);
|
2074
|
+
if (!fontFamily) {
|
2075
|
+
return null;
|
2076
|
+
}
|
2077
|
+
Object.assign(properties, fontFamily);
|
2078
|
+
break;
|
2079
|
+
}
|
2080
|
+
}
|
2081
|
+
}
|
2082
|
+
return properties;
|
2083
|
+
}
|
2084
|
+
/**
|
2085
|
+
* Returns font style.
|
2086
|
+
*
|
2087
|
+
* @param value Value.
|
2088
|
+
* @param important Important.
|
2089
|
+
* @returns Property values
|
2090
|
+
*/
|
2091
|
+
static getFontStyle(value, important) {
|
2092
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2093
|
+
if (variable) {
|
2094
|
+
return { 'font-style': { value: variable, important } };
|
2095
|
+
}
|
2096
|
+
const lowerValue = value.toLowerCase();
|
2097
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || FONT_STYLE.includes(lowerValue)) {
|
2098
|
+
return { 'font-style': { value: lowerValue, important } };
|
2099
|
+
}
|
2100
|
+
const parts = value.split(/ +/);
|
2101
|
+
if (parts.length === 2 && parts[0] === 'oblique') {
|
2102
|
+
const degree = CSSStyleDeclarationValueParser_1.default.getDegree(parts[1]);
|
2103
|
+
return degree ? { 'font-style': { value: lowerValue, important } } : null;
|
2104
|
+
}
|
2105
|
+
return null;
|
2106
|
+
}
|
2107
|
+
/**
|
2108
|
+
* Returns font variant.
|
2109
|
+
*
|
2110
|
+
* @param value Value.
|
2111
|
+
* @param important Important.
|
2112
|
+
* @returns Property values
|
2113
|
+
*/
|
2114
|
+
static getFontVariant(value, important) {
|
2115
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2116
|
+
if (variable) {
|
2117
|
+
return { 'font-variant': { value: variable, important } };
|
2118
|
+
}
|
2119
|
+
const lowerValue = value.toLowerCase();
|
2120
|
+
return CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) ||
|
2121
|
+
lowerValue === 'normal' ||
|
2122
|
+
lowerValue === 'small-caps'
|
2123
|
+
? { 'font-variant': { value: lowerValue, important } }
|
2124
|
+
: null;
|
2125
|
+
}
|
2126
|
+
/**
|
2127
|
+
* Returns font strech.
|
2128
|
+
*
|
2129
|
+
* @param value Value.
|
2130
|
+
* @param important Important.
|
2131
|
+
* @returns Property values
|
2132
|
+
*/
|
2133
|
+
static getFontStretch(value, important) {
|
2134
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2135
|
+
if (variable) {
|
2136
|
+
return { 'font-stretch': { value: variable, important } };
|
2137
|
+
}
|
2138
|
+
const lowerValue = value.toLowerCase();
|
2139
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || FONT_STRETCH.includes(lowerValue)) {
|
2140
|
+
return { 'font-stretch': { value: lowerValue, important } };
|
2141
|
+
}
|
2142
|
+
const percentage = CSSStyleDeclarationValueParser_1.default.getPercentage(value);
|
2143
|
+
return percentage ? { 'font-stretch': { value: percentage, important } } : null;
|
2144
|
+
}
|
2145
|
+
/**
|
2146
|
+
* Returns font weight.
|
2147
|
+
*
|
2148
|
+
* @param value Value.
|
2149
|
+
* @param important Important.
|
2150
|
+
* @returns Property values
|
2151
|
+
*/
|
2152
|
+
static getFontWeight(value, important) {
|
2153
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2154
|
+
if (variable) {
|
2155
|
+
return { 'font-weight': { value: variable, important } };
|
2156
|
+
}
|
2157
|
+
const lowerValue = value.toLowerCase();
|
2158
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || FONT_WEIGHT.includes(lowerValue)) {
|
2159
|
+
return { 'font-weight': { value: lowerValue, important } };
|
2160
|
+
}
|
2161
|
+
const integer = CSSStyleDeclarationValueParser_1.default.getInteger(value);
|
2162
|
+
return integer ? { 'font-weight': { value: integer, important } } : null;
|
2163
|
+
}
|
2164
|
+
/**
|
2165
|
+
* Returns font size.
|
2166
|
+
*
|
2167
|
+
* @param value Value.
|
2168
|
+
* @param important Important.
|
2169
|
+
* @returns Property values
|
2170
|
+
*/
|
2171
|
+
static getFontSize(value, important) {
|
2172
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2173
|
+
if (variable) {
|
2174
|
+
return { 'font-size': { value: variable, important } };
|
2175
|
+
}
|
2176
|
+
const lowerValue = value.toLowerCase();
|
2177
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || FONT_SIZE.includes(lowerValue)) {
|
2178
|
+
return { 'font-size': { value: lowerValue, important } };
|
2179
|
+
}
|
2180
|
+
const measurement = CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
2181
|
+
return measurement ? { 'font-size': { value: measurement, important } } : null;
|
2182
|
+
}
|
2183
|
+
/**
|
2184
|
+
* Returns line height.
|
2185
|
+
*
|
2186
|
+
* @param value Value.
|
2187
|
+
* @param important Important.
|
2188
|
+
* @returns Property values
|
2189
|
+
*/
|
2190
|
+
static getLineHeight(value, important) {
|
2191
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2192
|
+
if (variable) {
|
2193
|
+
return { 'line-height': { value: variable, important } };
|
2194
|
+
}
|
2195
|
+
const lowerValue = value.toLowerCase();
|
2196
|
+
if (CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) || lowerValue === 'normal') {
|
2197
|
+
return { 'line-height': { value: lowerValue, important } };
|
2198
|
+
}
|
2199
|
+
const lineHeight = CSSStyleDeclarationValueParser_1.default.getFloat(value) ||
|
2200
|
+
CSSStyleDeclarationValueParser_1.default.getMeasurement(value);
|
2201
|
+
return lineHeight ? { 'line-height': { value: lineHeight, important } } : null;
|
2202
|
+
}
|
2203
|
+
/**
|
2204
|
+
* Returns font family.
|
2205
|
+
*
|
2206
|
+
* @param value Value.
|
2207
|
+
* @param important Important.
|
2208
|
+
* @returns Property values
|
2209
|
+
*/
|
2210
|
+
static getFontFamily(value, important) {
|
2211
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2212
|
+
if (variable) {
|
2213
|
+
return { 'font-family': { value: variable, important } };
|
2214
|
+
}
|
2215
|
+
const globalValue = CSSStyleDeclarationValueParser_1.default.getGlobal(value);
|
2216
|
+
if (globalValue) {
|
2217
|
+
return { 'font-family': { value: globalValue, important } };
|
2218
|
+
}
|
2219
|
+
const parts = value.split(',');
|
2220
|
+
let parsedValue = '';
|
2221
|
+
let endWithApostroph = false;
|
2222
|
+
for (let i = 0, max = parts.length; i < max; i++) {
|
2223
|
+
let trimmedPart = parts[i].trim().replace(/'/g, '"');
|
2224
|
+
if (!trimmedPart) {
|
2225
|
+
return null;
|
2226
|
+
}
|
2227
|
+
if (trimmedPart.includes(' ')) {
|
2228
|
+
const apostrophCount = (trimmedPart.match(/"/g) || []).length;
|
2229
|
+
if ((trimmedPart[0] !== '"' || i !== 0) && apostrophCount !== 2 && apostrophCount !== 0) {
|
2230
|
+
return null;
|
2231
|
+
}
|
2232
|
+
if (trimmedPart[0] === '"' && trimmedPart[trimmedPart.length - 1] !== '"') {
|
2233
|
+
endWithApostroph = true;
|
2234
|
+
}
|
2235
|
+
else if (trimmedPart[0] !== '"' && trimmedPart[trimmedPart.length - 1] !== '"') {
|
2236
|
+
trimmedPart = `"${trimmedPart}"`;
|
2237
|
+
}
|
2238
|
+
}
|
2239
|
+
if (i > 0) {
|
2240
|
+
parsedValue += ', ';
|
2241
|
+
}
|
2242
|
+
parsedValue += trimmedPart;
|
2243
|
+
}
|
2244
|
+
if (endWithApostroph) {
|
2245
|
+
parsedValue += '"';
|
2246
|
+
}
|
2247
|
+
if (!parsedValue) {
|
2248
|
+
return null;
|
2249
|
+
}
|
2250
|
+
return {
|
2251
|
+
'font-family': {
|
2252
|
+
important,
|
2253
|
+
value: parsedValue
|
2254
|
+
}
|
2255
|
+
};
|
2256
|
+
}
|
2257
|
+
/**
|
2258
|
+
* Returns font family.
|
2259
|
+
*
|
2260
|
+
* @param value Value.
|
2261
|
+
* @param important Important.
|
2262
|
+
* @returns Property values
|
2263
|
+
*/
|
2264
|
+
static getTextTransform(value, important) {
|
2265
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2266
|
+
if (variable) {
|
2267
|
+
return { 'text-transform': { value: variable, important } };
|
2268
|
+
}
|
2269
|
+
const lowerValue = value.toLowerCase();
|
2270
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) ||
|
2271
|
+
(TEXT_TRANSFORM.includes(lowerValue) && lowerValue);
|
2272
|
+
if (parsedValue) {
|
2273
|
+
return {
|
2274
|
+
'text-transform': { value: parsedValue, important }
|
2275
|
+
};
|
2276
|
+
}
|
2277
|
+
return null;
|
2278
|
+
}
|
2279
|
+
/**
|
2280
|
+
* Returns visibility.
|
2281
|
+
*
|
2282
|
+
* @param value Value.
|
2283
|
+
* @param important Important.
|
2284
|
+
* @returns Property
|
2285
|
+
*/
|
2286
|
+
static getVisibility(value, important) {
|
2287
|
+
const variable = CSSStyleDeclarationValueParser_1.default.getVariable(value);
|
2288
|
+
if (variable) {
|
2289
|
+
return { visibility: { value: variable, important } };
|
2290
|
+
}
|
2291
|
+
const lowerValue = value.toLowerCase();
|
2292
|
+
const parsedValue = CSSStyleDeclarationValueParser_1.default.getGlobal(lowerValue) ||
|
2293
|
+
(VISIBILITY.includes(lowerValue) && lowerValue);
|
2294
|
+
if (parsedValue) {
|
2295
|
+
return {
|
2296
|
+
visibility: { value: parsedValue, important }
|
2297
|
+
};
|
2298
|
+
}
|
2299
|
+
return null;
|
2300
|
+
}
|
2301
|
+
}
|
2302
|
+
exports.default = CSSStyleDeclarationPropertySetParser;
|
2303
|
+
//# sourceMappingURL=CSSStyleDeclarationPropertySetParser.js.map
|