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,743 @@
|
|
1
|
+
import CSSStyleDeclarationValueParser from './CSSStyleDeclarationValueParser';
|
2
|
+
import ICSSStyleDeclarationPropertyValue from './ICSSStyleDeclarationPropertyValue';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Computed style property parser.
|
6
|
+
*/
|
7
|
+
export default class CSSStyleDeclarationPropertyGetParser {
|
8
|
+
/**
|
9
|
+
* Returns margin.
|
10
|
+
*
|
11
|
+
* @param properties Properties.
|
12
|
+
* @returns Property value
|
13
|
+
*/
|
14
|
+
public static getMargin(properties: {
|
15
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
16
|
+
}): ICSSStyleDeclarationPropertyValue {
|
17
|
+
return this.getPaddingLikeProperty(
|
18
|
+
['margin-top', 'margin-right', 'margin-bottom', 'margin-left'],
|
19
|
+
properties
|
20
|
+
);
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Returns padding.
|
25
|
+
*
|
26
|
+
* @param properties Properties.
|
27
|
+
* @returns Property value
|
28
|
+
*/
|
29
|
+
public static getPadding(properties: {
|
30
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
31
|
+
}): ICSSStyleDeclarationPropertyValue {
|
32
|
+
return this.getPaddingLikeProperty(
|
33
|
+
['padding-top', 'padding-right', 'padding-bottom', 'padding-left'],
|
34
|
+
properties
|
35
|
+
);
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Returns border.
|
40
|
+
*
|
41
|
+
* @param properties Properties.
|
42
|
+
* @returns Property value
|
43
|
+
*/
|
44
|
+
public static getBorder(properties: {
|
45
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
46
|
+
}): ICSSStyleDeclarationPropertyValue {
|
47
|
+
if (
|
48
|
+
!properties['border-top-width']?.value ||
|
49
|
+
properties['border-top-width']?.value !== properties['border-right-width']?.value ||
|
50
|
+
properties['border-top-width']?.value !== properties['border-bottom-width']?.value ||
|
51
|
+
properties['border-top-width']?.value !== properties['border-left-width']?.value ||
|
52
|
+
!properties['border-top-style']?.value ||
|
53
|
+
properties['border-top-style']?.value !== properties['border-right-style']?.value ||
|
54
|
+
properties['border-top-style']?.value !== properties['border-bottom-style']?.value ||
|
55
|
+
properties['border-top-style']?.value !== properties['border-left-style']?.value ||
|
56
|
+
!properties['border-top-color']?.value ||
|
57
|
+
properties['border-top-color']?.value !== properties['border-right-color']?.value ||
|
58
|
+
properties['border-top-color']?.value !== properties['border-bottom-color']?.value ||
|
59
|
+
properties['border-top-color']?.value !== properties['border-left-color']?.value ||
|
60
|
+
!properties['border-image-source']?.value ||
|
61
|
+
!properties['border-image-slice']?.value ||
|
62
|
+
!properties['border-image-width']?.value ||
|
63
|
+
!properties['border-image-outset']?.value ||
|
64
|
+
!properties['border-image-repeat']?.value
|
65
|
+
) {
|
66
|
+
return null;
|
67
|
+
}
|
68
|
+
|
69
|
+
const important =
|
70
|
+
properties['border-top-width'].important &&
|
71
|
+
properties['border-right-width'].important &&
|
72
|
+
properties['border-bottom-width'].important &&
|
73
|
+
properties['border-left-width'].important &&
|
74
|
+
properties['border-top-style'].important &&
|
75
|
+
properties['border-right-style'].important &&
|
76
|
+
properties['border-bottom-style'].important &&
|
77
|
+
properties['border-left-style'].important &&
|
78
|
+
properties['border-top-color'].important &&
|
79
|
+
properties['border-right-color'].important &&
|
80
|
+
properties['border-bottom-color'].important &&
|
81
|
+
properties['border-left-color'].important &&
|
82
|
+
properties['border-image-source'].important &&
|
83
|
+
properties['border-image-slice'].important &&
|
84
|
+
properties['border-image-width'].important &&
|
85
|
+
properties['border-image-outset'].important &&
|
86
|
+
properties['border-image-repeat'].important;
|
87
|
+
|
88
|
+
if (
|
89
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties['border-top-width'].value) ||
|
90
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties['border-top-style'].value) ||
|
91
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties['border-top-color'].value) ||
|
92
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
93
|
+
properties['border-image-source'].value
|
94
|
+
) ||
|
95
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
96
|
+
properties['border-image-slice'].value
|
97
|
+
) ||
|
98
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
99
|
+
properties['border-image-width'].value
|
100
|
+
) ||
|
101
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
102
|
+
properties['border-image-outset'].value
|
103
|
+
) ||
|
104
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties['border-image-repeat'].value)
|
105
|
+
) {
|
106
|
+
if (
|
107
|
+
properties['border-top-width'].value !== properties['border-top-style'].value ||
|
108
|
+
properties['border-top-width'].value !== properties['border-top-color'].value ||
|
109
|
+
properties['border-top-width'].value !== properties['border-image-source'].value ||
|
110
|
+
properties['border-top-width'].value !== properties['border-image-slice'].value ||
|
111
|
+
properties['border-top-width'].value !== properties['border-image-width'].value ||
|
112
|
+
properties['border-top-width'].value !== properties['border-image-outset'].value ||
|
113
|
+
properties['border-top-width'].value !== properties['border-image-repeat'].value
|
114
|
+
) {
|
115
|
+
return null;
|
116
|
+
}
|
117
|
+
|
118
|
+
return {
|
119
|
+
important,
|
120
|
+
value: properties['border-top-width'].value
|
121
|
+
};
|
122
|
+
}
|
123
|
+
|
124
|
+
const values = [];
|
125
|
+
|
126
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties['border-top-width'].value)) {
|
127
|
+
values.push(properties['border-top-width'].value);
|
128
|
+
}
|
129
|
+
|
130
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties['border-top-style'].value)) {
|
131
|
+
values.push(properties['border-top-style'].value);
|
132
|
+
}
|
133
|
+
|
134
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties['border-top-color'].value)) {
|
135
|
+
values.push(properties['border-top-color'].value);
|
136
|
+
}
|
137
|
+
|
138
|
+
return {
|
139
|
+
important,
|
140
|
+
value: values.join(' ')
|
141
|
+
};
|
142
|
+
}
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Returns border.
|
146
|
+
*
|
147
|
+
* @param properties Properties.
|
148
|
+
* @returns Property value
|
149
|
+
*/
|
150
|
+
public static getBorderTop(properties: {
|
151
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
152
|
+
}): ICSSStyleDeclarationPropertyValue {
|
153
|
+
return this.getBorderTopRightBottomLeft('top', properties);
|
154
|
+
}
|
155
|
+
|
156
|
+
/**
|
157
|
+
* Returns border.
|
158
|
+
*
|
159
|
+
* @param properties Properties.
|
160
|
+
* @returns Property value
|
161
|
+
*/
|
162
|
+
public static getBorderRight(properties: {
|
163
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
164
|
+
}): ICSSStyleDeclarationPropertyValue {
|
165
|
+
return this.getBorderTopRightBottomLeft('right', properties);
|
166
|
+
}
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Returns border.
|
170
|
+
*
|
171
|
+
* @param properties Properties.
|
172
|
+
* @returns Property value
|
173
|
+
*/
|
174
|
+
public static getBorderBottom(properties: {
|
175
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
176
|
+
}): ICSSStyleDeclarationPropertyValue {
|
177
|
+
return this.getBorderTopRightBottomLeft('bottom', properties);
|
178
|
+
}
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Returns border.
|
182
|
+
*
|
183
|
+
* @param properties Properties.
|
184
|
+
* @returns Property value
|
185
|
+
*/
|
186
|
+
public static getBorderLeft(properties: {
|
187
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
188
|
+
}): ICSSStyleDeclarationPropertyValue {
|
189
|
+
return this.getBorderTopRightBottomLeft('left', properties);
|
190
|
+
}
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Returns border.
|
194
|
+
*
|
195
|
+
* @param properties Properties.
|
196
|
+
* @returns Property value
|
197
|
+
*/
|
198
|
+
public static getBorderColor(properties: {
|
199
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
200
|
+
}): ICSSStyleDeclarationPropertyValue {
|
201
|
+
return this.getPaddingLikeProperty(
|
202
|
+
['border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color'],
|
203
|
+
properties
|
204
|
+
);
|
205
|
+
}
|
206
|
+
|
207
|
+
/**
|
208
|
+
* Returns border.
|
209
|
+
*
|
210
|
+
* @param properties Properties.
|
211
|
+
* @returns Property value
|
212
|
+
*/
|
213
|
+
public static getBorderWidth(properties: {
|
214
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
215
|
+
}): ICSSStyleDeclarationPropertyValue {
|
216
|
+
return this.getPaddingLikeProperty(
|
217
|
+
['border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width'],
|
218
|
+
properties
|
219
|
+
);
|
220
|
+
}
|
221
|
+
|
222
|
+
/**
|
223
|
+
* Returns border.
|
224
|
+
*
|
225
|
+
* @param properties Properties.
|
226
|
+
* @returns Property value
|
227
|
+
*/
|
228
|
+
public static getBorderStyle(properties: {
|
229
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
230
|
+
}): ICSSStyleDeclarationPropertyValue {
|
231
|
+
return this.getPaddingLikeProperty(
|
232
|
+
['border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style'],
|
233
|
+
properties
|
234
|
+
);
|
235
|
+
}
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Returns border radius.
|
239
|
+
*
|
240
|
+
* @param properties Properties.
|
241
|
+
* @returns Property value
|
242
|
+
*/
|
243
|
+
public static getBorderRadius(properties: {
|
244
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
245
|
+
}): ICSSStyleDeclarationPropertyValue {
|
246
|
+
return this.getPaddingLikeProperty(
|
247
|
+
[
|
248
|
+
'border-top-left-radius',
|
249
|
+
'border-top-right-radius',
|
250
|
+
'border-bottom-right-radius',
|
251
|
+
'border-bottom-left-radius'
|
252
|
+
],
|
253
|
+
properties
|
254
|
+
);
|
255
|
+
}
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Returns border image.
|
259
|
+
*
|
260
|
+
* @param properties Properties.
|
261
|
+
* @returns Property value
|
262
|
+
*/
|
263
|
+
public static getBorderImage(properties: {
|
264
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
265
|
+
}): ICSSStyleDeclarationPropertyValue {
|
266
|
+
if (
|
267
|
+
!properties['border-image-source']?.value ||
|
268
|
+
!properties['border-image-slice']?.value ||
|
269
|
+
!properties['border-image-width']?.value ||
|
270
|
+
!properties['border-image-outset']?.value ||
|
271
|
+
!properties['border-image-repeat']?.value
|
272
|
+
) {
|
273
|
+
return null;
|
274
|
+
}
|
275
|
+
|
276
|
+
const important =
|
277
|
+
properties['border-image-source'].important &&
|
278
|
+
properties['border-image-slice'].important &&
|
279
|
+
properties['border-image-width'].important &&
|
280
|
+
properties['border-image-outset'].important &&
|
281
|
+
properties['border-image-repeat'].important;
|
282
|
+
|
283
|
+
if (
|
284
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['border-image-source'].value) ||
|
285
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['border-image-slice'].value) ||
|
286
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['border-image-width'].value) ||
|
287
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['border-image-outset'].value) ||
|
288
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['border-image-repeat'].value)
|
289
|
+
) {
|
290
|
+
if (
|
291
|
+
properties['border-image-source'].value !== properties['border-image-slice'].value ||
|
292
|
+
properties['border-image-source'].value !== properties['border-image-width'].value ||
|
293
|
+
properties['border-image-source'].value !== properties['border-image-outset'].value ||
|
294
|
+
properties['border-image-source'].value !== properties['border-image-repeat'].value
|
295
|
+
) {
|
296
|
+
return null;
|
297
|
+
}
|
298
|
+
return {
|
299
|
+
important,
|
300
|
+
value: properties['border-image-source'].value
|
301
|
+
};
|
302
|
+
}
|
303
|
+
|
304
|
+
return {
|
305
|
+
important,
|
306
|
+
value: `${properties['border-image-source'].value} ${properties['border-image-slice'].value} / ${properties['border-image-width'].value} / ${properties['border-image-outset'].value} ${properties['border-image-repeat'].value}`
|
307
|
+
};
|
308
|
+
}
|
309
|
+
|
310
|
+
/**
|
311
|
+
* Returns background.
|
312
|
+
*
|
313
|
+
* @param properties Properties.
|
314
|
+
* @returns Property value
|
315
|
+
*/
|
316
|
+
public static getBackground(properties: {
|
317
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
318
|
+
}): ICSSStyleDeclarationPropertyValue {
|
319
|
+
if (
|
320
|
+
!properties['background-image']?.value ||
|
321
|
+
!properties['background-repeat']?.value ||
|
322
|
+
!properties['background-attachment']?.value ||
|
323
|
+
!properties['background-position-x']?.value ||
|
324
|
+
!properties['background-position-y']?.value ||
|
325
|
+
!properties['background-color']?.value ||
|
326
|
+
!properties['background-size']?.value ||
|
327
|
+
!properties['background-origin']?.value ||
|
328
|
+
!properties['background-clip']?.value
|
329
|
+
) {
|
330
|
+
return null;
|
331
|
+
}
|
332
|
+
|
333
|
+
const important =
|
334
|
+
properties['background-image'].important &&
|
335
|
+
properties['background-repeat'].important &&
|
336
|
+
properties['background-attachment'].important &&
|
337
|
+
properties['background-position-x'].important &&
|
338
|
+
properties['background-position-y'].important &&
|
339
|
+
properties['background-color'].important &&
|
340
|
+
properties['background-size'].important &&
|
341
|
+
properties['background-origin'].important &&
|
342
|
+
properties['background-clip'].important;
|
343
|
+
|
344
|
+
if (
|
345
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties['background-image'].value) ||
|
346
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
347
|
+
properties['background-repeat'].value
|
348
|
+
) ||
|
349
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
350
|
+
properties['background-attachment'].value
|
351
|
+
) ||
|
352
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
353
|
+
properties['background-position-x'].value
|
354
|
+
) ||
|
355
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
356
|
+
properties['background-position-y'].value
|
357
|
+
) ||
|
358
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties['background-color'].value) ||
|
359
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties['background-size'].value) ||
|
360
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
361
|
+
properties['background-origin'].value
|
362
|
+
) ||
|
363
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties['background-clip'].value)
|
364
|
+
) {
|
365
|
+
if (
|
366
|
+
properties['background-image'].value !== properties['background-repeat'].value ||
|
367
|
+
properties['background-image'].value !== properties['background-attachment'].value ||
|
368
|
+
properties['background-image'].value !== properties['background-position-x'].value ||
|
369
|
+
properties['background-image'].value !== properties['background-position-y'].value ||
|
370
|
+
properties['background-image'].value !== properties['background-color'].value ||
|
371
|
+
properties['background-image'].value !== properties['background-size'].value ||
|
372
|
+
properties['background-image'].value !== properties['background-origin'].value ||
|
373
|
+
properties['background-image'].value !== properties['background-clip'].value
|
374
|
+
) {
|
375
|
+
return null;
|
376
|
+
}
|
377
|
+
|
378
|
+
return {
|
379
|
+
important,
|
380
|
+
value: properties['background-image'].value
|
381
|
+
};
|
382
|
+
}
|
383
|
+
|
384
|
+
const values = [];
|
385
|
+
|
386
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties['background-image'].value)) {
|
387
|
+
values.push(properties['background-image'].value);
|
388
|
+
}
|
389
|
+
|
390
|
+
if (
|
391
|
+
!CSSStyleDeclarationValueParser.getInitial(properties['background-position-x'].value) &&
|
392
|
+
!CSSStyleDeclarationValueParser.getInitial(properties['background-position-y'].value) &&
|
393
|
+
!CSSStyleDeclarationValueParser.getInitial(properties['background-size'].value)
|
394
|
+
) {
|
395
|
+
values.push(
|
396
|
+
`${properties['background-position-x'].value} ${properties['background-position-y'].value} / ${properties['background-size'].value}`
|
397
|
+
);
|
398
|
+
} else if (
|
399
|
+
!CSSStyleDeclarationValueParser.getInitial(properties['background-position-x'].value) &&
|
400
|
+
!CSSStyleDeclarationValueParser.getInitial(properties['background-position-y'].value)
|
401
|
+
) {
|
402
|
+
values.push(
|
403
|
+
`${properties['background-position-x'].value} ${properties['background-position-y'].value}`
|
404
|
+
);
|
405
|
+
}
|
406
|
+
|
407
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties['background-repeat'].value)) {
|
408
|
+
values.push(properties['background-repeat'].value);
|
409
|
+
}
|
410
|
+
|
411
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties['background-attachment'].value)) {
|
412
|
+
values.push(properties['background-attachment'].value);
|
413
|
+
}
|
414
|
+
|
415
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties['background-origin'].value)) {
|
416
|
+
values.push(properties['background-origin'].value);
|
417
|
+
}
|
418
|
+
|
419
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties['background-clip'].value)) {
|
420
|
+
values.push(properties['background-clip'].value);
|
421
|
+
}
|
422
|
+
|
423
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties['background-color'].value)) {
|
424
|
+
values.push(properties['background-color'].value);
|
425
|
+
}
|
426
|
+
|
427
|
+
return {
|
428
|
+
important,
|
429
|
+
value: values.join(' ')
|
430
|
+
};
|
431
|
+
}
|
432
|
+
|
433
|
+
/**
|
434
|
+
* Returns background position.
|
435
|
+
*
|
436
|
+
* @param properties Properties.
|
437
|
+
* @returns Property value
|
438
|
+
*/
|
439
|
+
public static getBackgroundPosition(properties: {
|
440
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
441
|
+
}): ICSSStyleDeclarationPropertyValue {
|
442
|
+
if (
|
443
|
+
!properties['background-position-x']?.value ||
|
444
|
+
!properties['background-position-y']?.value
|
445
|
+
) {
|
446
|
+
return null;
|
447
|
+
}
|
448
|
+
|
449
|
+
const important =
|
450
|
+
properties['background-position-x'].important &&
|
451
|
+
properties['background-position-y'].important;
|
452
|
+
if (
|
453
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['background-position-x'].value) ||
|
454
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['background-position-y'].value)
|
455
|
+
) {
|
456
|
+
if (properties['background-position-x'].value !== properties['background-position-y'].value) {
|
457
|
+
return null;
|
458
|
+
}
|
459
|
+
|
460
|
+
return {
|
461
|
+
important,
|
462
|
+
value: properties['background-position-x'].value
|
463
|
+
};
|
464
|
+
}
|
465
|
+
|
466
|
+
const positionX = properties['background-position-x'].value.replace(/ *, */g, ',').split(',');
|
467
|
+
const positionY = properties['background-position-y'].value.replace(/ *, */g, ',').split(',');
|
468
|
+
const parts = [];
|
469
|
+
|
470
|
+
for (let i = 0; i < positionX.length; i++) {
|
471
|
+
parts.push(`${positionX[i]} ${positionY[i]}`);
|
472
|
+
}
|
473
|
+
|
474
|
+
return {
|
475
|
+
important,
|
476
|
+
value: parts.join(', ')
|
477
|
+
};
|
478
|
+
}
|
479
|
+
|
480
|
+
/**
|
481
|
+
* Returns flex.
|
482
|
+
*
|
483
|
+
* @param properties Properties.
|
484
|
+
* @returns Property value
|
485
|
+
*/
|
486
|
+
public static getFlex(properties: {
|
487
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
488
|
+
}): ICSSStyleDeclarationPropertyValue {
|
489
|
+
if (
|
490
|
+
!properties['flex-grow']?.value ||
|
491
|
+
!properties['flex-shrink']?.value ||
|
492
|
+
!properties['flex-basis']?.value
|
493
|
+
) {
|
494
|
+
return null;
|
495
|
+
}
|
496
|
+
|
497
|
+
const important =
|
498
|
+
properties['flex-grow'].important &&
|
499
|
+
properties['flex-shrink'].important &&
|
500
|
+
properties['flex-basis'].important;
|
501
|
+
|
502
|
+
if (
|
503
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['flex-grow'].value) ||
|
504
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['flex-shrink'].value) ||
|
505
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['flex-basis'].value)
|
506
|
+
) {
|
507
|
+
if (
|
508
|
+
properties['flex-grow'].value !== properties['flex-shrink'].value ||
|
509
|
+
properties['flex-grow'].value !== properties['flex-basis'].value
|
510
|
+
) {
|
511
|
+
return null;
|
512
|
+
}
|
513
|
+
|
514
|
+
return {
|
515
|
+
important,
|
516
|
+
value: properties['flex-grow'].value
|
517
|
+
};
|
518
|
+
}
|
519
|
+
|
520
|
+
return {
|
521
|
+
important,
|
522
|
+
value: `${properties['flex-grow'].value} ${properties['flex-shrink'].value} ${properties['flex-basis'].value}`
|
523
|
+
};
|
524
|
+
}
|
525
|
+
|
526
|
+
/**
|
527
|
+
* Returns flex.
|
528
|
+
*
|
529
|
+
* @param properties Properties.
|
530
|
+
* @returns Property value
|
531
|
+
*/
|
532
|
+
public static getFont(properties: {
|
533
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
534
|
+
}): ICSSStyleDeclarationPropertyValue {
|
535
|
+
if (
|
536
|
+
!properties['font-size']?.value ||
|
537
|
+
!properties['font-family']?.value ||
|
538
|
+
!properties['font-weight']?.value ||
|
539
|
+
!properties['font-style']?.value ||
|
540
|
+
!properties['font-variant']?.value ||
|
541
|
+
!properties['font-stretch']?.value ||
|
542
|
+
!properties['line-height']?.value
|
543
|
+
) {
|
544
|
+
return null;
|
545
|
+
}
|
546
|
+
|
547
|
+
const important =
|
548
|
+
properties['font-size'].important &&
|
549
|
+
properties['font-family'].important &&
|
550
|
+
properties['font-weight'].important &&
|
551
|
+
properties['font-style'].important &&
|
552
|
+
properties['font-variant'].important &&
|
553
|
+
properties['font-stretch'].important &&
|
554
|
+
properties['line-height'].important;
|
555
|
+
|
556
|
+
if (
|
557
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['font-size'].value) ||
|
558
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['font-family'].value) ||
|
559
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['font-weight'].value) ||
|
560
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['font-style'].value) ||
|
561
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['font-variant'].value) ||
|
562
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['font-stretch'].value) ||
|
563
|
+
CSSStyleDeclarationValueParser.getGlobal(properties['line-height'].value)
|
564
|
+
) {
|
565
|
+
if (
|
566
|
+
properties['font-size'].value !== properties['font-family'].value ||
|
567
|
+
properties['font-size'].value !== properties['font-weight'].value ||
|
568
|
+
properties['font-size'].value !== properties['font-style'].value ||
|
569
|
+
properties['font-size'].value !== properties['font-variant'].value ||
|
570
|
+
properties['font-size'].value !== properties['font-stretch'].value ||
|
571
|
+
properties['font-size'].value !== properties['line-height'].value
|
572
|
+
) {
|
573
|
+
return null;
|
574
|
+
}
|
575
|
+
|
576
|
+
return {
|
577
|
+
important,
|
578
|
+
value: properties['font-size'].value
|
579
|
+
};
|
580
|
+
}
|
581
|
+
|
582
|
+
const values = [];
|
583
|
+
|
584
|
+
if (properties['font-style'].value !== 'normal') {
|
585
|
+
values.push(properties['font-style'].value);
|
586
|
+
}
|
587
|
+
if (properties['font-variant'].value !== 'normal') {
|
588
|
+
values.push(properties['font-variant'].value);
|
589
|
+
}
|
590
|
+
if (properties['font-weight'].value !== 'normal') {
|
591
|
+
values.push(properties['font-weight'].value);
|
592
|
+
}
|
593
|
+
if (properties['font-stretch'].value !== 'normal') {
|
594
|
+
values.push(properties['font-stretch'].value);
|
595
|
+
}
|
596
|
+
|
597
|
+
if (properties['line-height'].value !== 'normal') {
|
598
|
+
values.push(`${properties['font-size'].value} / ${properties['line-height'].value}`);
|
599
|
+
} else {
|
600
|
+
values.push(properties['font-size'].value);
|
601
|
+
}
|
602
|
+
|
603
|
+
values.push(properties['font-family'].value);
|
604
|
+
|
605
|
+
return {
|
606
|
+
important,
|
607
|
+
value: values.join(' ')
|
608
|
+
};
|
609
|
+
}
|
610
|
+
|
611
|
+
/**
|
612
|
+
* Returns border.
|
613
|
+
*
|
614
|
+
* @param properties Properties.
|
615
|
+
* @param position
|
616
|
+
* @returns Property value
|
617
|
+
*/
|
618
|
+
private static getBorderTopRightBottomLeft(
|
619
|
+
position: 'top' | 'right' | 'bottom' | 'left',
|
620
|
+
properties: {
|
621
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
622
|
+
}
|
623
|
+
): ICSSStyleDeclarationPropertyValue {
|
624
|
+
if (
|
625
|
+
!properties[`border-${position}-width`]?.value ||
|
626
|
+
!properties[`border-${position}-style`]?.value ||
|
627
|
+
!properties[`border-${position}-color`]?.value
|
628
|
+
) {
|
629
|
+
return null;
|
630
|
+
}
|
631
|
+
|
632
|
+
const important =
|
633
|
+
properties[`border-${position}-width`].important &&
|
634
|
+
properties[`border-${position}-style`].important &&
|
635
|
+
properties[`border-${position}-color`].important;
|
636
|
+
|
637
|
+
if (
|
638
|
+
CSSStyleDeclarationValueParser.getGlobalExceptInitial(
|
639
|
+
properties[`border-${position}-width`].value
|
640
|
+
) &&
|
641
|
+
properties[`border-${position}-width`].value ===
|
642
|
+
properties[`border-${position}-style`].value &&
|
643
|
+
properties[`border-${position}-width`].value === properties[`border-${position}-color`].value
|
644
|
+
) {
|
645
|
+
return {
|
646
|
+
important,
|
647
|
+
value: properties[`border-${position}-width`].value
|
648
|
+
};
|
649
|
+
}
|
650
|
+
|
651
|
+
const values = [];
|
652
|
+
|
653
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties[`border-${position}-width`].value)) {
|
654
|
+
values.push(properties[`border-${position}-width`].value);
|
655
|
+
}
|
656
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties[`border-${position}-style`]?.value)) {
|
657
|
+
values.push(properties[`border-${position}-style`].value);
|
658
|
+
}
|
659
|
+
if (!CSSStyleDeclarationValueParser.getInitial(properties[`border-${position}-color`]?.value)) {
|
660
|
+
values.push(properties[`border-${position}-color`].value);
|
661
|
+
}
|
662
|
+
|
663
|
+
return {
|
664
|
+
important,
|
665
|
+
value: values.join(' ')
|
666
|
+
};
|
667
|
+
}
|
668
|
+
|
669
|
+
/**
|
670
|
+
* Returns a padding like property.
|
671
|
+
*
|
672
|
+
* @param properties Properties.
|
673
|
+
* @param position
|
674
|
+
* @param propertyNames
|
675
|
+
* @returns Property value
|
676
|
+
*/
|
677
|
+
private static getPaddingLikeProperty(
|
678
|
+
propertyNames: [string, string, string, string],
|
679
|
+
properties: {
|
680
|
+
[k: string]: ICSSStyleDeclarationPropertyValue;
|
681
|
+
}
|
682
|
+
): ICSSStyleDeclarationPropertyValue {
|
683
|
+
if (
|
684
|
+
!properties[propertyNames[0]]?.value ||
|
685
|
+
!properties[propertyNames[1]]?.value ||
|
686
|
+
!properties[propertyNames[2]]?.value ||
|
687
|
+
!properties[propertyNames[3]]?.value
|
688
|
+
) {
|
689
|
+
return null;
|
690
|
+
}
|
691
|
+
|
692
|
+
const important =
|
693
|
+
properties[propertyNames[0]].important &&
|
694
|
+
properties[propertyNames[1]].important &&
|
695
|
+
properties[propertyNames[2]].important &&
|
696
|
+
properties[propertyNames[3]].important;
|
697
|
+
|
698
|
+
if (
|
699
|
+
CSSStyleDeclarationValueParser.getGlobal(properties[propertyNames[0]].value) ||
|
700
|
+
CSSStyleDeclarationValueParser.getGlobal(properties[propertyNames[1]].value) ||
|
701
|
+
CSSStyleDeclarationValueParser.getGlobal(properties[propertyNames[2]].value) ||
|
702
|
+
CSSStyleDeclarationValueParser.getGlobal(properties[propertyNames[3]].value)
|
703
|
+
) {
|
704
|
+
if (
|
705
|
+
properties[propertyNames[0]].value !== properties[propertyNames[1]].value ||
|
706
|
+
properties[propertyNames[0]].value !== properties[propertyNames[2]].value ||
|
707
|
+
properties[propertyNames[0]].value !== properties[propertyNames[3]].value
|
708
|
+
) {
|
709
|
+
return null;
|
710
|
+
}
|
711
|
+
return {
|
712
|
+
important,
|
713
|
+
value: properties[propertyNames[0]].value
|
714
|
+
};
|
715
|
+
}
|
716
|
+
|
717
|
+
const values = [properties[propertyNames[0]].value];
|
718
|
+
|
719
|
+
if (
|
720
|
+
properties[propertyNames[1]].value !== properties[propertyNames[0]].value ||
|
721
|
+
properties[propertyNames[2]].value !== properties[propertyNames[0]].value ||
|
722
|
+
properties[propertyNames[3]].value !== properties[propertyNames[1]].value
|
723
|
+
) {
|
724
|
+
values.push(properties[propertyNames[1]].value);
|
725
|
+
}
|
726
|
+
|
727
|
+
if (
|
728
|
+
properties[propertyNames[2]].value !== properties[propertyNames[0]].value ||
|
729
|
+
properties[propertyNames[3]].value !== properties[propertyNames[1]].value
|
730
|
+
) {
|
731
|
+
values.push(properties[propertyNames[2]].value);
|
732
|
+
}
|
733
|
+
|
734
|
+
if (properties[propertyNames[3]].value !== properties[propertyNames[1]].value) {
|
735
|
+
values.push(properties[propertyNames[3]].value);
|
736
|
+
}
|
737
|
+
|
738
|
+
return {
|
739
|
+
important,
|
740
|
+
value: values.join(' ')
|
741
|
+
};
|
742
|
+
}
|
743
|
+
}
|