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
package/src/nodes/node/Node.ts
CHANGED
@@ -21,14 +21,18 @@ export default class Node extends EventTarget implements INode {
|
|
21
21
|
|
22
22
|
// Public properties
|
23
23
|
public static readonly ELEMENT_NODE = NodeTypeEnum.elementNode;
|
24
|
+
public static readonly ATTRIBUTE_NODE = NodeTypeEnum.attributeNode;
|
24
25
|
public static readonly TEXT_NODE = NodeTypeEnum.textNode;
|
26
|
+
public static readonly CDATA_SECTION_NODE = NodeTypeEnum.cdataSectionNode;
|
25
27
|
public static readonly COMMENT_NODE = NodeTypeEnum.commentNode;
|
26
28
|
public static readonly DOCUMENT_NODE = NodeTypeEnum.documentNode;
|
27
29
|
public static readonly DOCUMENT_TYPE_NODE = NodeTypeEnum.documentTypeNode;
|
28
30
|
public static readonly DOCUMENT_FRAGMENT_NODE = NodeTypeEnum.documentFragmentNode;
|
29
31
|
public static readonly PROCESSING_INSTRUCTION_NODE = NodeTypeEnum.processingInstructionNode;
|
30
32
|
public readonly ELEMENT_NODE = NodeTypeEnum.elementNode;
|
33
|
+
public readonly ATTRIBUTE_NODE = NodeTypeEnum.attributeNode;
|
31
34
|
public readonly TEXT_NODE = NodeTypeEnum.textNode;
|
35
|
+
public readonly CDATA_SECTION_NODE = NodeTypeEnum.cdataSectionNode;
|
32
36
|
public readonly COMMENT_NODE = NodeTypeEnum.commentNode;
|
33
37
|
public readonly DOCUMENT_NODE = NodeTypeEnum.documentNode;
|
34
38
|
public readonly DOCUMENT_TYPE_NODE = NodeTypeEnum.documentTypeNode;
|
@@ -58,16 +62,18 @@ export default class Node extends EventTarget implements INode {
|
|
58
62
|
* @returns Text content.
|
59
63
|
*/
|
60
64
|
public get textContent(): string {
|
65
|
+
// Sub-classes should implement this method.
|
61
66
|
return null;
|
62
67
|
}
|
63
68
|
|
64
69
|
/**
|
65
70
|
* Sets text content.
|
66
71
|
*
|
67
|
-
* @param
|
72
|
+
* @param _textContent Text content.
|
68
73
|
*/
|
69
74
|
public set textContent(_textContent) {
|
70
75
|
// Do nothing.
|
76
|
+
// Sub-classes should implement this method.
|
71
77
|
}
|
72
78
|
|
73
79
|
/**
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import CSSStyleDeclaration from '../../css/CSSStyleDeclaration';
|
1
|
+
import CSSStyleDeclaration from '../../css/declaration/CSSStyleDeclaration';
|
2
2
|
import Element from '../element/Element';
|
3
3
|
import ISVGElement from './ISVGElement';
|
4
4
|
import ISVGSVGElement from './ISVGSVGElement';
|
5
|
-
import
|
5
|
+
import IAttr from '../attr/IAttr';
|
6
6
|
|
7
7
|
/**
|
8
8
|
* SVG Element.
|
@@ -59,7 +59,7 @@ export default class SVGElement extends Element implements ISVGElement {
|
|
59
59
|
*/
|
60
60
|
public get style(): CSSStyleDeclaration {
|
61
61
|
if (!this._style) {
|
62
|
-
this._style = new CSSStyleDeclaration(this
|
62
|
+
this._style = new CSSStyleDeclaration(this);
|
63
63
|
}
|
64
64
|
return this._style;
|
65
65
|
}
|
@@ -71,7 +71,7 @@ export default class SVGElement extends Element implements ISVGElement {
|
|
71
71
|
* @param attribute Attribute.
|
72
72
|
* @returns Replaced attribute.
|
73
73
|
*/
|
74
|
-
public setAttributeNode(attribute:
|
74
|
+
public setAttributeNode(attribute: IAttr): IAttr {
|
75
75
|
const replacedAttribute = super.setAttributeNode(attribute);
|
76
76
|
|
77
77
|
if (attribute.name === 'style' && this._style) {
|
@@ -87,7 +87,7 @@ export default class SVGElement extends Element implements ISVGElement {
|
|
87
87
|
* @override
|
88
88
|
* @param attribute Attribute.
|
89
89
|
*/
|
90
|
-
public removeAttributeNode(attribute:
|
90
|
+
public removeAttributeNode(attribute: IAttr): void {
|
91
91
|
super.removeAttributeNode(attribute);
|
92
92
|
|
93
93
|
if (attribute.name === 'style' && this._style) {
|
package/src/window/IWindow.ts
CHANGED
@@ -11,7 +11,6 @@ import Element from '../nodes/element/Element';
|
|
11
11
|
import HTMLTemplateElement from '../nodes/html-template-element/HTMLTemplateElement';
|
12
12
|
import HTMLFormElement from '../nodes/html-form-element/HTMLFormElement';
|
13
13
|
import HTMLElement from '../nodes/html-element/HTMLElement';
|
14
|
-
import IHTMLElement from '../nodes/html-element/IHTMLElement';
|
15
14
|
import HTMLUnknownElement from '../nodes/html-unknown-element/HTMLUnknownElement';
|
16
15
|
import HTMLInputElement from '../nodes/html-input-element/HTMLInputElement';
|
17
16
|
import HTMLTextAreaElement from '../nodes/html-text-area-element/HTMLTextAreaElement';
|
@@ -35,6 +34,7 @@ import CustomEvent from '../event/events/CustomEvent';
|
|
35
34
|
import AnimationEvent from '../event/events/AnimationEvent';
|
36
35
|
import KeyboardEvent from '../event/events/KeyboardEvent';
|
37
36
|
import ProgressEvent from '../event/events/ProgressEvent';
|
37
|
+
import MediaQueryListEvent from '../event/events/MediaQueryListEvent';
|
38
38
|
import EventTarget from '../event/EventTarget';
|
39
39
|
import URL from '../location/URL';
|
40
40
|
import Location from '../location/Location';
|
@@ -48,9 +48,16 @@ import DOMException from '../exception/DOMException';
|
|
48
48
|
import FileReader from '../file/FileReader';
|
49
49
|
import History from '../history/History';
|
50
50
|
import CSSStyleSheet from '../css/CSSStyleSheet';
|
51
|
-
import CSSStyleDeclaration from '../css/CSSStyleDeclaration';
|
51
|
+
import CSSStyleDeclaration from '../css/declaration/CSSStyleDeclaration';
|
52
52
|
import CSS from '../css/CSS';
|
53
53
|
import CSSUnitValue from '../css/CSSUnitValue';
|
54
|
+
import CSSRule from '../css/CSSRule';
|
55
|
+
import CSSContainerRule from '../css/rules/CSSContainerRule';
|
56
|
+
import CSSFontFaceRule from '../css/rules/CSSFontFaceRule';
|
57
|
+
import CSSKeyframeRule from '../css/rules/CSSKeyframeRule';
|
58
|
+
import CSSKeyframesRule from '../css/rules/CSSKeyframesRule';
|
59
|
+
import CSSMediaRule from '../css/rules/CSSMediaRule';
|
60
|
+
import CSSStyleRule from '../css/rules/CSSStyleRule';
|
54
61
|
import PointerEvent from '../event/events/PointerEvent';
|
55
62
|
import MouseEvent from '../event/events/MouseEvent';
|
56
63
|
import FocusEvent from '../event/events/FocusEvent';
|
@@ -84,8 +91,10 @@ import Range from '../range/Range';
|
|
84
91
|
import MediaQueryList from '../match-media/MediaQueryList';
|
85
92
|
import DOMRect from '../nodes/element/DOMRect';
|
86
93
|
import Window from './Window';
|
94
|
+
import Attr from '../nodes/attr/Attr';
|
87
95
|
import { URLSearchParams } from 'url';
|
88
96
|
import { Performance } from 'perf_hooks';
|
97
|
+
import IElement from '../nodes/element/IElement';
|
89
98
|
|
90
99
|
/**
|
91
100
|
* Window without dependencies to server side specific packages.
|
@@ -96,6 +105,8 @@ export default interface IWindow extends IEventTarget, NodeJS.Global {
|
|
96
105
|
whenAsyncComplete: () => Promise<void>;
|
97
106
|
cancelAsync: () => void;
|
98
107
|
asyncTaskManager: AsyncTaskManager;
|
108
|
+
setInnerWidth: (width: number) => void;
|
109
|
+
setInnerHeight: (height: number) => void;
|
99
110
|
};
|
100
111
|
|
101
112
|
// Global classes
|
@@ -115,6 +126,7 @@ export default interface IWindow extends IEventTarget, NodeJS.Global {
|
|
115
126
|
readonly HTMLMetaElement: typeof HTMLMetaElement;
|
116
127
|
readonly HTMLBaseElement: typeof HTMLBaseElement;
|
117
128
|
readonly HTMLDialogElement: typeof HTMLDialogElement;
|
129
|
+
readonly Attr: typeof Attr;
|
118
130
|
readonly SVGSVGElement: typeof SVGSVGElement;
|
119
131
|
readonly SVGElement: typeof SVGElement;
|
120
132
|
readonly Image: typeof Image;
|
@@ -145,6 +157,7 @@ export default interface IWindow extends IEventTarget, NodeJS.Global {
|
|
145
157
|
readonly ErrorEvent: typeof ErrorEvent;
|
146
158
|
readonly StorageEvent: typeof StorageEvent;
|
147
159
|
readonly ProgressEvent: typeof ProgressEvent;
|
160
|
+
readonly MediaQueryListEvent: typeof MediaQueryListEvent;
|
148
161
|
readonly EventTarget: typeof EventTarget;
|
149
162
|
readonly DataTransfer: typeof DataTransfer;
|
150
163
|
readonly DataTransferItem: typeof DataTransferItem;
|
@@ -168,6 +181,13 @@ export default interface IWindow extends IEventTarget, NodeJS.Global {
|
|
168
181
|
readonly NodeList: typeof NodeList;
|
169
182
|
readonly CSSUnitValue: typeof CSSUnitValue;
|
170
183
|
readonly CSS: CSS;
|
184
|
+
readonly CSSRule: typeof CSSRule;
|
185
|
+
readonly CSSContainerRule: typeof CSSContainerRule;
|
186
|
+
readonly CSSFontFaceRule: typeof CSSFontFaceRule;
|
187
|
+
readonly CSSKeyframeRule: typeof CSSKeyframeRule;
|
188
|
+
readonly CSSKeyframesRule: typeof CSSKeyframesRule;
|
189
|
+
readonly CSSMediaRule: typeof CSSMediaRule;
|
190
|
+
readonly CSSStyleRule: typeof CSSStyleRule;
|
171
191
|
readonly Selection: typeof Selection;
|
172
192
|
readonly Navigator: typeof Navigator;
|
173
193
|
readonly MimeType: typeof MimeType;
|
@@ -217,7 +237,7 @@ export default interface IWindow extends IEventTarget, NodeJS.Global {
|
|
217
237
|
* @param element Element.
|
218
238
|
* @returns CSS style declaration.
|
219
239
|
*/
|
220
|
-
getComputedStyle(element:
|
240
|
+
getComputedStyle(element: IElement): CSSStyleDeclaration;
|
221
241
|
|
222
242
|
/**
|
223
243
|
* Returns selection.
|
package/src/window/Window.ts
CHANGED
@@ -35,6 +35,7 @@ import CustomEvent from '../event/events/CustomEvent';
|
|
35
35
|
import AnimationEvent from '../event/events/AnimationEvent';
|
36
36
|
import KeyboardEvent from '../event/events/KeyboardEvent';
|
37
37
|
import ProgressEvent from '../event/events/ProgressEvent';
|
38
|
+
import MediaQueryListEvent from '../event/events/MediaQueryListEvent';
|
38
39
|
import EventTarget from '../event/EventTarget';
|
39
40
|
import URL from '../location/URL';
|
40
41
|
import Location from '../location/Location';
|
@@ -50,9 +51,16 @@ import DOMException from '../exception/DOMException';
|
|
50
51
|
import { default as FileReaderImplementation } from '../file/FileReader';
|
51
52
|
import History from '../history/History';
|
52
53
|
import CSSStyleSheet from '../css/CSSStyleSheet';
|
53
|
-
import CSSStyleDeclaration from '../css/CSSStyleDeclaration';
|
54
|
+
import CSSStyleDeclaration from '../css/declaration/CSSStyleDeclaration';
|
54
55
|
import CSS from '../css/CSS';
|
55
56
|
import CSSUnitValue from '../css/CSSUnitValue';
|
57
|
+
import CSSRule from '../css/CSSRule';
|
58
|
+
import CSSContainerRule from '../css/rules/CSSContainerRule';
|
59
|
+
import CSSFontFaceRule from '../css/rules/CSSFontFaceRule';
|
60
|
+
import CSSKeyframeRule from '../css/rules/CSSKeyframeRule';
|
61
|
+
import CSSKeyframesRule from '../css/rules/CSSKeyframesRule';
|
62
|
+
import CSSMediaRule from '../css/rules/CSSMediaRule';
|
63
|
+
import CSSStyleRule from '../css/rules/CSSStyleRule';
|
56
64
|
import MouseEvent from '../event/events/MouseEvent';
|
57
65
|
import PointerEvent from '../event/events/PointerEvent';
|
58
66
|
import FocusEvent from '../event/events/FocusEvent';
|
@@ -96,6 +104,8 @@ import VM from 'vm';
|
|
96
104
|
import { Buffer } from 'buffer';
|
97
105
|
import Base64 from '../base64/Base64';
|
98
106
|
import IDocument from '../nodes/document/IDocument';
|
107
|
+
import Attr from '../nodes/attr/Attr';
|
108
|
+
import IElement from '../nodes/element/IElement';
|
99
109
|
|
100
110
|
const ORIGINAL_SET_TIMEOUT = setTimeout;
|
101
111
|
const ORIGINAL_CLEAR_TIMEOUT = clearTimeout;
|
@@ -117,7 +127,19 @@ export default class Window extends EventTarget implements IWindow {
|
|
117
127
|
cancelAsync: (): void => {
|
118
128
|
this.happyDOM.asyncTaskManager.cancelAll();
|
119
129
|
},
|
120
|
-
asyncTaskManager: new AsyncTaskManager()
|
130
|
+
asyncTaskManager: new AsyncTaskManager(),
|
131
|
+
setInnerWidth: (width: number): void => {
|
132
|
+
if (this.innerWidth !== width) {
|
133
|
+
(<number>this.innerWidth) = width;
|
134
|
+
this.dispatchEvent(new Event('resize'));
|
135
|
+
}
|
136
|
+
},
|
137
|
+
setInnerHeight: (height: number): void => {
|
138
|
+
if (this.innerHeight !== height) {
|
139
|
+
(<number>this.innerHeight) = height;
|
140
|
+
this.dispatchEvent(new Event('resize'));
|
141
|
+
}
|
142
|
+
}
|
121
143
|
};
|
122
144
|
|
123
145
|
// Global classes
|
@@ -137,6 +159,7 @@ export default class Window extends EventTarget implements IWindow {
|
|
137
159
|
public readonly HTMLMetaElement = HTMLMetaElement;
|
138
160
|
public readonly HTMLBaseElement = HTMLBaseElement;
|
139
161
|
public readonly HTMLDialogElement = HTMLDialogElement;
|
162
|
+
public readonly Attr = Attr;
|
140
163
|
public readonly SVGSVGElement = SVGSVGElement;
|
141
164
|
public readonly SVGElement = SVGElement;
|
142
165
|
public readonly Text = Text;
|
@@ -165,6 +188,7 @@ export default class Window extends EventTarget implements IWindow {
|
|
165
188
|
public readonly ErrorEvent = ErrorEvent;
|
166
189
|
public readonly StorageEvent = StorageEvent;
|
167
190
|
public readonly ProgressEvent = ProgressEvent;
|
191
|
+
public readonly MediaQueryListEvent = MediaQueryListEvent;
|
168
192
|
public readonly EventTarget = EventTarget;
|
169
193
|
public readonly DataTransfer = DataTransfer;
|
170
194
|
public readonly DataTransferItem = DataTransferItem;
|
@@ -185,8 +209,14 @@ export default class Window extends EventTarget implements IWindow {
|
|
185
209
|
public readonly URLSearchParams = URLSearchParams;
|
186
210
|
public readonly HTMLCollection = HTMLCollection;
|
187
211
|
public readonly NodeList = NodeList;
|
188
|
-
public readonly MediaQueryList = MediaQueryList;
|
189
212
|
public readonly CSSUnitValue = CSSUnitValue;
|
213
|
+
public readonly CSSRule = CSSRule;
|
214
|
+
public readonly CSSContainerRule = CSSContainerRule;
|
215
|
+
public readonly CSSFontFaceRule = CSSFontFaceRule;
|
216
|
+
public readonly CSSKeyframeRule = CSSKeyframeRule;
|
217
|
+
public readonly CSSKeyframesRule = CSSKeyframesRule;
|
218
|
+
public readonly CSSMediaRule = CSSMediaRule;
|
219
|
+
public readonly CSSStyleRule = CSSStyleRule;
|
190
220
|
public readonly Selection = Selection;
|
191
221
|
public readonly Navigator = Navigator;
|
192
222
|
public readonly MimeType = MimeType;
|
@@ -223,12 +253,12 @@ export default class Window extends EventTarget implements IWindow {
|
|
223
253
|
public readonly window = this;
|
224
254
|
public readonly globalThis = this;
|
225
255
|
public readonly screen = new Screen();
|
226
|
-
public readonly innerWidth = 1024;
|
227
|
-
public readonly innerHeight = 768;
|
228
256
|
public readonly devicePixelRatio = 1;
|
229
257
|
public readonly sessionStorage = new Storage();
|
230
258
|
public readonly localStorage = new Storage();
|
231
259
|
public readonly performance = PerfHooks.performance;
|
260
|
+
public readonly innerWidth: number;
|
261
|
+
public readonly innerHeight: number;
|
232
262
|
|
233
263
|
// Node.js Globals
|
234
264
|
public ArrayBuffer;
|
@@ -301,10 +331,22 @@ export default class Window extends EventTarget implements IWindow {
|
|
301
331
|
|
302
332
|
/**
|
303
333
|
* Constructor.
|
334
|
+
*
|
335
|
+
* @param [options] Options.
|
336
|
+
* @param [options.innerWidth] Inner width.
|
337
|
+
* @param [options.innerHeight] Inner height.
|
338
|
+
* @param [options.url] URL.
|
304
339
|
*/
|
305
|
-
constructor() {
|
340
|
+
constructor(options?: { innerWidth?: number; innerHeight?: number; url?: string }) {
|
306
341
|
super();
|
307
342
|
|
343
|
+
this.innerWidth = options?.innerWidth ? options.innerWidth : 0;
|
344
|
+
this.innerHeight = options?.innerHeight ? options.innerHeight : 0;
|
345
|
+
|
346
|
+
if (options?.url) {
|
347
|
+
this.location.href = options.url;
|
348
|
+
}
|
349
|
+
|
308
350
|
this._setTimeout = ORIGINAL_SET_TIMEOUT;
|
309
351
|
this._clearTimeout = ORIGINAL_CLEAR_TIMEOUT;
|
310
352
|
this._setInterval = ORIGINAL_SET_INTERVAL;
|
@@ -418,8 +460,8 @@ export default class Window extends EventTarget implements IWindow {
|
|
418
460
|
* @param element Element.
|
419
461
|
* @returns CSS style declaration.
|
420
462
|
*/
|
421
|
-
public getComputedStyle(element:
|
422
|
-
return new CSSStyleDeclaration(element
|
463
|
+
public getComputedStyle(element: IElement): CSSStyleDeclaration {
|
464
|
+
return new CSSStyleDeclaration(element, true);
|
423
465
|
}
|
424
466
|
|
425
467
|
/**
|
@@ -482,9 +524,7 @@ export default class Window extends EventTarget implements IWindow {
|
|
482
524
|
* @returns A new MediaQueryList.
|
483
525
|
*/
|
484
526
|
public matchMedia(mediaQueryString: string): MediaQueryList {
|
485
|
-
|
486
|
-
mediaQueryList._media = mediaQueryString;
|
487
|
-
return mediaQueryList;
|
527
|
+
return new MediaQueryList(this, mediaQueryString);
|
488
528
|
}
|
489
529
|
|
490
530
|
/**
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Attr.js","sourceRoot":"","sources":["../../src/attribute/Attr.ts"],"names":[],"mappings":";;AAGA;;;;GAIG;AACH,MAAqB,IAAI;IAAzB;QACQ,UAAK,GAAW,IAAI,CAAC;QACrB,SAAI,GAAW,IAAI,CAAC;QACpB,iBAAY,GAAW,IAAI,CAAC;QAEnC;;WAEG;QACa,iBAAY,GAAa,IAAI,CAAC;QAE9C;;WAEG;QACa,kBAAa,GAAc,IAAI,CAAC;QAEhD;;WAEG;QACa,cAAS,GAAG,IAAI,CAAC;IAmBlC,CAAC;IAjBA;;;;OAIG;IACH,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACH,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnD,CAAC;CACD;AArCD,uBAqCC"}
|