happy-dom 2.54.0 → 3.1.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.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/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 +37 -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 +78 -105
- package/lib/window/Window.js +277 -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-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 +33 -12
- package/src/window/VMGlobalPropertyScript.ts +62 -0
- package/src/window/Window.ts +115 -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/nodes/node/Node.js
CHANGED
@@ -1,209 +1,171 @@
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
19
4
|
};
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
6
|
+
const EventTarget_1 = __importDefault(require("../../event/EventTarget"));
|
7
|
+
const MutationRecord_1 = __importDefault(require("../../mutation-observer/MutationRecord"));
|
8
|
+
const MutationTypeEnum_1 = __importDefault(require("../../mutation-observer/MutationTypeEnum"));
|
9
|
+
const DOMException_1 = __importDefault(require("../../exception/DOMException"));
|
10
|
+
const NodeListFactory_1 = __importDefault(require("./NodeListFactory"));
|
26
11
|
/**
|
27
12
|
* Node.
|
28
13
|
*/
|
29
|
-
|
30
|
-
__extends(Node, _super);
|
14
|
+
class Node extends EventTarget_1.default {
|
31
15
|
/**
|
32
16
|
* Constructor.
|
33
17
|
*/
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
18
|
+
constructor() {
|
19
|
+
super();
|
20
|
+
this.ELEMENT_NODE = 1;
|
21
|
+
this.TEXT_NODE = 3;
|
22
|
+
this.COMMENT_NODE = 8;
|
23
|
+
this.DOCUMENT_NODE = 9;
|
24
|
+
this.DOCUMENT_TYPE_NODE = 10;
|
25
|
+
this.DOCUMENT_FRAGMENT_NODE = 11;
|
26
|
+
this.ownerDocument = null;
|
27
|
+
this.parentNode = null;
|
28
|
+
this.childNodes = NodeListFactory_1.default.create();
|
29
|
+
this.isConnected = false;
|
30
|
+
this._rootNode = null;
|
47
31
|
// Custom Properties (not part of HTML standard)
|
48
|
-
|
49
|
-
|
50
|
-
return _this;
|
32
|
+
this._observers = [];
|
33
|
+
this.ownerDocument = this.constructor.ownerDocument;
|
51
34
|
}
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
configurable: true
|
101
|
-
});
|
102
|
-
Object.defineProperty(Node.prototype, "previousSibling", {
|
103
|
-
/**
|
104
|
-
* Previous sibling.
|
105
|
-
*
|
106
|
-
* @returns Node.
|
107
|
-
*/
|
108
|
-
get: function () {
|
109
|
-
if (this.parentNode) {
|
110
|
-
var index = this.parentNode.childNodes.indexOf(this);
|
111
|
-
if (index > 0) {
|
112
|
-
return this.parentNode.childNodes[index - 1];
|
113
|
-
}
|
114
|
-
}
|
115
|
-
return null;
|
116
|
-
},
|
117
|
-
enumerable: false,
|
118
|
-
configurable: true
|
119
|
-
});
|
120
|
-
Object.defineProperty(Node.prototype, "nextSibling", {
|
121
|
-
/**
|
122
|
-
* Next sibling.
|
123
|
-
*
|
124
|
-
* @returns Node.
|
125
|
-
*/
|
126
|
-
get: function () {
|
127
|
-
if (this.parentNode) {
|
128
|
-
var index = this.parentNode.childNodes.indexOf(this);
|
129
|
-
if (index > -1 && index + 1 < this.parentNode.childNodes.length) {
|
130
|
-
return this.parentNode.childNodes[index + 1];
|
131
|
-
}
|
132
|
-
}
|
133
|
-
return null;
|
134
|
-
},
|
135
|
-
enumerable: false,
|
136
|
-
configurable: true
|
137
|
-
});
|
138
|
-
Object.defineProperty(Node.prototype, "firstChild", {
|
139
|
-
/**
|
140
|
-
* First child.
|
141
|
-
*
|
142
|
-
* @returns Node.
|
143
|
-
*/
|
144
|
-
get: function () {
|
145
|
-
if (this.childNodes.length > 0) {
|
146
|
-
return this.childNodes[0];
|
147
|
-
}
|
148
|
-
return null;
|
149
|
-
},
|
150
|
-
enumerable: false,
|
151
|
-
configurable: true
|
152
|
-
});
|
153
|
-
Object.defineProperty(Node.prototype, "lastChild", {
|
154
|
-
/**
|
155
|
-
* Last child.
|
156
|
-
*
|
157
|
-
* @returns Node.
|
158
|
-
*/
|
159
|
-
get: function () {
|
160
|
-
if (this.childNodes.length > 0) {
|
161
|
-
return this.childNodes[this.childNodes.length - 1];
|
35
|
+
/**
|
36
|
+
* Get text value of children.
|
37
|
+
*
|
38
|
+
* @returns Text content.
|
39
|
+
*/
|
40
|
+
get textContent() {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* Sets text content.
|
45
|
+
*
|
46
|
+
* @param textContent Text content.
|
47
|
+
*/
|
48
|
+
set textContent(_textContent) {
|
49
|
+
// Do nothing.
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* Node value.
|
53
|
+
*
|
54
|
+
* @returns Node value.
|
55
|
+
*/
|
56
|
+
get nodeValue() {
|
57
|
+
return null;
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* Sets node value.
|
61
|
+
*/
|
62
|
+
set nodeValue(_nodeValue) {
|
63
|
+
// Do nothing
|
64
|
+
}
|
65
|
+
/**
|
66
|
+
* Node name.
|
67
|
+
*
|
68
|
+
* @returns Node name.
|
69
|
+
*/
|
70
|
+
get nodeName() {
|
71
|
+
return '';
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Previous sibling.
|
75
|
+
*
|
76
|
+
* @returns Node.
|
77
|
+
*/
|
78
|
+
get previousSibling() {
|
79
|
+
if (this.parentNode) {
|
80
|
+
const index = this.parentNode.childNodes.indexOf(this);
|
81
|
+
if (index > 0) {
|
82
|
+
return this.parentNode.childNodes[index - 1];
|
162
83
|
}
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
while (parent && parent.nodeType !== Node.ELEMENT_NODE) {
|
177
|
-
parent = parent.parentNode;
|
84
|
+
}
|
85
|
+
return null;
|
86
|
+
}
|
87
|
+
/**
|
88
|
+
* Next sibling.
|
89
|
+
*
|
90
|
+
* @returns Node.
|
91
|
+
*/
|
92
|
+
get nextSibling() {
|
93
|
+
if (this.parentNode) {
|
94
|
+
const index = this.parentNode.childNodes.indexOf(this);
|
95
|
+
if (index > -1 && index + 1 < this.parentNode.childNodes.length) {
|
96
|
+
return this.parentNode.childNodes[index + 1];
|
178
97
|
}
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
98
|
+
}
|
99
|
+
return null;
|
100
|
+
}
|
101
|
+
/**
|
102
|
+
* First child.
|
103
|
+
*
|
104
|
+
* @returns Node.
|
105
|
+
*/
|
106
|
+
get firstChild() {
|
107
|
+
if (this.childNodes.length > 0) {
|
108
|
+
return this.childNodes[0];
|
109
|
+
}
|
110
|
+
return null;
|
111
|
+
}
|
112
|
+
/**
|
113
|
+
* Last child.
|
114
|
+
*
|
115
|
+
* @returns Node.
|
116
|
+
*/
|
117
|
+
get lastChild() {
|
118
|
+
if (this.childNodes.length > 0) {
|
119
|
+
return this.childNodes[this.childNodes.length - 1];
|
120
|
+
}
|
121
|
+
return null;
|
122
|
+
}
|
123
|
+
/**
|
124
|
+
* Returns parent element.
|
125
|
+
*
|
126
|
+
* @returns Element.
|
127
|
+
*/
|
128
|
+
get parentElement() {
|
129
|
+
let parent = this.parentNode;
|
130
|
+
while (parent && parent.nodeType !== Node.ELEMENT_NODE) {
|
131
|
+
parent = parent.parentNode;
|
132
|
+
}
|
133
|
+
return parent;
|
134
|
+
}
|
135
|
+
/**
|
136
|
+
* Returns base URI.
|
137
|
+
*
|
138
|
+
* @returns Base URI.
|
139
|
+
*/
|
140
|
+
get baseURI() {
|
141
|
+
const base = this.ownerDocument.querySelector('base');
|
142
|
+
if (base) {
|
143
|
+
return base.href;
|
144
|
+
}
|
145
|
+
return this.ownerDocument.location.href;
|
146
|
+
}
|
184
147
|
/**
|
185
148
|
* Returns "true" if the node has child nodes.
|
186
149
|
*
|
187
150
|
* @returns "true" if the node has child nodes.
|
188
151
|
*/
|
189
|
-
|
152
|
+
hasChildNodes() {
|
190
153
|
return this.childNodes.length > 0;
|
191
|
-
}
|
154
|
+
}
|
192
155
|
/**
|
193
156
|
* Returns "true" if this node contains the other node.
|
194
157
|
*
|
195
158
|
* @param otherNode Node to test with.
|
196
159
|
* @returns "true" if this node contains the other node.
|
197
160
|
*/
|
198
|
-
|
199
|
-
for (
|
200
|
-
var childNode = _a[_i];
|
161
|
+
contains(otherNode) {
|
162
|
+
for (const childNode of this.childNodes) {
|
201
163
|
if (childNode === otherNode || childNode.contains(otherNode)) {
|
202
164
|
return true;
|
203
165
|
}
|
204
166
|
}
|
205
167
|
return false;
|
206
|
-
}
|
168
|
+
}
|
207
169
|
/**
|
208
170
|
* Returns closest root node (Document or ShadowRoot).
|
209
171
|
*
|
@@ -211,64 +173,60 @@ var Node = /** @class */ (function (_super) {
|
|
211
173
|
* @param options.composed A Boolean that indicates whether the shadow root should be returned (false, the default), or a root node beyond shadow root (true).
|
212
174
|
* @returns Node.
|
213
175
|
*/
|
214
|
-
|
176
|
+
getRootNode(options) {
|
215
177
|
if (!this.isConnected) {
|
216
178
|
return this;
|
217
179
|
}
|
218
|
-
if (this._rootNode && !
|
180
|
+
if (this._rootNode && !options?.composed) {
|
219
181
|
return this._rootNode;
|
220
182
|
}
|
221
183
|
return this.ownerDocument;
|
222
|
-
}
|
184
|
+
}
|
223
185
|
/**
|
224
186
|
* Clones a node.
|
225
187
|
*
|
226
188
|
* @param [deep=false] "true" to clone deep.
|
227
189
|
* @returns Cloned node.
|
228
190
|
*/
|
229
|
-
|
230
|
-
|
231
|
-
var clone = new this.constructor();
|
191
|
+
cloneNode(deep = false) {
|
192
|
+
const clone = new this.constructor();
|
232
193
|
// Document has childNodes directly when it is created
|
233
194
|
if (clone.childNodes.length) {
|
234
|
-
for (
|
235
|
-
var node = _a[_i];
|
195
|
+
for (const node of clone.childNodes.slice()) {
|
236
196
|
node.parentNode.removeChild(node);
|
237
197
|
}
|
238
198
|
}
|
239
199
|
if (deep) {
|
240
|
-
for (
|
241
|
-
|
242
|
-
var childClone = childNode.cloneNode(true);
|
200
|
+
for (const childNode of this.childNodes) {
|
201
|
+
const childClone = childNode.cloneNode(true);
|
243
202
|
childClone.parentNode = clone;
|
244
203
|
clone.childNodes.push(childClone);
|
245
204
|
}
|
246
205
|
}
|
247
206
|
clone.ownerDocument = this.ownerDocument;
|
248
207
|
return clone;
|
249
|
-
}
|
208
|
+
}
|
250
209
|
/**
|
251
210
|
* Append a child node to childNodes.
|
252
211
|
*
|
253
212
|
* @param node Node to append.
|
254
213
|
* @returns Appended node.
|
255
214
|
*/
|
256
|
-
|
215
|
+
appendChild(node) {
|
257
216
|
if (node === this) {
|
258
217
|
throw new DOMException_1.default('Not possible to append a node as a child of itself.');
|
259
218
|
}
|
260
219
|
// If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
|
261
220
|
// See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
262
221
|
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
263
|
-
for (
|
264
|
-
var child = _a[_i];
|
222
|
+
for (const child of node.childNodes.slice()) {
|
265
223
|
this.appendChild(child);
|
266
224
|
}
|
267
225
|
return node;
|
268
226
|
}
|
269
227
|
// Remove the node from its previous parent if it has any.
|
270
228
|
if (node.parentNode) {
|
271
|
-
|
229
|
+
const index = node.parentNode.childNodes.indexOf(node);
|
272
230
|
if (index !== -1) {
|
273
231
|
node.parentNode.childNodes.splice(index, 1);
|
274
232
|
}
|
@@ -277,12 +235,11 @@ var Node = /** @class */ (function (_super) {
|
|
277
235
|
node._connectToNode(this);
|
278
236
|
// MutationObserver
|
279
237
|
if (this._observers.length > 0) {
|
280
|
-
|
238
|
+
const record = new MutationRecord_1.default();
|
281
239
|
record.target = this;
|
282
240
|
record.type = MutationTypeEnum_1.default.childList;
|
283
241
|
record.addedNodes = [node];
|
284
|
-
for (
|
285
|
-
var observer = _c[_b];
|
242
|
+
for (const observer of this._observers) {
|
286
243
|
if (observer.options.subtree) {
|
287
244
|
node._observe(observer);
|
288
245
|
}
|
@@ -292,15 +249,15 @@ var Node = /** @class */ (function (_super) {
|
|
292
249
|
}
|
293
250
|
}
|
294
251
|
return node;
|
295
|
-
}
|
252
|
+
}
|
296
253
|
/**
|
297
254
|
* Remove Child element from childNodes array.
|
298
255
|
*
|
299
256
|
* @param node Node to remove.
|
300
257
|
* @returns Removed node.
|
301
258
|
*/
|
302
|
-
|
303
|
-
|
259
|
+
removeChild(node) {
|
260
|
+
const index = this.childNodes.indexOf(node);
|
304
261
|
if (index === -1) {
|
305
262
|
throw new DOMException_1.default('Failed to remove node. Node is not child of parent.');
|
306
263
|
}
|
@@ -308,12 +265,11 @@ var Node = /** @class */ (function (_super) {
|
|
308
265
|
node._connectToNode(null);
|
309
266
|
// MutationObserver
|
310
267
|
if (this._observers.length > 0) {
|
311
|
-
|
268
|
+
const record = new MutationRecord_1.default();
|
312
269
|
record.target = this;
|
313
270
|
record.type = MutationTypeEnum_1.default.childList;
|
314
271
|
record.removedNodes = [node];
|
315
|
-
for (
|
316
|
-
var observer = _a[_i];
|
272
|
+
for (const observer of this._observers) {
|
317
273
|
node._unobserve(observer);
|
318
274
|
if (observer.options.childList) {
|
319
275
|
observer.callback([record]);
|
@@ -321,7 +277,7 @@ var Node = /** @class */ (function (_super) {
|
|
321
277
|
}
|
322
278
|
}
|
323
279
|
return node;
|
324
|
-
}
|
280
|
+
}
|
325
281
|
/**
|
326
282
|
* Inserts a node before another.
|
327
283
|
*
|
@@ -329,12 +285,11 @@ var Node = /** @class */ (function (_super) {
|
|
329
285
|
* @param [referenceNode] Node to insert before.
|
330
286
|
* @returns Inserted node.
|
331
287
|
*/
|
332
|
-
|
288
|
+
insertBefore(newNode, referenceNode) {
|
333
289
|
// If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
|
334
290
|
// See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
335
291
|
if (newNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
336
|
-
for (
|
337
|
-
var child = _a[_i];
|
292
|
+
for (const child of newNode.childNodes.slice()) {
|
338
293
|
this.insertBefore(child, referenceNode);
|
339
294
|
}
|
340
295
|
return newNode;
|
@@ -346,26 +301,25 @@ var Node = /** @class */ (function (_super) {
|
|
346
301
|
if (referenceNode === undefined) {
|
347
302
|
throw new DOMException_1.default("Failed to execute 'insertBefore' on 'Node': 2 arguments required, but only 1 present.", 'TypeError');
|
348
303
|
}
|
349
|
-
|
304
|
+
const index = referenceNode ? this.childNodes.indexOf(referenceNode) : 0;
|
350
305
|
if (index === -1) {
|
351
306
|
throw new DOMException_1.default("Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.");
|
352
307
|
}
|
353
308
|
if (newNode.parentNode) {
|
354
|
-
|
355
|
-
if (
|
356
|
-
newNode.parentNode.childNodes.splice(
|
309
|
+
const index = newNode.parentNode.childNodes.indexOf(newNode);
|
310
|
+
if (index !== -1) {
|
311
|
+
newNode.parentNode.childNodes.splice(index, 1);
|
357
312
|
}
|
358
313
|
}
|
359
314
|
this.childNodes.splice(index, 0, newNode);
|
360
315
|
newNode._connectToNode(this);
|
361
316
|
// MutationObserver
|
362
317
|
if (this._observers.length > 0) {
|
363
|
-
|
318
|
+
const record = new MutationRecord_1.default();
|
364
319
|
record.target = this;
|
365
320
|
record.type = MutationTypeEnum_1.default.childList;
|
366
321
|
record.addedNodes = [newNode];
|
367
|
-
for (
|
368
|
-
var observer = _c[_b];
|
322
|
+
for (const observer of this._observers) {
|
369
323
|
if (observer.options.subtree) {
|
370
324
|
newNode._observe(observer);
|
371
325
|
}
|
@@ -375,7 +329,7 @@ var Node = /** @class */ (function (_super) {
|
|
375
329
|
}
|
376
330
|
}
|
377
331
|
return newNode;
|
378
|
-
}
|
332
|
+
}
|
379
333
|
/**
|
380
334
|
* Replaces a node with another.
|
381
335
|
*
|
@@ -383,16 +337,16 @@ var Node = /** @class */ (function (_super) {
|
|
383
337
|
* @param oldChild Old child.
|
384
338
|
* @returns Replaced node.
|
385
339
|
*/
|
386
|
-
|
340
|
+
replaceChild(newChild, oldChild) {
|
387
341
|
this.insertBefore(newChild, oldChild);
|
388
342
|
this.removeChild(oldChild);
|
389
343
|
return oldChild;
|
390
|
-
}
|
344
|
+
}
|
391
345
|
/**
|
392
346
|
* @override
|
393
347
|
*/
|
394
|
-
|
395
|
-
|
348
|
+
dispatchEvent(event) {
|
349
|
+
const returnValue = super.dispatchEvent(event);
|
396
350
|
if (event.bubbles && !event._propagationStopped) {
|
397
351
|
if (this.parentNode) {
|
398
352
|
return this.parentNode.dispatchEvent(event);
|
@@ -404,56 +358,53 @@ var Node = /** @class */ (function (_super) {
|
|
404
358
|
}
|
405
359
|
}
|
406
360
|
return returnValue;
|
407
|
-
}
|
361
|
+
}
|
408
362
|
/**
|
409
363
|
* Converts the node to a string.
|
410
364
|
*
|
411
365
|
* @param listener Listener.
|
412
366
|
*/
|
413
|
-
|
414
|
-
return
|
415
|
-
}
|
367
|
+
toString() {
|
368
|
+
return `[object ${this.constructor.name}]`;
|
369
|
+
}
|
416
370
|
/**
|
417
371
|
* Observeres the node.
|
418
372
|
* Used by MutationObserver, but it is not part of the HTML standard.
|
419
373
|
*
|
420
374
|
* @param listener Listener.
|
421
375
|
*/
|
422
|
-
|
376
|
+
_observe(listener) {
|
423
377
|
this._observers.push(listener);
|
424
378
|
if (listener.options.subtree) {
|
425
|
-
for (
|
426
|
-
var node = _a[_i];
|
379
|
+
for (const node of this.childNodes) {
|
427
380
|
node._observe(listener);
|
428
381
|
}
|
429
382
|
}
|
430
|
-
}
|
383
|
+
}
|
431
384
|
/**
|
432
385
|
* Stops observing the node.
|
433
386
|
* Used by MutationObserver, but it is not part of the HTML standard.
|
434
387
|
*
|
435
388
|
* @param listener Listener.
|
436
389
|
*/
|
437
|
-
|
438
|
-
|
390
|
+
_unobserve(listener) {
|
391
|
+
const index = this._observers.indexOf(listener);
|
439
392
|
if (index !== -1) {
|
440
393
|
this._observers.splice(index, 1);
|
441
394
|
}
|
442
395
|
if (listener.options.subtree) {
|
443
|
-
for (
|
444
|
-
var node = _a[_i];
|
396
|
+
for (const node of this.childNodes) {
|
445
397
|
node._unobserve(listener);
|
446
398
|
}
|
447
399
|
}
|
448
|
-
}
|
400
|
+
}
|
449
401
|
/**
|
450
402
|
* Connects this element to another element.
|
451
403
|
*
|
452
404
|
* @param parentNode Parent node.
|
453
405
|
*/
|
454
|
-
|
455
|
-
|
456
|
-
var isConnected = !!parentNode && parentNode.isConnected;
|
406
|
+
_connectToNode(parentNode = null) {
|
407
|
+
const isConnected = !!parentNode && parentNode.isConnected;
|
457
408
|
if (this.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
|
458
409
|
this.parentNode = parentNode;
|
459
410
|
this._rootNode = isConnected && parentNode ? parentNode._rootNode : null;
|
@@ -466,8 +417,7 @@ var Node = /** @class */ (function (_super) {
|
|
466
417
|
else if (!isConnected && this.disconnectedCallback) {
|
467
418
|
this.disconnectedCallback();
|
468
419
|
}
|
469
|
-
for (
|
470
|
-
var child = _a[_i];
|
420
|
+
for (const child of this.childNodes) {
|
471
421
|
child._connectToNode(this);
|
472
422
|
}
|
473
423
|
// eslint-disable-next-line
|
@@ -476,16 +426,15 @@ var Node = /** @class */ (function (_super) {
|
|
476
426
|
this._shadowRoot._connectToNode(this);
|
477
427
|
}
|
478
428
|
}
|
479
|
-
}
|
480
|
-
|
481
|
-
Node.ELEMENT_NODE = 1;
|
482
|
-
Node.TEXT_NODE = 3;
|
483
|
-
Node.COMMENT_NODE = 8;
|
484
|
-
Node.DOCUMENT_NODE = 9;
|
485
|
-
Node.DOCUMENT_TYPE_NODE = 10;
|
486
|
-
Node.DOCUMENT_FRAGMENT_NODE = 11;
|
487
|
-
Node.ownerDocument = null;
|
488
|
-
return Node;
|
489
|
-
}(EventTarget_1.default));
|
429
|
+
}
|
430
|
+
}
|
490
431
|
exports.default = Node;
|
432
|
+
// Public properties
|
433
|
+
Node.ELEMENT_NODE = 1;
|
434
|
+
Node.TEXT_NODE = 3;
|
435
|
+
Node.COMMENT_NODE = 8;
|
436
|
+
Node.DOCUMENT_NODE = 9;
|
437
|
+
Node.DOCUMENT_TYPE_NODE = 10;
|
438
|
+
Node.DOCUMENT_FRAGMENT_NODE = 11;
|
439
|
+
Node.ownerDocument = null;
|
491
440
|
//# sourceMappingURL=Node.js.map
|