happy-dom 2.53.1 → 3.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/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.d.ts +2 -1
- package/lib/config/ElementTag.js +16 -15
- package/lib/config/ElementTag.js.map +1 -1
- package/lib/config/NonImplemenetedElementClasses.js +0 -1
- package/lib/config/NonImplemenetedElementClasses.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 +5 -3
- package/lib/index.js +71 -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.d.ts +42 -0
- package/lib/nodes/html-base-element/HTMLBaseElement.js +62 -0
- package/lib/nodes/html-base-element/HTMLBaseElement.js.map +1 -0
- package/lib/nodes/html-base-element/IHTMLBaseElement.d.ts +19 -0
- package/lib/nodes/html-base-element/IHTMLBaseElement.js +3 -0
- package/lib/nodes/html-base-element/IHTMLBaseElement.js.map +1 -0
- 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.d.ts +17 -6
- package/lib/nodes/html-input-element/HTMLInputElement.js +719 -866
- 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/IHTMLInputElement.d.ts +11 -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/INode.d.ts +1 -0
- package/lib/nodes/node/Node.d.ts +6 -0
- package/lib/nodes/node/Node.js +193 -244
- 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 +84 -0
- package/lib/window/GlobalWindow.js +90 -0
- package/lib/window/GlobalWindow.js.map +1 -0
- package/lib/window/IWindow.d.ts +31 -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 +72 -105
- package/lib/window/Window.js +269 -489
- 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/config/ElementTag.ts +2 -1
- package/src/config/NonImplemenetedElementClasses.ts +0 -1
- 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 +3 -3
- package/src/index.ts +7 -3
- package/src/nodes/document/Document.ts +4 -4
- package/src/nodes/document/IDocument.ts +2 -2
- package/src/nodes/html-base-element/HTMLBaseElement.ts +61 -0
- package/src/nodes/html-base-element/IHTMLBaseElement.ts +21 -0
- package/src/nodes/html-input-element/HTMLInputElement.ts +37 -12
- package/src/nodes/html-input-element/IHTMLInputElement.ts +13 -1
- package/src/nodes/html-link-element/HTMLLinkElement.ts +8 -2
- package/src/nodes/html-script-element/ScriptUtility.ts +4 -4
- package/src/nodes/node/INode.ts +1 -0
- package/src/nodes/node/Node.ts +14 -0
- package/src/window/GlobalWindow.ts +82 -0
- package/src/window/IWindow.ts +26 -12
- package/src/window/VMGlobalPropertyScript.ts +62 -0
- package/src/window/Window.ts +106 -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
package/lib/window/Window.js
CHANGED
@@ -1,19 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
3
|
if (k2 === undefined) k2 = k;
|
19
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
@@ -37,490 +22,296 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
37
22
|
__setModuleDefault(result, mod);
|
38
23
|
return result;
|
39
24
|
};
|
40
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
41
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
42
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
43
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
44
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
45
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
47
|
-
});
|
48
|
-
};
|
49
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
50
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
51
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
52
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
53
|
-
function step(op) {
|
54
|
-
if (f) throw new TypeError("Generator is already executing.");
|
55
|
-
while (_) try {
|
56
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
57
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
58
|
-
switch (op[0]) {
|
59
|
-
case 0: case 1: t = op; break;
|
60
|
-
case 4: _.label++; return { value: op[1], done: false };
|
61
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
62
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
63
|
-
default:
|
64
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
65
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
66
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
67
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
68
|
-
if (t[2]) _.ops.pop();
|
69
|
-
_.trys.pop(); continue;
|
70
|
-
}
|
71
|
-
op = body.call(thisArg, _);
|
72
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
73
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
74
|
-
}
|
75
|
-
};
|
76
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
77
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
78
27
|
};
|
79
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
29
|
+
const CustomElementRegistry_1 = __importDefault(require("../custom-element/CustomElementRegistry"));
|
30
|
+
const Document_1 = __importDefault(require("../nodes/document/Document"));
|
31
|
+
const HTMLDocument_1 = __importDefault(require("../nodes/html-document/HTMLDocument"));
|
32
|
+
const XMLDocument_1 = __importDefault(require("../nodes/xml-document/XMLDocument"));
|
33
|
+
const SVGDocument_1 = __importDefault(require("../nodes/svg-document/SVGDocument"));
|
34
|
+
const Node_1 = __importDefault(require("../nodes/node/Node"));
|
35
|
+
const NodeFilter_1 = __importDefault(require("../tree-walker/NodeFilter"));
|
36
|
+
const Text_1 = __importDefault(require("../nodes/text/Text"));
|
37
|
+
const Comment_1 = __importDefault(require("../nodes/comment/Comment"));
|
38
|
+
const ShadowRoot_1 = __importDefault(require("../nodes/shadow-root/ShadowRoot"));
|
39
|
+
const Element_1 = __importDefault(require("../nodes/element/Element"));
|
40
|
+
const HTMLTemplateElement_1 = __importDefault(require("../nodes/html-template-element/HTMLTemplateElement"));
|
41
|
+
const HTMLFormElement_1 = __importDefault(require("../nodes/html-form-element/HTMLFormElement"));
|
42
|
+
const HTMLElement_1 = __importDefault(require("../nodes/html-element/HTMLElement"));
|
43
|
+
const HTMLUnknownElement_1 = __importDefault(require("../nodes/html-unknown-element/HTMLUnknownElement"));
|
44
|
+
const HTMLInputElement_1 = __importDefault(require("../nodes/html-input-element/HTMLInputElement"));
|
45
|
+
const HTMLTextAreaElement_1 = __importDefault(require("../nodes/html-text-area-element/HTMLTextAreaElement"));
|
46
|
+
const HTMLLinkElement_1 = __importDefault(require("../nodes/html-link-element/HTMLLinkElement"));
|
47
|
+
const HTMLStyleElement_1 = __importDefault(require("../nodes/html-style-element/HTMLStyleElement"));
|
48
|
+
const HTMLSlotElement_1 = __importDefault(require("../nodes/html-slot-element/HTMLSlotElement"));
|
49
|
+
const HTMLLabelElement_1 = __importDefault(require("../nodes/html-label-element/HTMLLabelElement"));
|
50
|
+
const HTMLMetaElement_1 = __importDefault(require("../nodes/html-meta-element/HTMLMetaElement"));
|
51
|
+
const HTMLBaseElement_1 = __importDefault(require("../nodes/html-base-element/HTMLBaseElement"));
|
52
|
+
const SVGSVGElement_1 = __importDefault(require("../nodes/svg-element/SVGSVGElement"));
|
53
|
+
const SVGElement_1 = __importDefault(require("../nodes/svg-element/SVGElement"));
|
54
|
+
const HTMLScriptElement_1 = __importDefault(require("../nodes/html-script-element/HTMLScriptElement"));
|
55
|
+
const HTMLImageElement_1 = __importDefault(require("../nodes/html-image-element/HTMLImageElement"));
|
56
|
+
const Image_1 = __importDefault(require("../nodes/html-image-element/Image"));
|
57
|
+
const DocumentFragment_1 = __importDefault(require("../nodes/document-fragment/DocumentFragment"));
|
58
|
+
const CharacterData_1 = __importDefault(require("../nodes/character-data/CharacterData"));
|
59
|
+
const TreeWalker_1 = __importDefault(require("../tree-walker/TreeWalker"));
|
60
|
+
const Event_1 = __importDefault(require("../event/Event"));
|
61
|
+
const CustomEvent_1 = __importDefault(require("../event/events/CustomEvent"));
|
62
|
+
const AnimationEvent_1 = __importDefault(require("../event/events/AnimationEvent"));
|
63
|
+
const KeyboardEvent_1 = __importDefault(require("../event/events/KeyboardEvent"));
|
64
|
+
const ProgressEvent_1 = __importDefault(require("../event/events/ProgressEvent"));
|
65
|
+
const EventTarget_1 = __importDefault(require("../event/EventTarget"));
|
66
|
+
const URL_1 = __importDefault(require("../location/URL"));
|
67
|
+
const Location_1 = __importDefault(require("../location/Location"));
|
68
|
+
const NonImplementedEventTypes_1 = __importDefault(require("../event/NonImplementedEventTypes"));
|
69
|
+
const MutationObserver_1 = __importDefault(require("../mutation-observer/MutationObserver"));
|
70
|
+
const NonImplemenetedElementClasses_1 = __importDefault(require("../config/NonImplemenetedElementClasses"));
|
71
|
+
const DOMParser_1 = __importDefault(require("../dom-parser/DOMParser"));
|
72
|
+
const XMLSerializer_1 = __importDefault(require("../xml-serializer/XMLSerializer"));
|
73
|
+
const ResizeObserver_1 = __importDefault(require("../resize-observer/ResizeObserver"));
|
74
|
+
const Blob_1 = __importDefault(require("../file/Blob"));
|
75
|
+
const File_1 = __importDefault(require("../file/File"));
|
76
|
+
const DOMException_1 = __importDefault(require("../exception/DOMException"));
|
77
|
+
const FileReader_1 = __importDefault(require("../file/FileReader"));
|
78
|
+
const History_1 = __importDefault(require("../history/History"));
|
79
|
+
const CSSStyleSheet_1 = __importDefault(require("../css/CSSStyleSheet"));
|
80
|
+
const CSSStyleDeclaration_1 = __importDefault(require("../css/CSSStyleDeclaration"));
|
81
|
+
const CSS_1 = __importDefault(require("../css/CSS"));
|
82
|
+
const CSSUnitValue_1 = __importDefault(require("../css/CSSUnitValue"));
|
83
|
+
const MouseEvent_1 = __importDefault(require("../event/events/MouseEvent"));
|
84
|
+
const PointerEvent_1 = __importDefault(require("../event/events/PointerEvent"));
|
85
|
+
const FocusEvent_1 = __importDefault(require("../event/events/FocusEvent"));
|
86
|
+
const WheelEvent_1 = __importDefault(require("../event/events/WheelEvent"));
|
87
|
+
const DataTransfer_1 = __importDefault(require("../event/DataTransfer"));
|
88
|
+
const DataTransferItem_1 = __importDefault(require("../event/DataTransferItem"));
|
89
|
+
const DataTransferItemList_1 = __importDefault(require("../event/DataTransferItemList"));
|
90
|
+
const InputEvent_1 = __importDefault(require("../event/events/InputEvent"));
|
91
|
+
const UIEvent_1 = __importDefault(require("../event/UIEvent"));
|
92
|
+
const ErrorEvent_1 = __importDefault(require("../event/events/ErrorEvent"));
|
93
|
+
const StorageEvent_1 = __importDefault(require("../event/events/StorageEvent"));
|
94
|
+
const Screen_1 = __importDefault(require("../screen/Screen"));
|
95
|
+
const AsyncTaskManager_1 = __importDefault(require("../async-task-manager/AsyncTaskManager"));
|
96
|
+
const Headers_1 = __importDefault(require("../fetch/Headers"));
|
97
|
+
const Request_1 = __importDefault(require("../fetch/Request"));
|
98
|
+
const Response_1 = __importDefault(require("../fetch/Response"));
|
99
|
+
const Storage_1 = __importDefault(require("../storage/Storage"));
|
100
|
+
const HTMLCollection_1 = __importDefault(require("../nodes/element/HTMLCollection"));
|
101
|
+
const NodeList_1 = __importDefault(require("../nodes/node/NodeList"));
|
102
|
+
const MediaQueryList_1 = __importDefault(require("../match-media/MediaQueryList"));
|
103
|
+
const Selection_1 = __importDefault(require("../selection/Selection"));
|
104
|
+
const Navigator_1 = __importDefault(require("../navigator/Navigator"));
|
105
|
+
const MimeType_1 = __importDefault(require("../navigator/MimeType"));
|
106
|
+
const MimeTypeArray_1 = __importDefault(require("../navigator/MimeTypeArray"));
|
107
|
+
const Plugin_1 = __importDefault(require("../navigator/Plugin"));
|
108
|
+
const PluginArray_1 = __importDefault(require("../navigator/PluginArray"));
|
109
|
+
const url_1 = require("url");
|
110
|
+
const FetchHandler_1 = __importDefault(require("../fetch/FetchHandler"));
|
111
|
+
const VMGlobalPropertyScript_1 = __importDefault(require("./VMGlobalPropertyScript"));
|
112
|
+
const PerfHooks = __importStar(require("perf_hooks"));
|
113
|
+
const vm_1 = __importDefault(require("vm"));
|
114
|
+
const buffer_1 = require("buffer");
|
159
115
|
/**
|
160
|
-
*
|
116
|
+
* Browser window.
|
117
|
+
*
|
118
|
+
* Reference:
|
119
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Window.
|
161
120
|
*/
|
162
|
-
|
163
|
-
__extends(Window, _super);
|
121
|
+
class Window extends EventTarget_1.default {
|
164
122
|
/**
|
165
123
|
* Constructor.
|
166
124
|
*/
|
167
|
-
|
168
|
-
|
125
|
+
constructor() {
|
126
|
+
super();
|
169
127
|
// Public Properties
|
170
|
-
|
171
|
-
whenAsyncComplete:
|
172
|
-
return
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
}
|
177
|
-
});
|
178
|
-
}); },
|
179
|
-
cancelAsync: function () {
|
180
|
-
_this.happyDOM.asyncTaskManager.cancelAll();
|
128
|
+
this.happyDOM = {
|
129
|
+
whenAsyncComplete: async () => {
|
130
|
+
return await this.happyDOM.asyncTaskManager.whenComplete();
|
131
|
+
},
|
132
|
+
cancelAsync: () => {
|
133
|
+
this.happyDOM.asyncTaskManager.cancelAll();
|
181
134
|
},
|
182
135
|
asyncTaskManager: new AsyncTaskManager_1.default()
|
183
136
|
};
|
184
137
|
// Global classes
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
138
|
+
this.Node = Node_1.default;
|
139
|
+
this.HTMLElement = HTMLElement_1.default;
|
140
|
+
this.HTMLUnknownElement = HTMLUnknownElement_1.default;
|
141
|
+
this.HTMLTemplateElement = HTMLTemplateElement_1.default;
|
142
|
+
this.HTMLFormElement = HTMLFormElement_1.default;
|
143
|
+
this.HTMLInputElement = HTMLInputElement_1.default;
|
144
|
+
this.HTMLTextAreaElement = HTMLTextAreaElement_1.default;
|
145
|
+
this.HTMLImageElement = HTMLImageElement_1.default;
|
146
|
+
this.Image = Image_1.default;
|
147
|
+
this.HTMLScriptElement = HTMLScriptElement_1.default;
|
148
|
+
this.HTMLLinkElement = HTMLLinkElement_1.default;
|
149
|
+
this.HTMLStyleElement = HTMLStyleElement_1.default;
|
150
|
+
this.HTMLLabelElement = HTMLLabelElement_1.default;
|
151
|
+
this.HTMLSlotElement = HTMLSlotElement_1.default;
|
152
|
+
this.HTMLMetaElement = HTMLMetaElement_1.default;
|
153
|
+
this.HTMLBaseElement = HTMLBaseElement_1.default;
|
154
|
+
this.SVGSVGElement = SVGSVGElement_1.default;
|
155
|
+
this.SVGElement = SVGElement_1.default;
|
156
|
+
this.Text = Text_1.default;
|
157
|
+
this.Comment = Comment_1.default;
|
158
|
+
this.ShadowRoot = ShadowRoot_1.default;
|
159
|
+
this.Element = Element_1.default;
|
160
|
+
this.DocumentFragment = DocumentFragment_1.default;
|
161
|
+
this.CharacterData = CharacterData_1.default;
|
162
|
+
this.NodeFilter = NodeFilter_1.default;
|
163
|
+
this.TreeWalker = TreeWalker_1.default;
|
164
|
+
this.DOMParser = DOMParser_1.default;
|
165
|
+
this.MutationObserver = MutationObserver_1.default;
|
166
|
+
this.Document = Document_1.default;
|
167
|
+
this.HTMLDocument = HTMLDocument_1.default;
|
168
|
+
this.XMLDocument = XMLDocument_1.default;
|
169
|
+
this.SVGDocument = SVGDocument_1.default;
|
170
|
+
this.Event = Event_1.default;
|
171
|
+
this.UIEvent = UIEvent_1.default;
|
172
|
+
this.CustomEvent = CustomEvent_1.default;
|
173
|
+
this.AnimationEvent = AnimationEvent_1.default;
|
174
|
+
this.KeyboardEvent = KeyboardEvent_1.default;
|
175
|
+
this.MouseEvent = MouseEvent_1.default;
|
176
|
+
this.PointerEvent = PointerEvent_1.default;
|
177
|
+
this.FocusEvent = FocusEvent_1.default;
|
178
|
+
this.WheelEvent = WheelEvent_1.default;
|
179
|
+
this.InputEvent = InputEvent_1.default;
|
180
|
+
this.ErrorEvent = ErrorEvent_1.default;
|
181
|
+
this.StorageEvent = StorageEvent_1.default;
|
182
|
+
this.ProgressEvent = ProgressEvent_1.default;
|
183
|
+
this.EventTarget = EventTarget_1.default;
|
184
|
+
this.DataTransfer = DataTransfer_1.default;
|
185
|
+
this.DataTransferItem = DataTransferItem_1.default;
|
186
|
+
this.DataTransferItemList = DataTransferItemList_1.default;
|
187
|
+
this.URL = URL_1.default;
|
188
|
+
this.Location = Location_1.default;
|
189
|
+
this.CustomElementRegistry = CustomElementRegistry_1.default;
|
190
|
+
this.Window = this.constructor;
|
191
|
+
this.XMLSerializer = XMLSerializer_1.default;
|
192
|
+
this.ResizeObserver = ResizeObserver_1.default;
|
193
|
+
this.CSSStyleSheet = CSSStyleSheet_1.default;
|
194
|
+
this.Blob = Blob_1.default;
|
195
|
+
this.File = File_1.default;
|
196
|
+
this.FileReader = FileReader_1.default;
|
197
|
+
this.DOMException = DOMException_1.default;
|
198
|
+
this.History = History_1.default;
|
199
|
+
this.Screen = Screen_1.default;
|
200
|
+
this.Storage = Storage_1.default;
|
201
|
+
this.URLSearchParams = url_1.URLSearchParams;
|
202
|
+
this.HTMLCollection = HTMLCollection_1.default;
|
203
|
+
this.NodeList = NodeList_1.default;
|
204
|
+
this.MediaQueryList = MediaQueryList_1.default;
|
205
|
+
this.CSSUnitValue = CSSUnitValue_1.default;
|
206
|
+
this.Selection = Selection_1.default;
|
207
|
+
this.Navigator = Navigator_1.default;
|
208
|
+
this.MimeType = MimeType_1.default;
|
209
|
+
this.MimeTypeArray = MimeTypeArray_1.default;
|
210
|
+
this.Plugin = Plugin_1.default;
|
211
|
+
this.PluginArray = PluginArray_1.default;
|
212
|
+
this.Headers = Headers_1.default;
|
213
|
+
this.Request = Request_1.default;
|
214
|
+
this.Response = Response_1.default;
|
258
215
|
// Events
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
_this.Date = global ? global.Date : null;
|
284
|
-
_this.Error = global ? global.Error : null;
|
285
|
-
_this.EvalError = global ? global.EvalError : null;
|
286
|
-
_this.Float32Array = global ? global.Float32Array : null;
|
287
|
-
_this.Float64Array = global ? global.Float64Array : null;
|
288
|
-
_this.GLOBAL = null;
|
289
|
-
_this.Infinity = global ? global.Infinity : null;
|
290
|
-
_this.Int16Array = global ? global.Int16Array : null;
|
291
|
-
_this.Int32Array = global ? global.Int32Array : null;
|
292
|
-
_this.Int8Array = global ? global.Int8Array : null;
|
293
|
-
_this.Intl = global ? global.Intl : null;
|
294
|
-
_this.JSON = global ? global.JSON : null;
|
295
|
-
_this.Map = global ? global.Map : null;
|
296
|
-
_this.Math = global ? global.Math : null;
|
297
|
-
_this.NaN = global ? global.NaN : null;
|
298
|
-
_this.Number = global ? global.Number : null;
|
299
|
-
_this.Promise = global ? global.Promise : null;
|
300
|
-
_this.RangeError = global ? global.RangeError : null;
|
301
|
-
_this.ReferenceError = global ? global.ReferenceError : null;
|
302
|
-
_this.RegExp = global ? global.RegExp : null;
|
303
|
-
_this.Reflect = global ? global.Reflect : null;
|
304
|
-
_this.Set = global ? global.Set : null;
|
305
|
-
_this.Symbol = global ? global.Symbol : null;
|
306
|
-
_this.SyntaxError = global ? global.SyntaxError : null;
|
307
|
-
_this.String = global ? global.String : null;
|
308
|
-
_this.TypeError = global ? global.TypeError : null;
|
309
|
-
_this.URIError = global ? global.URIError : null;
|
310
|
-
_this.Uint16Array = global ? global.Uint16Array : null;
|
311
|
-
_this.Uint32Array = global ? global.Uint32Array : null;
|
312
|
-
_this.Uint8Array = global ? global.Uint8Array : null;
|
313
|
-
_this.Uint8ClampedArray = global ? global.Uint8ClampedArray : null;
|
314
|
-
_this.WeakMap = global ? global.WeakMap : null;
|
315
|
-
_this.WeakSet = global ? global.WeakSet : null;
|
316
|
-
_this.clearImmediate = null;
|
317
|
-
_this.decodeURI = global ? global.decodeURI : null;
|
318
|
-
_this.decodeURIComponent = global ? global.decodeURIComponent : null;
|
319
|
-
_this.encodeURI = global ? global.encodeURI : null;
|
320
|
-
_this.encodeURIComponent = global ? global.encodeURIComponent : null;
|
321
|
-
_this.escape = global ? global.escape : null;
|
322
|
-
_this.global = null;
|
323
|
-
_this.isFinite = global ? global.isFinite : null;
|
324
|
-
_this.isNaN = global ? global.isNaN : null;
|
325
|
-
_this.parseFloat = global ? global.parseFloat : null;
|
326
|
-
_this.parseInt = global ? global.parseInt : null;
|
327
|
-
_this.process = null;
|
328
|
-
_this.root = null;
|
329
|
-
_this.setImmediate = null;
|
330
|
-
_this.queueMicrotask = global ? global.queueMicrotask : null;
|
331
|
-
_this.undefined = global ? global.undefined : null;
|
332
|
-
_this.unescape = global ? global.unescape : null;
|
333
|
-
_this.gc = null;
|
334
|
-
_this.v8debug = null;
|
335
|
-
_this.AbortController = global ? global.AbortController : null;
|
336
|
-
_this.AbortSignal = global ? global.AbortSignal : null;
|
337
|
-
// Private properties
|
338
|
-
_this._objectClass = null;
|
339
|
-
_this._arrayClass = null;
|
340
|
-
_this._functionClass = null;
|
341
|
-
_this.document = new HTMLDocument_1.default();
|
342
|
-
_this.document.defaultView = _this;
|
343
|
-
_this.document._readyStateManager.whenComplete().then(function () {
|
344
|
-
_this.dispatchEvent(new Event_1.default('load'));
|
216
|
+
this.onload = null;
|
217
|
+
this.onerror = null;
|
218
|
+
this.customElements = new CustomElementRegistry_1.default();
|
219
|
+
this.location = new Location_1.default();
|
220
|
+
this.history = new History_1.default();
|
221
|
+
this.navigator = new Navigator_1.default();
|
222
|
+
this.console = console;
|
223
|
+
this.self = this;
|
224
|
+
this.top = this;
|
225
|
+
this.parent = this;
|
226
|
+
this.window = this;
|
227
|
+
this.globalThis = this;
|
228
|
+
this.screen = new Screen_1.default();
|
229
|
+
this.innerWidth = 1024;
|
230
|
+
this.innerHeight = 768;
|
231
|
+
this.devicePixelRatio = 1;
|
232
|
+
this.sessionStorage = new Storage_1.default();
|
233
|
+
this.localStorage = new Storage_1.default();
|
234
|
+
this.performance = PerfHooks.performance;
|
235
|
+
this.Buffer = buffer_1.Buffer;
|
236
|
+
this.document = new HTMLDocument_1.default();
|
237
|
+
this.document.defaultView = this;
|
238
|
+
this.document._readyStateManager.whenComplete().then(() => {
|
239
|
+
this.dispatchEvent(new Event_1.default('load'));
|
345
240
|
});
|
346
|
-
DOMParser_1.default._ownerDocument =
|
347
|
-
FileReader_1.default._ownerDocument =
|
348
|
-
Image_1.default.ownerDocument =
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
241
|
+
DOMParser_1.default._ownerDocument = this.document;
|
242
|
+
FileReader_1.default._ownerDocument = this.document;
|
243
|
+
Image_1.default.ownerDocument = this.document;
|
244
|
+
Request_1.default._ownerDocument = this.document;
|
245
|
+
Response_1.default._ownerDocument = this.document;
|
246
|
+
for (const eventType of NonImplementedEventTypes_1.default) {
|
247
|
+
if (!this[eventType]) {
|
248
|
+
this[eventType] = Event_1.default;
|
353
249
|
}
|
354
250
|
}
|
355
|
-
for (
|
356
|
-
|
357
|
-
|
358
|
-
_this[className] = HTMLElement_1.default;
|
251
|
+
for (const className of NonImplemenetedElementClasses_1.default) {
|
252
|
+
if (!this[className]) {
|
253
|
+
this[className] = HTMLElement_1.default;
|
359
254
|
}
|
360
255
|
}
|
361
256
|
// Binds all methods to "this", so that it will use the correct context when called globally.
|
362
|
-
for (
|
363
|
-
|
364
|
-
|
365
|
-
_this[key] = _this[key].bind(_this);
|
257
|
+
for (const key of Object.getOwnPropertyNames(this.constructor.prototype)) {
|
258
|
+
if (key !== 'constructor' && key !== 'CSS' && typeof this[key] === 'function') {
|
259
|
+
this[key] = this[key].bind(this);
|
366
260
|
}
|
367
261
|
}
|
368
|
-
|
262
|
+
// Only contextify if there isn't any sub-class handling globals (like GlobalWindow)
|
263
|
+
if (this.Array === undefined && !vm_1.default.isContext(this)) {
|
264
|
+
vm_1.default.createContext(this);
|
265
|
+
// Sets global properties from the VM to the Window object.
|
266
|
+
// Otherwise "this.Array" will be undefined for example.
|
267
|
+
vm_1.default.runInContext(VMGlobalPropertyScript_1.default, this);
|
268
|
+
}
|
269
|
+
}
|
270
|
+
/**
|
271
|
+
* The CSS interface holds useful CSS-related methods.
|
272
|
+
*
|
273
|
+
* @returns CSS interface.
|
274
|
+
*/
|
275
|
+
get CSS() {
|
276
|
+
return new CSS_1.default();
|
369
277
|
}
|
370
|
-
Object.defineProperty(Window.prototype, "Object", {
|
371
|
-
/**
|
372
|
-
* Returns Object class.
|
373
|
-
*
|
374
|
-
* @returns Object class.
|
375
|
-
*/
|
376
|
-
get: function () {
|
377
|
-
if (this._objectClass) {
|
378
|
-
return this._objectClass;
|
379
|
-
}
|
380
|
-
// When inside a VM global.Object is not the same as ({}).constructor
|
381
|
-
// We will therefore run the code inside the VM to get the real constructor
|
382
|
-
this._objectClass = this.eval('({}).constructor');
|
383
|
-
return this._objectClass;
|
384
|
-
},
|
385
|
-
enumerable: false,
|
386
|
-
configurable: true
|
387
|
-
});
|
388
|
-
Object.defineProperty(Window.prototype, "Array", {
|
389
|
-
/**
|
390
|
-
* Returns Array class.
|
391
|
-
*
|
392
|
-
* @returns Array class.
|
393
|
-
*/
|
394
|
-
get: function () {
|
395
|
-
if (this._arrayClass) {
|
396
|
-
return this._arrayClass;
|
397
|
-
}
|
398
|
-
// When inside a VM global.Object is not the same as [].constructor
|
399
|
-
// We will therefore run the code inside the VM to get the real constructor
|
400
|
-
this._arrayClass = this.eval('[].constructor');
|
401
|
-
return this._arrayClass;
|
402
|
-
},
|
403
|
-
enumerable: false,
|
404
|
-
configurable: true
|
405
|
-
});
|
406
|
-
Object.defineProperty(Window.prototype, "Function", {
|
407
|
-
/**
|
408
|
-
* Returns Function class.
|
409
|
-
*
|
410
|
-
* @returns Function class.
|
411
|
-
*/
|
412
|
-
get: function () {
|
413
|
-
if (this._functionClass) {
|
414
|
-
return this._functionClass;
|
415
|
-
}
|
416
|
-
// When inside a VM global.Function is not the same as (() => {}).constructor
|
417
|
-
// We will therefore run the code inside the VM to get the real constructor
|
418
|
-
this._functionClass = this.eval('(() => {}).constructor');
|
419
|
-
return this._functionClass;
|
420
|
-
},
|
421
|
-
enumerable: false,
|
422
|
-
configurable: true
|
423
|
-
});
|
424
|
-
Object.defineProperty(Window.prototype, "CSS", {
|
425
|
-
/**
|
426
|
-
* The CSS interface holds useful CSS-related methods.
|
427
|
-
*
|
428
|
-
* @returns CSS interface.
|
429
|
-
*/
|
430
|
-
get: function () {
|
431
|
-
return new CSS_1.default();
|
432
|
-
},
|
433
|
-
enumerable: false,
|
434
|
-
configurable: true
|
435
|
-
});
|
436
|
-
Object.defineProperty(Window.prototype, "Headers", {
|
437
|
-
/**
|
438
|
-
* Returns Headers class.
|
439
|
-
*
|
440
|
-
* @returns Headers.
|
441
|
-
*/
|
442
|
-
get: function () {
|
443
|
-
return require('../fetch/Headers').default;
|
444
|
-
},
|
445
|
-
enumerable: false,
|
446
|
-
configurable: true
|
447
|
-
});
|
448
|
-
Object.defineProperty(Window.prototype, "Request", {
|
449
|
-
/**
|
450
|
-
* Returns Request class.
|
451
|
-
*
|
452
|
-
* @returns Request.
|
453
|
-
*/
|
454
|
-
get: function () {
|
455
|
-
var Request = require('../fetch/Request').default;
|
456
|
-
Request._ownerDocument = Request._ownerDocument || this.document;
|
457
|
-
return Request;
|
458
|
-
},
|
459
|
-
enumerable: false,
|
460
|
-
configurable: true
|
461
|
-
});
|
462
|
-
Object.defineProperty(Window.prototype, "Response", {
|
463
|
-
/**
|
464
|
-
* Returns Response class.
|
465
|
-
*
|
466
|
-
* @returns Response.
|
467
|
-
*/
|
468
|
-
get: function () {
|
469
|
-
var Response = require('../fetch/Response').default;
|
470
|
-
Response._ownerDocument = Response._ownerDocument || this.document;
|
471
|
-
return Response;
|
472
|
-
},
|
473
|
-
enumerable: false,
|
474
|
-
configurable: true
|
475
|
-
});
|
476
278
|
/**
|
477
279
|
* Evaluates code.
|
478
280
|
*
|
281
|
+
* @override
|
479
282
|
* @param code Code.
|
480
283
|
* @returns Result.
|
481
284
|
*/
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
try {
|
486
|
-
vmExists = !!require.resolve('vm');
|
487
|
-
}
|
488
|
-
catch (error) {
|
489
|
-
// Ignore error;
|
285
|
+
eval(code) {
|
286
|
+
if (vm_1.default.isContext(this)) {
|
287
|
+
return vm_1.default.runInContext(code, this);
|
490
288
|
}
|
491
|
-
|
492
|
-
|
493
|
-
}
|
494
|
-
if (vm && vm.isContext(this)) {
|
495
|
-
return vm.runInContext(code, this);
|
496
|
-
}
|
497
|
-
return global.eval(code);
|
498
|
-
};
|
289
|
+
return eval(code);
|
290
|
+
}
|
499
291
|
/**
|
500
292
|
* Returns an object containing the values of all CSS properties of an element.
|
501
293
|
*
|
502
294
|
* @param element Element.
|
503
295
|
* @returns CSS style declaration.
|
504
296
|
*/
|
505
|
-
|
297
|
+
getComputedStyle(element) {
|
506
298
|
return new CSSStyleDeclaration_1.default(element._attributes, element);
|
507
|
-
}
|
299
|
+
}
|
508
300
|
/**
|
509
301
|
* Scrolls to a particular set of coordinates.
|
510
302
|
*
|
511
303
|
* @param x X position or options object.
|
512
304
|
* @param y Y position.
|
513
305
|
*/
|
514
|
-
|
515
|
-
var _this = this;
|
306
|
+
scroll(x, y) {
|
516
307
|
if (typeof x === 'object') {
|
517
308
|
if (x.behavior === 'smooth') {
|
518
|
-
this.setTimeout(
|
309
|
+
this.setTimeout(() => {
|
519
310
|
if (x.top !== undefined) {
|
520
|
-
|
311
|
+
this.document.documentElement.scrollTop = x.top;
|
521
312
|
}
|
522
313
|
if (x.left !== undefined) {
|
523
|
-
|
314
|
+
this.document.documentElement.scrollLeft = x.left;
|
524
315
|
}
|
525
316
|
});
|
526
317
|
}
|
@@ -537,27 +328,27 @@ var Window = /** @class */ (function (_super) {
|
|
537
328
|
this.document.documentElement.scrollLeft = x;
|
538
329
|
this.document.documentElement.scrollTop = y;
|
539
330
|
}
|
540
|
-
}
|
331
|
+
}
|
541
332
|
/**
|
542
333
|
* Scrolls to a particular set of coordinates.
|
543
334
|
*
|
544
335
|
* @param x X position or options object.
|
545
336
|
* @param y Y position.
|
546
337
|
*/
|
547
|
-
|
338
|
+
scrollTo(x, y) {
|
548
339
|
this.scroll(x, y);
|
549
|
-
}
|
340
|
+
}
|
550
341
|
/**
|
551
342
|
* Returns a new MediaQueryList object that can then be used to determine if the document matches the media query string.
|
552
343
|
*
|
553
344
|
* @param mediaQueryString A string specifying the media query to parse into a MediaQueryList.
|
554
345
|
* @returns A new MediaQueryList.
|
555
346
|
*/
|
556
|
-
|
557
|
-
|
347
|
+
matchMedia(mediaQueryString) {
|
348
|
+
const mediaQueryList = new MediaQueryList_1.default();
|
558
349
|
mediaQueryList._media = mediaQueryString;
|
559
350
|
return mediaQueryList;
|
560
|
-
}
|
351
|
+
}
|
561
352
|
/**
|
562
353
|
* Sets a timer which executes a function once the timer expires.
|
563
354
|
*
|
@@ -566,26 +357,24 @@ var Window = /** @class */ (function (_super) {
|
|
566
357
|
* @param [delay=0] Delay in ms.
|
567
358
|
* @returns Timeout ID.
|
568
359
|
*/
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
var id = global.setTimeout(function () {
|
573
|
-
_this.happyDOM.asyncTaskManager.endTimer(id);
|
360
|
+
setTimeout(callback, delay = 0) {
|
361
|
+
const id = setTimeout(() => {
|
362
|
+
this.happyDOM.asyncTaskManager.endTimer(id);
|
574
363
|
callback();
|
575
364
|
}, delay);
|
576
365
|
this.happyDOM.asyncTaskManager.startTimer(id);
|
577
366
|
return id;
|
578
|
-
}
|
367
|
+
}
|
579
368
|
/**
|
580
369
|
* Cancels a timeout previously established by calling setTimeout().
|
581
370
|
*
|
582
371
|
* @override
|
583
372
|
* @param id ID of the timeout.
|
584
373
|
*/
|
585
|
-
|
586
|
-
|
374
|
+
clearTimeout(id) {
|
375
|
+
clearTimeout(id);
|
587
376
|
this.happyDOM.asyncTaskManager.endTimer(id);
|
588
|
-
}
|
377
|
+
}
|
589
378
|
/**
|
590
379
|
* Calls a function with a fixed time delay between each call.
|
591
380
|
*
|
@@ -594,22 +383,21 @@ var Window = /** @class */ (function (_super) {
|
|
594
383
|
* @param [delay=0] Delay in ms.
|
595
384
|
* @returns Interval ID.
|
596
385
|
*/
|
597
|
-
|
598
|
-
|
599
|
-
var id = global.setInterval(callback, delay);
|
386
|
+
setInterval(callback, delay = 0) {
|
387
|
+
const id = setInterval(callback, delay);
|
600
388
|
this.happyDOM.asyncTaskManager.startTimer(id);
|
601
389
|
return id;
|
602
|
-
}
|
390
|
+
}
|
603
391
|
/**
|
604
392
|
* Cancels a timed repeating action which was previously established by a call to setInterval().
|
605
393
|
*
|
606
394
|
* @override
|
607
395
|
* @param id ID of the interval.
|
608
396
|
*/
|
609
|
-
|
610
|
-
|
397
|
+
clearInterval(id) {
|
398
|
+
clearInterval(id);
|
611
399
|
this.happyDOM.asyncTaskManager.endTimer(id);
|
612
|
-
}
|
400
|
+
}
|
613
401
|
/**
|
614
402
|
* Mock animation frames with timeouts.
|
615
403
|
*
|
@@ -617,20 +405,20 @@ var Window = /** @class */ (function (_super) {
|
|
617
405
|
* @param callback Callback.
|
618
406
|
* @returns Timeout ID.
|
619
407
|
*/
|
620
|
-
|
621
|
-
return this.setTimeout(
|
408
|
+
requestAnimationFrame(callback) {
|
409
|
+
return this.setTimeout(() => {
|
622
410
|
callback(2);
|
623
411
|
});
|
624
|
-
}
|
412
|
+
}
|
625
413
|
/**
|
626
414
|
* Mock animation frames with timeouts.
|
627
415
|
*
|
628
416
|
* @override
|
629
417
|
* @param id Timeout ID.
|
630
418
|
*/
|
631
|
-
|
419
|
+
cancelAnimationFrame(id) {
|
632
420
|
this.clearTimeout(id);
|
633
|
-
}
|
421
|
+
}
|
634
422
|
/**
|
635
423
|
* This method provides an easy, logical way to fetch resources asynchronously across the network.
|
636
424
|
*
|
@@ -639,17 +427,9 @@ var Window = /** @class */ (function (_super) {
|
|
639
427
|
* @param [init] Init.
|
640
428
|
* @returns Promise.
|
641
429
|
*/
|
642
|
-
|
643
|
-
return
|
644
|
-
|
645
|
-
|
646
|
-
case 0: return [4 /*yield*/, FetchHandler_1.default.fetch(this.document, url, init)];
|
647
|
-
case 1: return [2 /*return*/, _a.sent()];
|
648
|
-
}
|
649
|
-
});
|
650
|
-
});
|
651
|
-
};
|
652
|
-
return Window;
|
653
|
-
}(EventTarget_1.default));
|
430
|
+
async fetch(url, init) {
|
431
|
+
return await FetchHandler_1.default.fetch(this.document, url, init);
|
432
|
+
}
|
433
|
+
}
|
654
434
|
exports.default = Window;
|
655
435
|
//# sourceMappingURL=Window.js.map
|