happy-dom 2.55.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/README.md +26 -6
- package/lib/async-task-manager/AsyncTaskManager.js +34 -78
- package/lib/async-task-manager/AsyncTaskManager.js.map +1 -1
- package/lib/attribute/Attr.js +19 -28
- package/lib/attribute/Attr.js.map +1 -1
- package/lib/config/ElementTag.js +15 -15
- package/lib/config/ElementTag.js.map +1 -1
- package/lib/cookie/CookieUtility.js +21 -26
- package/lib/cookie/CookieUtility.js.map +1 -1
- package/lib/css/CSS.js +12 -18
- package/lib/css/CSS.js.map +1 -1
- package/lib/css/CSSParser.js +29 -33
- package/lib/css/CSSParser.js.map +1 -1
- package/lib/css/CSSRule.js +24 -29
- package/lib/css/CSSRule.js.map +1 -1
- package/lib/css/CSSStyleDeclaration.js +4516 -6005
- package/lib/css/CSSStyleDeclaration.js.map +1 -1
- package/lib/css/CSSStyleSheet.js +17 -59
- package/lib/css/CSSStyleSheet.js.map +1 -1
- package/lib/css/CSSUnitValue.js +4 -5
- package/lib/css/CSSUnitValue.js.map +1 -1
- package/lib/css/MediaList.js +23 -28
- package/lib/css/MediaList.js.map +1 -1
- package/lib/css/rules/CSSFontFaceRule.js +6 -24
- package/lib/css/rules/CSSFontFaceRule.js.map +1 -1
- package/lib/css/rules/CSSKeyframeRule.js +14 -36
- package/lib/css/rules/CSSKeyframeRule.js.map +1 -1
- package/lib/css/rules/CSSKeyframesRule.js +31 -54
- package/lib/css/rules/CSSKeyframesRule.js.map +1 -1
- package/lib/css/rules/CSSMediaRule.js +29 -56
- package/lib/css/rules/CSSMediaRule.js.map +1 -1
- package/lib/css/rules/CSSStyleRule.js +16 -38
- package/lib/css/rules/CSSStyleRule.js.map +1 -1
- package/lib/custom-element/CustomElementRegistry.js +21 -24
- package/lib/custom-element/CustomElementRegistry.js.map +1 -1
- package/lib/dom-implementation/DOMImplementation.js +12 -13
- package/lib/dom-implementation/DOMImplementation.js.map +1 -1
- package/lib/dom-parser/DOMParser.js +29 -35
- package/lib/dom-parser/DOMParser.js.map +1 -1
- package/lib/dom-token-list/DOMTokenList.js +64 -79
- package/lib/dom-token-list/DOMTokenList.js.map +1 -1
- package/lib/event/DataTransfer.js +4 -5
- package/lib/event/DataTransfer.js.map +1 -1
- package/lib/event/DataTransferItem.js +7 -8
- package/lib/event/DataTransferItem.js.map +1 -1
- package/lib/event/DataTransferItemList.js +10 -11
- package/lib/event/DataTransferItemList.js.map +1 -1
- package/lib/event/Event.js +11 -15
- package/lib/event/Event.js.map +1 -1
- package/lib/event/EventTarget.js +14 -16
- package/lib/event/EventTarget.js.map +1 -1
- package/lib/event/IUIEventInit.d.ts +2 -2
- package/lib/event/UIEvent.d.ts +2 -2
- package/lib/event/UIEvent.js +25 -46
- package/lib/event/UIEvent.js.map +1 -1
- package/lib/event/events/AnimationEvent.js +11 -29
- package/lib/event/events/AnimationEvent.js.map +1 -1
- package/lib/event/events/CustomEvent.js +9 -31
- package/lib/event/events/CustomEvent.js.map +1 -1
- package/lib/event/events/ErrorEvent.js +15 -34
- package/lib/event/events/ErrorEvent.js.map +1 -1
- package/lib/event/events/FocusEvent.js +7 -26
- package/lib/event/events/FocusEvent.js.map +1 -1
- package/lib/event/events/InputEvent.js +13 -32
- package/lib/event/events/InputEvent.js.map +1 -1
- package/lib/event/events/KeyboardEvent.js +27 -46
- package/lib/event/events/KeyboardEvent.js.map +1 -1
- package/lib/event/events/MouseEvent.js +33 -52
- package/lib/event/events/MouseEvent.js.map +1 -1
- package/lib/event/events/PointerEvent.js +25 -44
- package/lib/event/events/PointerEvent.js.map +1 -1
- package/lib/event/events/ProgressEvent.js +11 -30
- package/lib/event/events/ProgressEvent.js.map +1 -1
- package/lib/event/events/StorageEvent.js +13 -32
- package/lib/event/events/StorageEvent.js.map +1 -1
- package/lib/event/events/WheelEvent.js +16 -35
- package/lib/event/events/WheelEvent.js.map +1 -1
- package/lib/exception/DOMException.js +5 -24
- package/lib/exception/DOMException.js.map +1 -1
- package/lib/fetch/FetchHandler.js +18 -22
- package/lib/fetch/FetchHandler.js.map +1 -1
- package/lib/fetch/Headers.js +3 -23
- package/lib/fetch/Headers.js.map +1 -1
- package/lib/fetch/Request.js +61 -81
- package/lib/fetch/Request.js.map +1 -1
- package/lib/fetch/ResourceFetchHandler.js +18 -67
- package/lib/fetch/ResourceFetchHandler.js.map +1 -1
- package/lib/fetch/Response.js +61 -81
- package/lib/fetch/Response.js.map +1 -1
- package/lib/file/Blob.js +29 -78
- package/lib/file/Blob.js.map +1 -1
- package/lib/file/File.js +9 -27
- package/lib/file/File.js.map +1 -1
- package/lib/file/FileReader.js +57 -78
- package/lib/file/FileReader.js.map +1 -1
- package/lib/history/History.js +32 -37
- package/lib/history/History.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +69 -69
- package/lib/index.js.map +1 -1
- package/lib/location/Location.js +11 -28
- package/lib/location/Location.js.map +1 -1
- package/lib/location/RelativeURL.js +5 -8
- package/lib/location/RelativeURL.js.map +1 -1
- package/lib/location/URL.js +46 -59
- package/lib/location/URL.js.map +1 -1
- package/lib/match-media/MediaQueryList.js +28 -54
- package/lib/match-media/MediaQueryList.js.map +1 -1
- package/lib/mutation-observer/MutationListener.js +3 -4
- package/lib/mutation-observer/MutationListener.js.map +1 -1
- package/lib/mutation-observer/MutationObserver.js +12 -13
- package/lib/mutation-observer/MutationObserver.js.map +1 -1
- package/lib/mutation-observer/MutationRecord.js +3 -4
- package/lib/mutation-observer/MutationRecord.js.map +1 -1
- package/lib/navigator/MimeType.js +5 -6
- package/lib/navigator/MimeType.js.map +1 -1
- package/lib/navigator/MimeTypeArray.js +10 -11
- package/lib/navigator/MimeTypeArray.js.map +1 -1
- package/lib/navigator/Navigator.js +7 -8
- package/lib/navigator/Navigator.js.map +1 -1
- package/lib/navigator/Plugin.js +10 -11
- package/lib/navigator/Plugin.js.map +1 -1
- package/lib/navigator/PluginArray.js +12 -13
- package/lib/navigator/PluginArray.js.map +1 -1
- package/lib/nodes/character-data/CharacterData.js +119 -184
- package/lib/nodes/character-data/CharacterData.js.map +1 -1
- package/lib/nodes/character-data/CharacterDataUtility.js +12 -15
- package/lib/nodes/character-data/CharacterDataUtility.js.map +1 -1
- package/lib/nodes/child-node/ChildNodeUtility.js +24 -45
- package/lib/nodes/child-node/ChildNodeUtility.js.map +1 -1
- package/lib/nodes/child-node/NonDocumentChildNodeUtility.js +9 -12
- package/lib/nodes/child-node/NonDocumentChildNodeUtility.js.map +1 -1
- package/lib/nodes/comment/Comment.js +20 -43
- package/lib/nodes/comment/Comment.js.map +1 -1
- package/lib/nodes/document/Document.d.ts +3 -3
- package/lib/nodes/document/Document.js +334 -461
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/document/DocumentReadyStateManager.js +16 -19
- package/lib/nodes/document/DocumentReadyStateManager.js.map +1 -1
- package/lib/nodes/document/IDocument.d.ts +2 -2
- package/lib/nodes/document-fragment/DocumentFragment.js +93 -153
- package/lib/nodes/document-fragment/DocumentFragment.js.map +1 -1
- package/lib/nodes/document-type/DocumentType.js +22 -45
- package/lib/nodes/document-type/DocumentType.js.map +1 -1
- package/lib/nodes/element/DOMRect.js +3 -4
- package/lib/nodes/element/DOMRect.js.map +1 -1
- package/lib/nodes/element/Element.js +367 -496
- package/lib/nodes/element/Element.js.map +1 -1
- package/lib/nodes/element/HTMLCollection.js +4 -24
- package/lib/nodes/element/HTMLCollection.js.map +1 -1
- package/lib/nodes/element/HTMLCollectionFactory.js +6 -9
- package/lib/nodes/element/HTMLCollectionFactory.js.map +1 -1
- package/lib/nodes/element/Range.js +89 -114
- package/lib/nodes/element/Range.js.map +1 -1
- package/lib/nodes/html-base-element/HTMLBaseElement.js +41 -70
- package/lib/nodes/html-base-element/HTMLBaseElement.js.map +1 -1
- package/lib/nodes/html-document/HTMLDocument.js +3 -23
- package/lib/nodes/html-document/HTMLDocument.js.map +1 -1
- package/lib/nodes/html-element/DatasetUtility.js +9 -12
- package/lib/nodes/html-element/DatasetUtility.js.map +1 -1
- package/lib/nodes/html-element/HTMLElement.js +232 -290
- package/lib/nodes/html-element/HTMLElement.js.map +1 -1
- package/lib/nodes/html-form-element/HTMLFormElement.js +170 -235
- package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
- package/lib/nodes/html-image-element/HTMLImageElement.js +178 -237
- package/lib/nodes/html-image-element/HTMLImageElement.js.map +1 -1
- package/lib/nodes/html-image-element/Image.js +7 -27
- package/lib/nodes/html-image-element/Image.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElement.js +705 -872
- package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js +9 -12
- package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js +5 -8
- package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js.map +1 -1
- package/lib/nodes/html-input-element/ValidityState.js +47 -69
- package/lib/nodes/html-input-element/ValidityState.js.map +1 -1
- package/lib/nodes/html-label-element/HTMLLabelElement.js +53 -87
- package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElement.js +197 -252
- package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
- package/lib/nodes/html-meta-element/HTMLMetaElement.js +66 -102
- package/lib/nodes/html-meta-element/HTMLMetaElement.js.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElement.js +145 -193
- package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
- package/lib/nodes/html-script-element/ScriptUtility.js +58 -112
- package/lib/nodes/html-script-element/ScriptUtility.js.map +1 -1
- package/lib/nodes/html-slot-element/HTMLSlotElement.js +33 -65
- package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -1
- package/lib/nodes/html-style-element/HTMLStyleElement.js +75 -109
- package/lib/nodes/html-style-element/HTMLStyleElement.js.map +1 -1
- package/lib/nodes/html-template-element/HTMLTemplateElement.js +60 -99
- package/lib/nodes/html-template-element/HTMLTemplateElement.js.map +1 -1
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +349 -444
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
- package/lib/nodes/html-unknown-element/HTMLUnknownElement.js +17 -37
- package/lib/nodes/html-unknown-element/HTMLUnknownElement.js.map +1 -1
- package/lib/nodes/node/Node.js +193 -260
- package/lib/nodes/node/Node.js.map +1 -1
- package/lib/nodes/node/NodeList.js +4 -24
- package/lib/nodes/node/NodeList.js.map +1 -1
- package/lib/nodes/node/NodeListFactory.js +6 -9
- package/lib/nodes/node/NodeListFactory.js.map +1 -1
- package/lib/nodes/parent-node/ParentNodeUtility.js +43 -78
- package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
- package/lib/nodes/shadow-root/ShadowRoot.js +53 -83
- package/lib/nodes/shadow-root/ShadowRoot.js.map +1 -1
- package/lib/nodes/svg-document/SVGDocument.js +3 -23
- package/lib/nodes/svg-document/SVGDocument.js.map +1 -1
- package/lib/nodes/svg-element/DOMMatrix.js +3 -4
- package/lib/nodes/svg-element/DOMMatrix.js.map +1 -1
- package/lib/nodes/svg-element/SVGAngle.js +10 -11
- package/lib/nodes/svg-element/SVGAngle.js.map +1 -1
- package/lib/nodes/svg-element/SVGAnimatedRect.js +4 -5
- package/lib/nodes/svg-element/SVGAnimatedRect.js.map +1 -1
- package/lib/nodes/svg-element/SVGElement.js +58 -93
- package/lib/nodes/svg-element/SVGElement.js.map +1 -1
- package/lib/nodes/svg-element/SVGGraphicsElement.js +14 -32
- package/lib/nodes/svg-element/SVGGraphicsElement.js.map +1 -1
- package/lib/nodes/svg-element/SVGLength.js +16 -17
- package/lib/nodes/svg-element/SVGLength.js.map +1 -1
- package/lib/nodes/svg-element/SVGNumber.js +3 -4
- package/lib/nodes/svg-element/SVGNumber.js.map +1 -1
- package/lib/nodes/svg-element/SVGPoint.js +3 -4
- package/lib/nodes/svg-element/SVGPoint.js.map +1 -1
- package/lib/nodes/svg-element/SVGRect.js +3 -4
- package/lib/nodes/svg-element/SVGRect.js.map +1 -1
- package/lib/nodes/svg-element/SVGSVGElement.js +187 -248
- package/lib/nodes/svg-element/SVGSVGElement.js.map +1 -1
- package/lib/nodes/svg-element/SVGTransform.js +16 -17
- package/lib/nodes/svg-element/SVGTransform.js.map +1 -1
- package/lib/nodes/text/Text.js +20 -43
- package/lib/nodes/text/Text.js.map +1 -1
- package/lib/nodes/xml-document/XMLDocument.js +3 -23
- package/lib/nodes/xml-document/XMLDocument.js.map +1 -1
- package/lib/query-selector/QuerySelector.js +36 -44
- package/lib/query-selector/QuerySelector.js.map +1 -1
- package/lib/query-selector/SelectorItem.js +62 -66
- package/lib/query-selector/SelectorItem.js.map +1 -1
- package/lib/resize-observer/ResizeObserver.js +8 -11
- package/lib/resize-observer/ResizeObserver.js.map +1 -1
- package/lib/screen/Screen.js +3 -4
- package/lib/screen/Screen.js.map +1 -1
- package/lib/selection/Selection.js +29 -30
- package/lib/selection/Selection.js.map +1 -1
- package/lib/storage/Storage.js +22 -27
- package/lib/storage/Storage.js.map +1 -1
- package/lib/tree-walker/NodeFilterMask.js +1 -1
- package/lib/tree-walker/NodeFilterMask.js.map +1 -1
- package/lib/tree-walker/TreeWalker.js +30 -33
- package/lib/tree-walker/TreeWalker.js.map +1 -1
- package/lib/window/GlobalWindow.d.ts +90 -0
- package/lib/window/GlobalWindow.js +98 -0
- package/lib/window/GlobalWindow.js.map +1 -0
- package/lib/window/IWindow.d.ts +35 -18
- package/lib/window/VMGlobalPropertyScript.d.ts +2 -0
- package/lib/window/VMGlobalPropertyScript.js +65 -0
- package/lib/window/VMGlobalPropertyScript.js.map +1 -0
- package/lib/window/Window.d.ts +84 -105
- package/lib/window/Window.js +286 -490
- package/lib/window/Window.js.map +1 -1
- package/lib/xml-parser/XMLParser.js +65 -71
- package/lib/xml-parser/XMLParser.js.map +1 -1
- package/lib/xml-serializer/XMLSerializer.js +30 -37
- package/lib/xml-serializer/XMLSerializer.js.map +1 -1
- package/package.json +6 -7
- package/src/dom-parser/DOMParser.ts +4 -5
- package/src/event/IUIEventInit.ts +2 -2
- package/src/event/UIEvent.ts +2 -2
- package/src/fetch/FetchHandler.ts +3 -3
- package/src/fetch/ResourceFetchHandler.ts +2 -2
- package/src/index.ts +3 -3
- package/src/nodes/document/Document.ts +4 -4
- package/src/nodes/document/IDocument.ts +2 -2
- package/src/nodes/html-link-element/HTMLLinkElement.ts +8 -2
- package/src/nodes/html-script-element/ScriptUtility.ts +4 -4
- package/src/window/GlobalWindow.ts +91 -0
- package/src/window/IWindow.ts +31 -12
- package/src/window/VMGlobalPropertyScript.ts +62 -0
- package/src/window/Window.ts +125 -173
- package/tsconfig.json +1 -1
- package/lib/window/AsyncWindow.d.ts +0 -10
- package/lib/window/AsyncWindow.js +0 -38
- package/lib/window/AsyncWindow.js.map +0 -1
- package/src/window/AsyncWindow.ts +0 -17
@@ -2,7 +2,7 @@ import Element from '../element/Element';
|
|
2
2
|
import HTMLUnknownElement from '../html-unknown-element/HTMLUnknownElement';
|
3
3
|
import Text from '../text/Text';
|
4
4
|
import Comment from '../comment/Comment';
|
5
|
-
import
|
5
|
+
import IWindow from '../../window/IWindow';
|
6
6
|
import Node from '../node/Node';
|
7
7
|
import TreeWalker from '../../tree-walker/TreeWalker';
|
8
8
|
import DocumentFragment from '../document-fragment/DocumentFragment';
|
@@ -54,7 +54,7 @@ export default class Document extends Node implements IDocument {
|
|
54
54
|
public _activeElement: IHTMLElement = null;
|
55
55
|
protected _isFirstWrite = true;
|
56
56
|
protected _isFirstWriteAfterOpen = false;
|
57
|
-
private _defaultView:
|
57
|
+
private _defaultView: IWindow = null;
|
58
58
|
private _cookie = '';
|
59
59
|
|
60
60
|
/**
|
@@ -103,7 +103,7 @@ export default class Document extends Node implements IDocument {
|
|
103
103
|
*
|
104
104
|
* @returns Default view.
|
105
105
|
*/
|
106
|
-
public get defaultView():
|
106
|
+
public get defaultView(): IWindow {
|
107
107
|
return this._defaultView;
|
108
108
|
}
|
109
109
|
|
@@ -112,7 +112,7 @@ export default class Document extends Node implements IDocument {
|
|
112
112
|
*
|
113
113
|
* @param defaultView Default view.
|
114
114
|
*/
|
115
|
-
public set defaultView(defaultView:
|
115
|
+
public set defaultView(defaultView: IWindow) {
|
116
116
|
this._defaultView = defaultView;
|
117
117
|
this._readyStateManager = new DocumentReadyStateManager(defaultView);
|
118
118
|
this._readyStateManager.whenComplete().then(() => {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import IElement from '../element/IElement';
|
2
2
|
import IHTMLElement from '../html-element/IHTMLElement';
|
3
|
-
import
|
3
|
+
import IWindow from '../../window/IWindow';
|
4
4
|
import TreeWalker from '../../tree-walker/TreeWalker';
|
5
5
|
import Event from '../../event/Event';
|
6
6
|
import DOMImplementation from '../../dom-implementation/DOMImplementation';
|
@@ -24,7 +24,7 @@ import INodeList from '../node/INodeList';
|
|
24
24
|
*/
|
25
25
|
export default interface IDocument extends IParentNode {
|
26
26
|
onreadystatechange: (event: Event) => void;
|
27
|
-
readonly defaultView:
|
27
|
+
readonly defaultView: IWindow;
|
28
28
|
readonly implementation: DOMImplementation;
|
29
29
|
readonly documentElement: IHTMLElement;
|
30
30
|
readonly doctype: IDocumentType;
|
@@ -221,7 +221,10 @@ export default class HTMLLinkElement extends HTMLElement implements IHTMLLinkEle
|
|
221
221
|
})
|
222
222
|
);
|
223
223
|
(<Document>this.ownerDocument)._readyStateManager.endTask();
|
224
|
-
if (
|
224
|
+
if (
|
225
|
+
!this['_listeners']['error'] &&
|
226
|
+
!this.ownerDocument.defaultView['_listeners']['error']
|
227
|
+
) {
|
225
228
|
this.ownerDocument.defaultView.console.error(error);
|
226
229
|
}
|
227
230
|
});
|
@@ -267,7 +270,10 @@ export default class HTMLLinkElement extends HTMLElement implements IHTMLLinkEle
|
|
267
270
|
})
|
268
271
|
);
|
269
272
|
(<Document>this.ownerDocument)._readyStateManager.endTask();
|
270
|
-
if (
|
273
|
+
if (
|
274
|
+
!this['_listeners']['error'] &&
|
275
|
+
!this.ownerDocument.defaultView['_listeners']['error']
|
276
|
+
) {
|
271
277
|
this.ownerDocument.defaultView.console.error(error);
|
272
278
|
}
|
273
279
|
});
|
@@ -37,8 +37,8 @@ export default class ScriptUtility {
|
|
37
37
|
})
|
38
38
|
);
|
39
39
|
if (
|
40
|
-
!element
|
41
|
-
!element.ownerDocument.defaultView
|
40
|
+
!element['_listeners']['error'] &&
|
41
|
+
!element.ownerDocument.defaultView['_listeners']['error']
|
42
42
|
) {
|
43
43
|
element.ownerDocument.defaultView.console.error(error);
|
44
44
|
}
|
@@ -66,8 +66,8 @@ export default class ScriptUtility {
|
|
66
66
|
})
|
67
67
|
);
|
68
68
|
if (
|
69
|
-
!element
|
70
|
-
!element.ownerDocument.defaultView
|
69
|
+
!element['_listeners']['error'] &&
|
70
|
+
!element.ownerDocument.defaultView['_listeners']['error']
|
71
71
|
) {
|
72
72
|
element.ownerDocument.defaultView.console.error(error);
|
73
73
|
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import Window from './Window';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Browser window.
|
5
|
+
*
|
6
|
+
* Reference:
|
7
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Window.
|
8
|
+
*/
|
9
|
+
export default class GlobalWindow extends Window {
|
10
|
+
// Node.js Globals
|
11
|
+
public ArrayBuffer = globalThis.ArrayBuffer;
|
12
|
+
public Boolean = globalThis.Boolean;
|
13
|
+
public Buffer = globalThis.global ? globalThis.global.Buffer : Buffer;
|
14
|
+
public DataView = globalThis.DataView;
|
15
|
+
public Date = globalThis.Date;
|
16
|
+
public Error = globalThis.Error;
|
17
|
+
public EvalError = globalThis.EvalError;
|
18
|
+
public Float32Array = globalThis.Float32Array;
|
19
|
+
public Float64Array = globalThis.Float64Array;
|
20
|
+
public GLOBAL = globalThis.GLOBAL;
|
21
|
+
public Infinity = globalThis.Infinity;
|
22
|
+
public Int16Array = globalThis.Int16Array;
|
23
|
+
public Int32Array = globalThis.Int32Array;
|
24
|
+
public Int8Array = globalThis.Int8Array;
|
25
|
+
public Intl = globalThis.Intl;
|
26
|
+
public JSON = globalThis.JSON;
|
27
|
+
public Map = globalThis.Map;
|
28
|
+
public Math = globalThis.Math;
|
29
|
+
public NaN = globalThis.NaN;
|
30
|
+
public Number = globalThis.Number;
|
31
|
+
public Promise = globalThis.Promise;
|
32
|
+
public RangeError = globalThis.RangeError;
|
33
|
+
public ReferenceError = globalThis.ReferenceError;
|
34
|
+
public RegExp = globalThis.RegExp;
|
35
|
+
public Reflect = globalThis.ArrayBuffer;
|
36
|
+
public Set = globalThis.Set;
|
37
|
+
public Symbol = globalThis.Symbol;
|
38
|
+
public SyntaxError = globalThis.SyntaxError;
|
39
|
+
public String = globalThis.String;
|
40
|
+
public TypeError = globalThis.TypeError;
|
41
|
+
public URIError = globalThis.URIError;
|
42
|
+
public Uint16Array = globalThis.Uint16Array;
|
43
|
+
public Uint32Array = globalThis.Uint32Array;
|
44
|
+
public Uint8Array = globalThis.Uint8Array;
|
45
|
+
public Uint8ClampedArray = globalThis.Uint8ClampedArray;
|
46
|
+
public WeakMap = globalThis.WeakMap;
|
47
|
+
public WeakSet = globalThis.WeakSet;
|
48
|
+
public clearImmediate = globalThis.clearImmediate;
|
49
|
+
public decodeURI = globalThis.decodeURI;
|
50
|
+
public decodeURIComponent = globalThis.decodeURIComponent;
|
51
|
+
public encodeURI = globalThis.encodeURI;
|
52
|
+
public encodeURIComponent = globalThis.encodeURIComponent;
|
53
|
+
public escape = globalThis.escape;
|
54
|
+
public global = globalThis.global;
|
55
|
+
public isFinite = globalThis.isFinite;
|
56
|
+
public isNaN = globalThis.isNaN;
|
57
|
+
public parseFloat = globalThis.parseFloat;
|
58
|
+
public parseInt = globalThis.parseInt;
|
59
|
+
public process = globalThis.process;
|
60
|
+
public root = globalThis.ArrayBuffer;
|
61
|
+
public setImmediate = globalThis.setImmediate;
|
62
|
+
public queueMicrotask = globalThis.queueMicrotask;
|
63
|
+
public undefined = globalThis.ArrayBuffer;
|
64
|
+
public unescape = globalThis.unescape;
|
65
|
+
public gc = globalThis.gc;
|
66
|
+
public v8debug = globalThis.v8debug;
|
67
|
+
public AbortController = globalThis.AbortController;
|
68
|
+
public AbortSignal = globalThis.AbortSignal;
|
69
|
+
public Array = globalThis.Array;
|
70
|
+
public Object = globalThis.Object;
|
71
|
+
public Function = globalThis.Function;
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Evaluates code.
|
75
|
+
*
|
76
|
+
* @param code Code.
|
77
|
+
* @returns Result.
|
78
|
+
*/
|
79
|
+
public eval(code: string): unknown {
|
80
|
+
return eval(code);
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Setup of VM context.
|
85
|
+
*
|
86
|
+
* @override
|
87
|
+
*/
|
88
|
+
protected _setupVMContext(): void {
|
89
|
+
// Do nothing
|
90
|
+
}
|
91
|
+
}
|
package/src/window/IWindow.ts
CHANGED
@@ -11,6 +11,7 @@ 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';
|
14
15
|
import HTMLUnknownElement from '../nodes/html-unknown-element/HTMLUnknownElement';
|
15
16
|
import HTMLInputElement from '../nodes/html-input-element/HTMLInputElement';
|
16
17
|
import HTMLTextAreaElement from '../nodes/html-text-area-element/HTMLTextAreaElement';
|
@@ -62,14 +63,8 @@ import ErrorEvent from '../event/events/ErrorEvent';
|
|
62
63
|
import StorageEvent from '../event/events/StorageEvent';
|
63
64
|
import Screen from '../screen/Screen';
|
64
65
|
import AsyncTaskManager from '../async-task-manager/AsyncTaskManager';
|
65
|
-
import IResponse from '../fetch/IResponse';
|
66
|
-
import IResponseInit from '../fetch/IResponseInit';
|
67
|
-
import IRequest from '../fetch/IRequest';
|
68
|
-
import IRequestInit from '../fetch/IRequestInit';
|
69
|
-
import IHeaders from '../fetch/IHeaders';
|
70
66
|
import Storage from '../storage/Storage';
|
71
67
|
import NodeFilter from '../tree-walker/NodeFilter';
|
72
|
-
import Window from './Window';
|
73
68
|
import HTMLCollection from '../nodes/element/HTMLCollection';
|
74
69
|
import NodeList from '../nodes/node/NodeList';
|
75
70
|
import Selection from '../selection/Selection';
|
@@ -79,12 +74,20 @@ import MimeType from '../navigator/MimeType';
|
|
79
74
|
import MimeTypeArray from '../navigator/MimeTypeArray';
|
80
75
|
import Plugin from '../navigator/Plugin';
|
81
76
|
import PluginArray from '../navigator/PluginArray';
|
77
|
+
import IResponseInit from '../fetch/IResponseInit';
|
78
|
+
import IRequest from '../fetch/IRequest';
|
79
|
+
import IHeaders from '../fetch/IHeaders';
|
80
|
+
import IRequestInit from '../fetch/IRequestInit';
|
81
|
+
import IResponse from '../fetch/IResponse';
|
82
|
+
import MediaQueryList from '../match-media/MediaQueryList';
|
83
|
+
import Window from './Window';
|
82
84
|
import { URLSearchParams } from 'url';
|
85
|
+
import { Performance } from 'perf_hooks';
|
83
86
|
|
84
87
|
/**
|
85
|
-
* Window.
|
88
|
+
* Window without dependencies to server side specific packages.
|
86
89
|
*/
|
87
|
-
export default interface IWindow extends IEventTarget {
|
90
|
+
export default interface IWindow extends IEventTarget, NodeJS.Global {
|
88
91
|
// Public Properties
|
89
92
|
readonly happyDOM: {
|
90
93
|
whenAsyncComplete: () => Promise<void>;
|
@@ -146,9 +149,6 @@ export default interface IWindow extends IEventTarget {
|
|
146
149
|
readonly Location: typeof Location;
|
147
150
|
readonly CustomElementRegistry: typeof CustomElementRegistry;
|
148
151
|
readonly Window: typeof Window;
|
149
|
-
readonly Headers: { new (init?: string[][] | Record<string, string> | IHeaders): IHeaders };
|
150
|
-
readonly Request: { new (input: string | IRequest, init?: IRequestInit): IRequest };
|
151
|
-
readonly Response: { new (body?: unknown | null, init?: IResponseInit): IResponse };
|
152
152
|
readonly XMLSerializer: typeof XMLSerializer;
|
153
153
|
readonly ResizeObserver: typeof ResizeObserver;
|
154
154
|
readonly CSSStyleSheet: typeof CSSStyleSheet;
|
@@ -170,6 +170,9 @@ export default interface IWindow extends IEventTarget {
|
|
170
170
|
readonly MimeTypeArray: typeof MimeTypeArray;
|
171
171
|
readonly Plugin: typeof Plugin;
|
172
172
|
readonly PluginArray: typeof PluginArray;
|
173
|
+
readonly Headers: { new (init?: string[][] | Record<string, string> | IHeaders): IHeaders };
|
174
|
+
readonly Request: { new (input: string | IRequest, init?: IRequestInit): IRequest };
|
175
|
+
readonly Response: { new (body?: unknown | null, init?: IResponseInit): IResponse };
|
173
176
|
|
174
177
|
// Events
|
175
178
|
onload: (event: Event) => void;
|
@@ -192,6 +195,7 @@ export default interface IWindow extends IEventTarget {
|
|
192
195
|
readonly innerHeight: number;
|
193
196
|
readonly sessionStorage: Storage;
|
194
197
|
readonly localStorage: Storage;
|
198
|
+
readonly performance: Performance;
|
195
199
|
|
196
200
|
/**
|
197
201
|
* Evaluates code.
|
@@ -207,7 +211,14 @@ export default interface IWindow extends IEventTarget {
|
|
207
211
|
* @param element Element.
|
208
212
|
* @returns CSS style declaration.
|
209
213
|
*/
|
210
|
-
getComputedStyle(element:
|
214
|
+
getComputedStyle(element: IHTMLElement): CSSStyleDeclaration;
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Returns selection.
|
218
|
+
*
|
219
|
+
* @returns Selection.
|
220
|
+
*/
|
221
|
+
getSelection(): Selection;
|
211
222
|
|
212
223
|
/**
|
213
224
|
* Scrolls to a particular set of coordinates.
|
@@ -225,6 +236,14 @@ export default interface IWindow extends IEventTarget {
|
|
225
236
|
*/
|
226
237
|
scrollTo(x: { top?: number; left?: number; behavior?: string } | number, y?: number): void;
|
227
238
|
|
239
|
+
/**
|
240
|
+
* Returns a new MediaQueryList object that can then be used to determine if the document matches the media query string.
|
241
|
+
*
|
242
|
+
* @param mediaQueryString A string specifying the media query to parse into a MediaQueryList.
|
243
|
+
* @returns A new MediaQueryList.
|
244
|
+
*/
|
245
|
+
matchMedia(mediaQueryString: string): MediaQueryList;
|
246
|
+
|
228
247
|
/**
|
229
248
|
* Sets a timer which executes a function once the timer expires.
|
230
249
|
*
|
@@ -0,0 +1,62 @@
|
|
1
|
+
export default `
|
2
|
+
this.ArrayBuffer = globalThis.ArrayBuffer;
|
3
|
+
this.Boolean = globalThis.Boolean;
|
4
|
+
this.DataView = globalThis.DataView;
|
5
|
+
this.Date = globalThis.Date;
|
6
|
+
this.Error = globalThis.Error;
|
7
|
+
this.EvalError = globalThis.EvalError;
|
8
|
+
this.Float32Array = globalThis.Float32Array;
|
9
|
+
this.Float64Array = globalThis.Float64Array;
|
10
|
+
this.GLOBAL = globalThis.GLOBAL;
|
11
|
+
this.Infinity = globalThis.Infinity;
|
12
|
+
this.Int16Array = globalThis.Int16Array;
|
13
|
+
this.Int32Array = globalThis.Int32Array;
|
14
|
+
this.Int8Array = globalThis.Int8Array;
|
15
|
+
this.Intl = globalThis.Intl;
|
16
|
+
this.JSON = globalThis.JSON;
|
17
|
+
this.Map = globalThis.Map;
|
18
|
+
this.Math = globalThis.Math;
|
19
|
+
this.NaN = globalThis.NaN;
|
20
|
+
this.Number = globalThis.Number;
|
21
|
+
this.Promise = globalThis.Promise;
|
22
|
+
this.RangeError = globalThis.RangeError;
|
23
|
+
this.ReferenceError = globalThis.ReferenceError;
|
24
|
+
this.RegExp = globalThis.RegExp;
|
25
|
+
this.Reflect = globalThis.Reflect;
|
26
|
+
this.Set = globalThis.Set;
|
27
|
+
this.Symbol = globalThis.Symbol;
|
28
|
+
this.SyntaxError = globalThis.SyntaxError;
|
29
|
+
this.String = globalThis.String;
|
30
|
+
this.TypeError = globalThis.TypeError;
|
31
|
+
this.URIError = globalThis.URIError;
|
32
|
+
this.Uint16Array = globalThis.Uint16Array;
|
33
|
+
this.Uint32Array = globalThis.Uint32Array;
|
34
|
+
this.Uint8Array = globalThis.Uint8Array;
|
35
|
+
this.Uint8ClampedArray = globalThis.Uint8ClampedArray;
|
36
|
+
this.WeakMap = globalThis.WeakMap;
|
37
|
+
this.WeakSet = globalThis.WeakSet;
|
38
|
+
this.clearImmediate = globalThis.clearImmediate;
|
39
|
+
this.decodeURI = globalThis.decodeURI;
|
40
|
+
this.decodeURIComponent = globalThis.decodeURIComponent;
|
41
|
+
this.encodeURI = globalThis.encodeURI;
|
42
|
+
this.encodeURIComponent = globalThis.encodeURIComponent;
|
43
|
+
this.escape = globalThis.escape;
|
44
|
+
this.global = globalThis.global;
|
45
|
+
this.isFinite = globalThis.isFinite;
|
46
|
+
this.isNaN = globalThis.isNaN;
|
47
|
+
this.parseFloat = globalThis.parseFloat;
|
48
|
+
this.parseInt = globalThis.parseInt;
|
49
|
+
this.process = globalThis.process;
|
50
|
+
this.root = globalThis.root;
|
51
|
+
this.setImmediate = globalThis.setImmediate;
|
52
|
+
this.queueMicrotask = globalThis.queueMicrotask;
|
53
|
+
this.undefined = globalThis.undefined;
|
54
|
+
this.unescape = globalThis.unescape;
|
55
|
+
this.gc = globalThis.gc;
|
56
|
+
this.v8debug = globalThis.v8debug;
|
57
|
+
this.AbortController = globalThis.AbortController;
|
58
|
+
this.AbortSignal = globalThis.AbortSignal;
|
59
|
+
this.Array = globalThis.Array;
|
60
|
+
this.Object = globalThis.Object;
|
61
|
+
this.Function = globalThis.Function;
|
62
|
+
`;
|