happy-dom 2.55.0 → 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.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 +84 -0
- package/lib/window/GlobalWindow.js +90 -0
- package/lib/window/GlobalWindow.js.map +1 -0
- package/lib/window/IWindow.d.ts +29 -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 +70 -105
- package/lib/window/Window.js +269 -491
- 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 +3 -3
- 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 +82 -0
- package/src/window/IWindow.ts +24 -12
- package/src/window/VMGlobalPropertyScript.ts +62 -0
- package/src/window/Window.ts +104 -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
@@ -1,412 +1,302 @@
|
|
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
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
19
|
-
if (ar || !(i in from)) {
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
21
|
-
ar[i] = from[i];
|
22
|
-
}
|
23
|
-
}
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
25
|
-
};
|
26
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
27
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
28
4
|
};
|
29
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
6
|
+
const HTMLUnknownElement_1 = __importDefault(require("../html-unknown-element/HTMLUnknownElement"));
|
7
|
+
const Text_1 = __importDefault(require("../text/Text"));
|
8
|
+
const Comment_1 = __importDefault(require("../comment/Comment"));
|
9
|
+
const Node_1 = __importDefault(require("../node/Node"));
|
10
|
+
const TreeWalker_1 = __importDefault(require("../../tree-walker/TreeWalker"));
|
11
|
+
const DocumentFragment_1 = __importDefault(require("../document-fragment/DocumentFragment"));
|
12
|
+
const XMLParser_1 = __importDefault(require("../../xml-parser/XMLParser"));
|
13
|
+
const Event_1 = __importDefault(require("../../event/Event"));
|
14
|
+
const DOMImplementation_1 = __importDefault(require("../../dom-implementation/DOMImplementation"));
|
15
|
+
const ElementTag_1 = __importDefault(require("../../config/ElementTag"));
|
16
|
+
const Attr_1 = __importDefault(require("../../attribute/Attr"));
|
17
|
+
const NamespaceURI_1 = __importDefault(require("../../config/NamespaceURI"));
|
18
|
+
const DocumentType_1 = __importDefault(require("../document-type/DocumentType"));
|
19
|
+
const ParentNodeUtility_1 = __importDefault(require("../parent-node/ParentNodeUtility"));
|
20
|
+
const QuerySelector_1 = __importDefault(require("../../query-selector/QuerySelector"));
|
21
|
+
const DOMException_1 = __importDefault(require("../../exception/DOMException"));
|
22
|
+
const CookieUtility_1 = __importDefault(require("../../cookie/CookieUtility"));
|
23
|
+
const HTMLCollectionFactory_1 = __importDefault(require("../element/HTMLCollectionFactory"));
|
24
|
+
const DocumentReadyStateEnum_1 = __importDefault(require("./DocumentReadyStateEnum"));
|
25
|
+
const DocumentReadyStateManager_1 = __importDefault(require("./DocumentReadyStateManager"));
|
26
|
+
const Selection_1 = __importDefault(require("../../selection/Selection"));
|
51
27
|
/**
|
52
28
|
* Document.
|
53
29
|
*/
|
54
|
-
|
55
|
-
__extends(Document, _super);
|
30
|
+
class Document extends Node_1.default {
|
56
31
|
/**
|
57
32
|
* Creates an instance of Document.
|
58
33
|
*/
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
34
|
+
constructor() {
|
35
|
+
super();
|
36
|
+
this.onreadystatechange = null;
|
37
|
+
this.nodeType = Node_1.default.DOCUMENT_NODE;
|
38
|
+
this.adoptedStyleSheets = [];
|
39
|
+
this.children = HTMLCollectionFactory_1.default.create();
|
40
|
+
this.readyState = DocumentReadyStateEnum_1.default.interactive;
|
41
|
+
this.isConnected = true;
|
42
|
+
this._readyStateManager = null;
|
43
|
+
this._activeElement = null;
|
44
|
+
this._isFirstWrite = true;
|
45
|
+
this._isFirstWriteAfterOpen = false;
|
46
|
+
this._defaultView = null;
|
47
|
+
this._cookie = '';
|
48
|
+
this.implementation = new DOMImplementation_1.default();
|
49
|
+
this.implementation._ownerDocument = this;
|
50
|
+
const doctype = this.implementation.createDocumentType('html', '', '');
|
51
|
+
const documentElement = this.createElement('html');
|
52
|
+
const bodyElement = this.createElement('body');
|
53
|
+
const headElement = this.createElement('head');
|
54
|
+
this.appendChild(doctype);
|
55
|
+
this.appendChild(documentElement);
|
81
56
|
documentElement.appendChild(headElement);
|
82
57
|
documentElement.appendChild(bodyElement);
|
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
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
set: function (cookie) {
|
189
|
-
this._cookie = CookieUtility_1.default.getCookieString(this.defaultView.location, this._cookie, cookie);
|
190
|
-
},
|
191
|
-
enumerable: false,
|
192
|
-
configurable: true
|
193
|
-
});
|
194
|
-
Object.defineProperty(Document.prototype, "nodeName", {
|
195
|
-
/**
|
196
|
-
* Node name.
|
197
|
-
*
|
198
|
-
* @returns Node name.
|
199
|
-
*/
|
200
|
-
get: function () {
|
201
|
-
return '#document';
|
202
|
-
},
|
203
|
-
enumerable: false,
|
204
|
-
configurable: true
|
205
|
-
});
|
206
|
-
Object.defineProperty(Document.prototype, "documentElement", {
|
207
|
-
/**
|
208
|
-
* Returns <html> element.
|
209
|
-
*
|
210
|
-
* @returns Element.
|
211
|
-
*/
|
212
|
-
get: function () {
|
213
|
-
return ParentNodeUtility_1.default.getElementByTagName(this, 'html');
|
214
|
-
},
|
215
|
-
enumerable: false,
|
216
|
-
configurable: true
|
217
|
-
});
|
218
|
-
Object.defineProperty(Document.prototype, "doctype", {
|
219
|
-
/**
|
220
|
-
* Returns document type element.
|
221
|
-
*
|
222
|
-
* @returns Document type.
|
223
|
-
*/
|
224
|
-
get: function () {
|
225
|
-
for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
|
226
|
-
var node = _a[_i];
|
227
|
-
if (node instanceof DocumentType_1.default) {
|
228
|
-
return node;
|
229
|
-
}
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* Returns character set.
|
61
|
+
*
|
62
|
+
* @deprecated
|
63
|
+
* @returns Character set.
|
64
|
+
*/
|
65
|
+
get charset() {
|
66
|
+
return this.characterSet;
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* Returns character set.
|
70
|
+
*
|
71
|
+
* @returns Character set.
|
72
|
+
*/
|
73
|
+
get characterSet() {
|
74
|
+
const charset = this.querySelector('meta[charset]')?.getAttributeNS(null, 'charset');
|
75
|
+
return charset ? charset : 'UTF-8';
|
76
|
+
}
|
77
|
+
/**
|
78
|
+
* Returns default view.
|
79
|
+
*
|
80
|
+
* @returns Default view.
|
81
|
+
*/
|
82
|
+
get defaultView() {
|
83
|
+
return this._defaultView;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* Sets a default view.
|
87
|
+
*
|
88
|
+
* @param defaultView Default view.
|
89
|
+
*/
|
90
|
+
set defaultView(defaultView) {
|
91
|
+
this._defaultView = defaultView;
|
92
|
+
this._readyStateManager = new DocumentReadyStateManager_1.default(defaultView);
|
93
|
+
this._readyStateManager.whenComplete().then(() => {
|
94
|
+
this.readyState = DocumentReadyStateEnum_1.default.complete;
|
95
|
+
this.dispatchEvent(new Event_1.default('readystatechange'));
|
96
|
+
});
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* Last element child.
|
100
|
+
*
|
101
|
+
* @returns Element.
|
102
|
+
*/
|
103
|
+
get childElementCount() {
|
104
|
+
return this.children.length;
|
105
|
+
}
|
106
|
+
/**
|
107
|
+
* First element child.
|
108
|
+
*
|
109
|
+
* @returns Element.
|
110
|
+
*/
|
111
|
+
get firstElementChild() {
|
112
|
+
return this.children ? this.children[0] || null : null;
|
113
|
+
}
|
114
|
+
/**
|
115
|
+
* Last element child.
|
116
|
+
*
|
117
|
+
* @returns Element.
|
118
|
+
*/
|
119
|
+
get lastElementChild() {
|
120
|
+
return this.children ? this.children[this.children.length - 1] || null : null;
|
121
|
+
}
|
122
|
+
/**
|
123
|
+
* Returns cookie string.
|
124
|
+
*
|
125
|
+
* @returns Cookie.
|
126
|
+
*/
|
127
|
+
get cookie() {
|
128
|
+
return this._cookie;
|
129
|
+
}
|
130
|
+
/**
|
131
|
+
* Sets a cookie string.
|
132
|
+
*
|
133
|
+
* @param cookie Cookie string.
|
134
|
+
*/
|
135
|
+
set cookie(cookie) {
|
136
|
+
this._cookie = CookieUtility_1.default.getCookieString(this.defaultView.location, this._cookie, cookie);
|
137
|
+
}
|
138
|
+
/**
|
139
|
+
* Node name.
|
140
|
+
*
|
141
|
+
* @returns Node name.
|
142
|
+
*/
|
143
|
+
get nodeName() {
|
144
|
+
return '#document';
|
145
|
+
}
|
146
|
+
/**
|
147
|
+
* Returns <html> element.
|
148
|
+
*
|
149
|
+
* @returns Element.
|
150
|
+
*/
|
151
|
+
get documentElement() {
|
152
|
+
return ParentNodeUtility_1.default.getElementByTagName(this, 'html');
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* Returns document type element.
|
156
|
+
*
|
157
|
+
* @returns Document type.
|
158
|
+
*/
|
159
|
+
get doctype() {
|
160
|
+
for (const node of this.childNodes) {
|
161
|
+
if (node instanceof DocumentType_1.default) {
|
162
|
+
return node;
|
230
163
|
}
|
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
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
* Returns CSS style sheets.
|
263
|
-
*
|
264
|
-
* @returns CSS style sheets.
|
265
|
-
*/
|
266
|
-
get: function () {
|
267
|
-
var styles = (this.querySelectorAll('link[rel="stylesheet"][href],style'));
|
268
|
-
var styleSheets = [];
|
269
|
-
for (var _i = 0, styles_1 = styles; _i < styles_1.length; _i++) {
|
270
|
-
var style = styles_1[_i];
|
271
|
-
var sheet = style.sheet;
|
272
|
-
if (sheet) {
|
273
|
-
styleSheets.push(sheet);
|
274
|
-
}
|
164
|
+
}
|
165
|
+
return null;
|
166
|
+
}
|
167
|
+
/**
|
168
|
+
* Returns <body> element.
|
169
|
+
*
|
170
|
+
* @returns Element.
|
171
|
+
*/
|
172
|
+
get body() {
|
173
|
+
return ParentNodeUtility_1.default.getElementByTagName(this, 'body');
|
174
|
+
}
|
175
|
+
/**
|
176
|
+
* Returns <head> element.
|
177
|
+
*
|
178
|
+
* @returns Element.
|
179
|
+
*/
|
180
|
+
get head() {
|
181
|
+
return ParentNodeUtility_1.default.getElementByTagName(this, 'head');
|
182
|
+
}
|
183
|
+
/**
|
184
|
+
* Returns CSS style sheets.
|
185
|
+
*
|
186
|
+
* @returns CSS style sheets.
|
187
|
+
*/
|
188
|
+
get styleSheets() {
|
189
|
+
const styles = (this.querySelectorAll('link[rel="stylesheet"][href],style'));
|
190
|
+
const styleSheets = [];
|
191
|
+
for (const style of styles) {
|
192
|
+
const sheet = style.sheet;
|
193
|
+
if (sheet) {
|
194
|
+
styleSheets.push(sheet);
|
275
195
|
}
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
while (rootNode !== this) {
|
292
|
-
activeElement = rootNode.host;
|
293
|
-
rootNode = activeElement.getRootNode();
|
294
|
-
}
|
295
|
-
return activeElement;
|
196
|
+
}
|
197
|
+
return styleSheets;
|
198
|
+
}
|
199
|
+
/**
|
200
|
+
* Returns active element.
|
201
|
+
*
|
202
|
+
* @returns Active element.
|
203
|
+
*/
|
204
|
+
get activeElement() {
|
205
|
+
if (this._activeElement) {
|
206
|
+
let rootNode = (this._activeElement.getRootNode());
|
207
|
+
let activeElement = this._activeElement;
|
208
|
+
while (rootNode !== this) {
|
209
|
+
activeElement = rootNode.host;
|
210
|
+
rootNode = activeElement.getRootNode();
|
296
211
|
}
|
297
|
-
return
|
298
|
-
}
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
});
|
326
|
-
Object.defineProperty(Document.prototype, "scripts", {
|
327
|
-
/**
|
328
|
-
* Returns scripts.
|
329
|
-
*
|
330
|
-
* @returns Scripts.
|
331
|
-
*/
|
332
|
-
get: function () {
|
333
|
-
return this.getElementsByTagName('script');
|
334
|
-
},
|
335
|
-
enumerable: false,
|
336
|
-
configurable: true
|
337
|
-
});
|
212
|
+
return activeElement;
|
213
|
+
}
|
214
|
+
return this._activeElement || this.body || this.documentElement || null;
|
215
|
+
}
|
216
|
+
/**
|
217
|
+
* Returns scrolling element.
|
218
|
+
*
|
219
|
+
* @returns Scrolling element.
|
220
|
+
*/
|
221
|
+
get scrollingElement() {
|
222
|
+
return this.documentElement;
|
223
|
+
}
|
224
|
+
/**
|
225
|
+
* Returns location.
|
226
|
+
*
|
227
|
+
* @returns Location.
|
228
|
+
*/
|
229
|
+
get location() {
|
230
|
+
return this._defaultView.location;
|
231
|
+
}
|
232
|
+
/**
|
233
|
+
* Returns scripts.
|
234
|
+
*
|
235
|
+
* @returns Scripts.
|
236
|
+
*/
|
237
|
+
get scripts() {
|
238
|
+
return this.getElementsByTagName('script');
|
239
|
+
}
|
338
240
|
/**
|
339
241
|
* Inserts a set of Node objects or DOMString objects after the last child of the ParentNode. DOMString objects are inserted as equivalent Text nodes.
|
340
242
|
*
|
341
243
|
* @param nodes List of Node or DOMString.
|
342
244
|
*/
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
nodes[_i] = arguments[_i];
|
347
|
-
}
|
348
|
-
ParentNodeUtility_1.default.append.apply(ParentNodeUtility_1.default, __spreadArray([this], nodes, false));
|
349
|
-
};
|
245
|
+
append(...nodes) {
|
246
|
+
ParentNodeUtility_1.default.append(this, ...nodes);
|
247
|
+
}
|
350
248
|
/**
|
351
249
|
* Inserts a set of Node objects or DOMString objects before the first child of the ParentNode. DOMString objects are inserted as equivalent Text nodes.
|
352
250
|
*
|
353
251
|
* @param nodes List of Node or DOMString.
|
354
252
|
*/
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
nodes[_i] = arguments[_i];
|
359
|
-
}
|
360
|
-
ParentNodeUtility_1.default.prepend.apply(ParentNodeUtility_1.default, __spreadArray([this], nodes, false));
|
361
|
-
};
|
253
|
+
prepend(...nodes) {
|
254
|
+
ParentNodeUtility_1.default.prepend(this, ...nodes);
|
255
|
+
}
|
362
256
|
/**
|
363
257
|
* Replaces the existing children of a node with a specified new set of children.
|
364
258
|
*
|
365
259
|
* @param nodes List of Node or DOMString.
|
366
260
|
*/
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
nodes[_i] = arguments[_i];
|
371
|
-
}
|
372
|
-
ParentNodeUtility_1.default.replaceChildren.apply(ParentNodeUtility_1.default, __spreadArray([this], nodes, false));
|
373
|
-
};
|
261
|
+
replaceChildren(...nodes) {
|
262
|
+
ParentNodeUtility_1.default.replaceChildren(this, ...nodes);
|
263
|
+
}
|
374
264
|
/**
|
375
265
|
* Query CSS selector to find matching elments.
|
376
266
|
*
|
377
267
|
* @param selector CSS selector.
|
378
268
|
* @returns Matching elements.
|
379
269
|
*/
|
380
|
-
|
270
|
+
querySelectorAll(selector) {
|
381
271
|
return QuerySelector_1.default.querySelectorAll(this, selector);
|
382
|
-
}
|
272
|
+
}
|
383
273
|
/**
|
384
274
|
* Query CSS Selector to find a matching element.
|
385
275
|
*
|
386
276
|
* @param selector CSS selector.
|
387
277
|
* @returns Matching element.
|
388
278
|
*/
|
389
|
-
|
279
|
+
querySelector(selector) {
|
390
280
|
return QuerySelector_1.default.querySelector(this, selector);
|
391
|
-
}
|
281
|
+
}
|
392
282
|
/**
|
393
283
|
* Returns an elements by class name.
|
394
284
|
*
|
395
285
|
* @param className Tag name.
|
396
286
|
* @returns Matching element.
|
397
287
|
*/
|
398
|
-
|
288
|
+
getElementsByClassName(className) {
|
399
289
|
return ParentNodeUtility_1.default.getElementsByClassName(this, className);
|
400
|
-
}
|
290
|
+
}
|
401
291
|
/**
|
402
292
|
* Returns an elements by tag name.
|
403
293
|
*
|
404
294
|
* @param tagName Tag name.
|
405
295
|
* @returns Matching element.
|
406
296
|
*/
|
407
|
-
|
297
|
+
getElementsByTagName(tagName) {
|
408
298
|
return ParentNodeUtility_1.default.getElementsByTagName(this, tagName);
|
409
|
-
}
|
299
|
+
}
|
410
300
|
/**
|
411
301
|
* Returns an elements by tag name and namespace.
|
412
302
|
*
|
@@ -414,41 +304,39 @@ var Document = /** @class */ (function (_super) {
|
|
414
304
|
* @param tagName Tag name.
|
415
305
|
* @returns Matching element.
|
416
306
|
*/
|
417
|
-
|
307
|
+
getElementsByTagNameNS(namespaceURI, tagName) {
|
418
308
|
return ParentNodeUtility_1.default.getElementsByTagNameNS(this, namespaceURI, tagName);
|
419
|
-
}
|
309
|
+
}
|
420
310
|
/**
|
421
311
|
* Returns an element by ID.
|
422
312
|
*
|
423
313
|
* @param id ID.
|
424
314
|
* @returns Matching element.
|
425
315
|
*/
|
426
|
-
|
316
|
+
getElementById(id) {
|
427
317
|
return ParentNodeUtility_1.default.getElementById(this, id);
|
428
|
-
}
|
318
|
+
}
|
429
319
|
/**
|
430
320
|
* Returns an element by Name.
|
431
321
|
*
|
432
322
|
* @returns Matching element.
|
433
323
|
* @param name
|
434
324
|
*/
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
for (
|
439
|
-
var child = _a[_i];
|
325
|
+
getElementsByName(name) {
|
326
|
+
const _getElementsByName = (_parentNode, _name) => {
|
327
|
+
const matches = HTMLCollectionFactory_1.default.create();
|
328
|
+
for (const child of _parentNode.children) {
|
440
329
|
if ((child.getAttributeNS(null, 'name') || '') === _name) {
|
441
330
|
matches.push(child);
|
442
331
|
}
|
443
|
-
for (
|
444
|
-
var match = _c[_b];
|
332
|
+
for (const match of _getElementsByName(child, _name)) {
|
445
333
|
matches.push(match);
|
446
334
|
}
|
447
335
|
}
|
448
336
|
return matches;
|
449
337
|
};
|
450
338
|
return _getElementsByName(this, name);
|
451
|
-
}
|
339
|
+
}
|
452
340
|
/**
|
453
341
|
* Clones a node.
|
454
342
|
*
|
@@ -456,12 +344,10 @@ var Document = /** @class */ (function (_super) {
|
|
456
344
|
* @param [deep=false] "true" to clone deep.
|
457
345
|
* @returns Cloned node.
|
458
346
|
*/
|
459
|
-
|
460
|
-
|
461
|
-
var clone = _super.prototype.cloneNode.call(this, deep);
|
347
|
+
cloneNode(deep = false) {
|
348
|
+
const clone = super.cloneNode(deep);
|
462
349
|
if (deep) {
|
463
|
-
for (
|
464
|
-
var node = _a[_i];
|
350
|
+
for (const node of clone.childNodes) {
|
465
351
|
if (node.nodeType === Node_1.default.ELEMENT_NODE) {
|
466
352
|
clone.children.push(node);
|
467
353
|
}
|
@@ -469,7 +355,7 @@ var Document = /** @class */ (function (_super) {
|
|
469
355
|
}
|
470
356
|
clone.defaultView = this.defaultView;
|
471
357
|
return clone;
|
472
|
-
}
|
358
|
+
}
|
473
359
|
/**
|
474
360
|
* Append a child node to childNodes.
|
475
361
|
*
|
@@ -477,12 +363,12 @@ var Document = /** @class */ (function (_super) {
|
|
477
363
|
* @param node Node to append.
|
478
364
|
* @returns Appended node.
|
479
365
|
*/
|
480
|
-
|
366
|
+
appendChild(node) {
|
481
367
|
// If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
|
482
368
|
// See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
483
369
|
if (node.nodeType !== Node_1.default.DOCUMENT_FRAGMENT_NODE) {
|
484
370
|
if (node.parentNode && node.parentNode['children']) {
|
485
|
-
|
371
|
+
const index = node.parentNode['children'].indexOf(node);
|
486
372
|
if (index !== -1) {
|
487
373
|
node.parentNode['children'].splice(index, 1);
|
488
374
|
}
|
@@ -491,23 +377,23 @@ var Document = /** @class */ (function (_super) {
|
|
491
377
|
this.children.push(node);
|
492
378
|
}
|
493
379
|
}
|
494
|
-
return
|
495
|
-
}
|
380
|
+
return super.appendChild(node);
|
381
|
+
}
|
496
382
|
/**
|
497
383
|
* Remove Child element from childNodes array.
|
498
384
|
*
|
499
385
|
* @override
|
500
386
|
* @param node Node to remove.
|
501
387
|
*/
|
502
|
-
|
388
|
+
removeChild(node) {
|
503
389
|
if (node.nodeType === Node_1.default.ELEMENT_NODE) {
|
504
|
-
|
390
|
+
const index = this.children.indexOf(node);
|
505
391
|
if (index !== -1) {
|
506
392
|
this.children.splice(index, 1);
|
507
393
|
}
|
508
394
|
}
|
509
|
-
return
|
510
|
-
}
|
395
|
+
return super.removeChild(node);
|
396
|
+
}
|
511
397
|
/**
|
512
398
|
* Inserts a node before another.
|
513
399
|
*
|
@@ -516,34 +402,33 @@ var Document = /** @class */ (function (_super) {
|
|
516
402
|
* @param [referenceNode] Node to insert before.
|
517
403
|
* @returns Inserted node.
|
518
404
|
*/
|
519
|
-
|
520
|
-
|
405
|
+
insertBefore(newNode, referenceNode) {
|
406
|
+
const returnValue = super.insertBefore(newNode, referenceNode);
|
521
407
|
// If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
|
522
408
|
// See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
523
409
|
if (newNode.nodeType !== Node_1.default.DOCUMENT_FRAGMENT_NODE) {
|
524
410
|
if (newNode.parentNode && newNode.parentNode['children']) {
|
525
|
-
|
411
|
+
const index = newNode.parentNode['children'].indexOf(newNode);
|
526
412
|
if (index !== -1) {
|
527
413
|
newNode.parentNode['children'].splice(index, 1);
|
528
414
|
}
|
529
415
|
}
|
530
416
|
this.children.length = 0;
|
531
|
-
for (
|
532
|
-
var node = _a[_i];
|
417
|
+
for (const node of this.childNodes) {
|
533
418
|
if (node.nodeType === Node_1.default.ELEMENT_NODE) {
|
534
419
|
this.children.push(node);
|
535
420
|
}
|
536
421
|
}
|
537
422
|
}
|
538
423
|
return returnValue;
|
539
|
-
}
|
424
|
+
}
|
540
425
|
/**
|
541
426
|
* Replaces the document HTML with new HTML.
|
542
427
|
*
|
543
428
|
* @param html HTML.
|
544
429
|
*/
|
545
|
-
|
546
|
-
|
430
|
+
write(html) {
|
431
|
+
const root = XMLParser_1.default.parse(this, html, true);
|
547
432
|
if (this._isFirstWrite || this._isFirstWriteAfterOpen) {
|
548
433
|
if (this._isFirstWrite) {
|
549
434
|
if (!this._isFirstWriteAfterOpen) {
|
@@ -552,10 +437,9 @@ var Document = /** @class */ (function (_super) {
|
|
552
437
|
this._isFirstWrite = false;
|
553
438
|
}
|
554
439
|
this._isFirstWriteAfterOpen = false;
|
555
|
-
|
556
|
-
|
557
|
-
for (
|
558
|
-
var node = _a[_i];
|
440
|
+
let documentElement = null;
|
441
|
+
let documentTypeNode = null;
|
442
|
+
for (const node of root.childNodes) {
|
559
443
|
if (node['tagName'] === 'HTML') {
|
560
444
|
documentElement = node;
|
561
445
|
}
|
@@ -574,19 +458,17 @@ var Document = /** @class */ (function (_super) {
|
|
574
458
|
this.appendChild(documentElement);
|
575
459
|
}
|
576
460
|
else {
|
577
|
-
|
578
|
-
|
579
|
-
if (rootBody &&
|
580
|
-
for (
|
581
|
-
|
582
|
-
body_1.appendChild(child);
|
461
|
+
const rootBody = root.querySelector('body');
|
462
|
+
const body = this.querySelector('body');
|
463
|
+
if (rootBody && body) {
|
464
|
+
for (const child of rootBody.childNodes.slice()) {
|
465
|
+
body.appendChild(child);
|
583
466
|
}
|
584
467
|
}
|
585
468
|
}
|
586
|
-
|
469
|
+
const body = this.querySelector('body');
|
587
470
|
if (body) {
|
588
|
-
for (
|
589
|
-
var child = _e[_d];
|
471
|
+
for (const child of root.childNodes.slice()) {
|
590
472
|
if (child['tagName'] !== 'HTML' && child.nodeType !== Node_1.default.DOCUMENT_TYPE_NODE) {
|
591
473
|
body.appendChild(child);
|
592
474
|
}
|
@@ -594,53 +476,48 @@ var Document = /** @class */ (function (_super) {
|
|
594
476
|
}
|
595
477
|
}
|
596
478
|
else {
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
for (
|
601
|
-
var child = _g[_f];
|
479
|
+
const documentElement = this.createElement('html');
|
480
|
+
const bodyElement = this.createElement('body');
|
481
|
+
const headElement = this.createElement('head');
|
482
|
+
for (const child of root.childNodes.slice()) {
|
602
483
|
bodyElement.appendChild(child);
|
603
484
|
}
|
604
|
-
|
605
|
-
|
606
|
-
this.appendChild(
|
485
|
+
documentElement.appendChild(headElement);
|
486
|
+
documentElement.appendChild(bodyElement);
|
487
|
+
this.appendChild(documentElement);
|
607
488
|
}
|
608
489
|
}
|
609
490
|
else {
|
610
|
-
|
611
|
-
for (
|
612
|
-
var child = _j[_h];
|
491
|
+
const bodyNode = root.querySelector('body');
|
492
|
+
for (const child of (bodyNode || root).childNodes.slice()) {
|
613
493
|
this.body.appendChild(child);
|
614
494
|
}
|
615
495
|
}
|
616
|
-
}
|
496
|
+
}
|
617
497
|
/**
|
618
498
|
* Opens the document.
|
619
499
|
*
|
620
500
|
* @returns Document.
|
621
501
|
*/
|
622
|
-
|
502
|
+
open() {
|
623
503
|
this._isFirstWriteAfterOpen = true;
|
624
|
-
for (
|
625
|
-
|
626
|
-
var listeners = this._listeners[eventType];
|
504
|
+
for (const eventType of Object.keys(this._listeners)) {
|
505
|
+
const listeners = this._listeners[eventType];
|
627
506
|
if (listeners) {
|
628
|
-
for (
|
629
|
-
var listener = listeners_1[_b];
|
507
|
+
for (const listener of listeners) {
|
630
508
|
this.removeEventListener(eventType, listener);
|
631
509
|
}
|
632
510
|
}
|
633
511
|
}
|
634
|
-
for (
|
635
|
-
var child = _d[_c];
|
512
|
+
for (const child of this.childNodes.slice()) {
|
636
513
|
this.removeChild(child);
|
637
514
|
}
|
638
515
|
return this;
|
639
|
-
}
|
516
|
+
}
|
640
517
|
/**
|
641
518
|
* Closes the document.
|
642
519
|
*/
|
643
|
-
|
520
|
+
close() { }
|
644
521
|
/* eslint-disable jsdoc/valid-types */
|
645
522
|
/**
|
646
523
|
* Creates an element.
|
@@ -650,9 +527,9 @@ var Document = /** @class */ (function (_super) {
|
|
650
527
|
* @param [options.is] Tag name of a custom element previously defined via customElements.define().
|
651
528
|
* @returns Element.
|
652
529
|
*/
|
653
|
-
|
530
|
+
createElement(qualifiedName, options) {
|
654
531
|
return this.createElementNS(NamespaceURI_1.default.html, qualifiedName, options);
|
655
|
-
}
|
532
|
+
}
|
656
533
|
/**
|
657
534
|
* Creates an element with the specified namespace URI and qualified name.
|
658
535
|
*
|
@@ -662,23 +539,23 @@ var Document = /** @class */ (function (_super) {
|
|
662
539
|
* @param [options.is] Tag name of a custom element previously defined via customElements.define().
|
663
540
|
* @returns Element.
|
664
541
|
*/
|
665
|
-
|
666
|
-
|
667
|
-
|
542
|
+
createElementNS(namespaceURI, qualifiedName, options) {
|
543
|
+
const tagName = String(qualifiedName).toUpperCase();
|
544
|
+
let customElementClass;
|
668
545
|
if (this.defaultView && options && options.is) {
|
669
546
|
customElementClass = this.defaultView.customElements.get(String(options.is));
|
670
547
|
}
|
671
548
|
else if (this.defaultView) {
|
672
549
|
customElementClass = this.defaultView.customElements.get(tagName);
|
673
550
|
}
|
674
|
-
|
551
|
+
const elementClass = customElementClass || ElementTag_1.default[tagName] || HTMLUnknownElement_1.default;
|
675
552
|
elementClass.ownerDocument = this;
|
676
|
-
|
553
|
+
const element = new elementClass();
|
677
554
|
element.tagName = tagName;
|
678
555
|
element.ownerDocument = this;
|
679
556
|
element.namespaceURI = namespaceURI;
|
680
557
|
return element;
|
681
|
-
}
|
558
|
+
}
|
682
559
|
/* eslint-enable jsdoc/valid-types */
|
683
560
|
/**
|
684
561
|
* Creates a text node.
|
@@ -686,29 +563,29 @@ var Document = /** @class */ (function (_super) {
|
|
686
563
|
* @param [data] Text data.
|
687
564
|
* @returns Text node.
|
688
565
|
*/
|
689
|
-
|
566
|
+
createTextNode(data) {
|
690
567
|
Text_1.default.ownerDocument = this;
|
691
568
|
return new Text_1.default(data);
|
692
|
-
}
|
569
|
+
}
|
693
570
|
/**
|
694
571
|
* Creates a comment node.
|
695
572
|
*
|
696
573
|
* @param [data] Text data.
|
697
574
|
* @returns Text node.
|
698
575
|
*/
|
699
|
-
|
576
|
+
createComment(data) {
|
700
577
|
Comment_1.default.ownerDocument = this;
|
701
578
|
return new Comment_1.default(data);
|
702
|
-
}
|
579
|
+
}
|
703
580
|
/**
|
704
581
|
* Creates a document fragment.
|
705
582
|
*
|
706
583
|
* @returns Document fragment.
|
707
584
|
*/
|
708
|
-
|
585
|
+
createDocumentFragment() {
|
709
586
|
DocumentFragment_1.default.ownerDocument = this;
|
710
587
|
return new DocumentFragment_1.default();
|
711
|
-
}
|
588
|
+
}
|
712
589
|
/**
|
713
590
|
* Creates a Tree Walker.
|
714
591
|
*
|
@@ -716,11 +593,9 @@ var Document = /** @class */ (function (_super) {
|
|
716
593
|
* @param [whatToShow] What to show.
|
717
594
|
* @param [filter] Filter.
|
718
595
|
*/
|
719
|
-
|
720
|
-
if (whatToShow === void 0) { whatToShow = -1; }
|
721
|
-
if (filter === void 0) { filter = null; }
|
596
|
+
createTreeWalker(root, whatToShow = -1, filter = null) {
|
722
597
|
return new TreeWalker_1.default(root, whatToShow, filter);
|
723
|
-
}
|
598
|
+
}
|
724
599
|
/**
|
725
600
|
* Creates an event.
|
726
601
|
*
|
@@ -728,24 +603,24 @@ var Document = /** @class */ (function (_super) {
|
|
728
603
|
* @param type Type.
|
729
604
|
* @returns Event.
|
730
605
|
*/
|
731
|
-
|
606
|
+
createEvent(type) {
|
732
607
|
if (this.defaultView[type]) {
|
733
608
|
return new this.defaultView[type]('init');
|
734
609
|
}
|
735
610
|
return new Event_1.default('init');
|
736
|
-
}
|
611
|
+
}
|
737
612
|
/**
|
738
613
|
* Creates an Attr node.
|
739
614
|
*
|
740
615
|
* @param name Name.
|
741
616
|
* @returns Attribute.
|
742
617
|
*/
|
743
|
-
|
744
|
-
|
618
|
+
createAttribute(name) {
|
619
|
+
const attribute = new Attr_1.default();
|
745
620
|
attribute.name = name.toLowerCase();
|
746
621
|
attribute.ownerDocument = this;
|
747
622
|
return attribute;
|
748
|
-
}
|
623
|
+
}
|
749
624
|
/**
|
750
625
|
* Creates a namespaced Attr node.
|
751
626
|
*
|
@@ -753,13 +628,13 @@ var Document = /** @class */ (function (_super) {
|
|
753
628
|
* @param qualifiedName Qualified name.
|
754
629
|
* @returns Element.
|
755
630
|
*/
|
756
|
-
|
757
|
-
|
631
|
+
createAttributeNS(namespaceURI, qualifiedName) {
|
632
|
+
const attribute = new Attr_1.default();
|
758
633
|
attribute.namespaceURI = namespaceURI;
|
759
634
|
attribute.name = qualifiedName;
|
760
635
|
attribute.ownerDocument = this;
|
761
636
|
return attribute;
|
762
|
-
}
|
637
|
+
}
|
763
638
|
/**
|
764
639
|
* Imports a node.
|
765
640
|
*
|
@@ -767,56 +642,54 @@ var Document = /** @class */ (function (_super) {
|
|
767
642
|
* @param [deep=false] Set to "true" if the clone should be deep.
|
768
643
|
* @param Imported Node.
|
769
644
|
*/
|
770
|
-
|
771
|
-
if (deep === void 0) { deep = false; }
|
645
|
+
importNode(node, deep = false) {
|
772
646
|
if (!(node instanceof Node_1.default)) {
|
773
647
|
throw new DOMException_1.default('Parameter 1 was not of type Node.');
|
774
648
|
}
|
775
|
-
|
649
|
+
const clone = node.cloneNode(deep);
|
776
650
|
clone.ownerDocument = this;
|
777
651
|
return clone;
|
778
|
-
}
|
652
|
+
}
|
779
653
|
/**
|
780
654
|
* Adopts a node.
|
781
655
|
*
|
782
656
|
* @param node Node to adopt.
|
783
657
|
* @returns Adopted node.
|
784
658
|
*/
|
785
|
-
|
659
|
+
adoptNode(node) {
|
786
660
|
if (!(node instanceof Node_1.default)) {
|
787
661
|
throw new DOMException_1.default('Parameter 1 was not of type Node.');
|
788
662
|
}
|
789
|
-
|
663
|
+
const adopted = node.parentNode ? node.parentNode.removeChild(node) : node;
|
790
664
|
adopted.ownerDocument = this;
|
791
665
|
return adopted;
|
792
|
-
}
|
666
|
+
}
|
793
667
|
/**
|
794
668
|
* Returns selection.
|
795
669
|
*
|
796
670
|
* @returns Selection.
|
797
671
|
*/
|
798
|
-
|
672
|
+
getSelection() {
|
799
673
|
return new Selection_1.default();
|
800
|
-
}
|
674
|
+
}
|
801
675
|
/**
|
802
676
|
* Returns a boolean value indicating whether the document or any element inside the document has focus.
|
803
677
|
*
|
804
678
|
* @returns "true" if the document has focus.
|
805
679
|
*/
|
806
|
-
|
680
|
+
hasFocus() {
|
807
681
|
return !!this.activeElement;
|
808
|
-
}
|
682
|
+
}
|
809
683
|
/**
|
810
684
|
* @override
|
811
685
|
*/
|
812
|
-
|
813
|
-
|
686
|
+
dispatchEvent(event) {
|
687
|
+
const returnValue = super.dispatchEvent(event);
|
814
688
|
if (event.bubbles && !event._propagationStopped) {
|
815
689
|
return this.defaultView.dispatchEvent(event);
|
816
690
|
}
|
817
691
|
return returnValue;
|
818
|
-
}
|
819
|
-
|
820
|
-
}(Node_1.default));
|
692
|
+
}
|
693
|
+
}
|
821
694
|
exports.default = Document;
|
822
695
|
//# sourceMappingURL=Document.js.map
|