happy-dom 2.55.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/README.md +26 -6
- package/lib/async-task-manager/AsyncTaskManager.js +34 -78
- package/lib/async-task-manager/AsyncTaskManager.js.map +1 -1
- package/lib/attribute/Attr.js +19 -28
- package/lib/attribute/Attr.js.map +1 -1
- package/lib/config/ElementTag.js +15 -15
- package/lib/config/ElementTag.js.map +1 -1
- package/lib/cookie/CookieUtility.js +21 -26
- package/lib/cookie/CookieUtility.js.map +1 -1
- package/lib/css/CSS.js +12 -18
- package/lib/css/CSS.js.map +1 -1
- package/lib/css/CSSParser.js +29 -33
- package/lib/css/CSSParser.js.map +1 -1
- package/lib/css/CSSRule.js +24 -29
- package/lib/css/CSSRule.js.map +1 -1
- package/lib/css/CSSStyleDeclaration.js +4516 -6005
- package/lib/css/CSSStyleDeclaration.js.map +1 -1
- package/lib/css/CSSStyleSheet.js +17 -59
- package/lib/css/CSSStyleSheet.js.map +1 -1
- package/lib/css/CSSUnitValue.js +4 -5
- package/lib/css/CSSUnitValue.js.map +1 -1
- package/lib/css/MediaList.js +23 -28
- package/lib/css/MediaList.js.map +1 -1
- package/lib/css/rules/CSSFontFaceRule.js +6 -24
- package/lib/css/rules/CSSFontFaceRule.js.map +1 -1
- package/lib/css/rules/CSSKeyframeRule.js +14 -36
- package/lib/css/rules/CSSKeyframeRule.js.map +1 -1
- package/lib/css/rules/CSSKeyframesRule.js +31 -54
- package/lib/css/rules/CSSKeyframesRule.js.map +1 -1
- package/lib/css/rules/CSSMediaRule.js +29 -56
- package/lib/css/rules/CSSMediaRule.js.map +1 -1
- package/lib/css/rules/CSSStyleRule.js +16 -38
- package/lib/css/rules/CSSStyleRule.js.map +1 -1
- package/lib/custom-element/CustomElementRegistry.js +21 -24
- package/lib/custom-element/CustomElementRegistry.js.map +1 -1
- package/lib/dom-implementation/DOMImplementation.js +12 -13
- package/lib/dom-implementation/DOMImplementation.js.map +1 -1
- package/lib/dom-parser/DOMParser.js +29 -35
- package/lib/dom-parser/DOMParser.js.map +1 -1
- package/lib/dom-token-list/DOMTokenList.js +64 -79
- package/lib/dom-token-list/DOMTokenList.js.map +1 -1
- package/lib/event/DataTransfer.js +4 -5
- package/lib/event/DataTransfer.js.map +1 -1
- package/lib/event/DataTransferItem.js +7 -8
- package/lib/event/DataTransferItem.js.map +1 -1
- package/lib/event/DataTransferItemList.js +10 -11
- package/lib/event/DataTransferItemList.js.map +1 -1
- package/lib/event/Event.js +11 -15
- package/lib/event/Event.js.map +1 -1
- package/lib/event/EventTarget.js +14 -16
- package/lib/event/EventTarget.js.map +1 -1
- package/lib/event/IUIEventInit.d.ts +2 -2
- package/lib/event/UIEvent.d.ts +2 -2
- package/lib/event/UIEvent.js +25 -46
- package/lib/event/UIEvent.js.map +1 -1
- package/lib/event/events/AnimationEvent.js +11 -29
- package/lib/event/events/AnimationEvent.js.map +1 -1
- package/lib/event/events/CustomEvent.js +9 -31
- package/lib/event/events/CustomEvent.js.map +1 -1
- package/lib/event/events/ErrorEvent.js +15 -34
- package/lib/event/events/ErrorEvent.js.map +1 -1
- package/lib/event/events/FocusEvent.js +7 -26
- package/lib/event/events/FocusEvent.js.map +1 -1
- package/lib/event/events/InputEvent.js +13 -32
- package/lib/event/events/InputEvent.js.map +1 -1
- package/lib/event/events/KeyboardEvent.js +27 -46
- package/lib/event/events/KeyboardEvent.js.map +1 -1
- package/lib/event/events/MouseEvent.js +33 -52
- package/lib/event/events/MouseEvent.js.map +1 -1
- package/lib/event/events/PointerEvent.js +25 -44
- package/lib/event/events/PointerEvent.js.map +1 -1
- package/lib/event/events/ProgressEvent.js +11 -30
- package/lib/event/events/ProgressEvent.js.map +1 -1
- package/lib/event/events/StorageEvent.js +13 -32
- package/lib/event/events/StorageEvent.js.map +1 -1
- package/lib/event/events/WheelEvent.js +16 -35
- package/lib/event/events/WheelEvent.js.map +1 -1
- package/lib/exception/DOMException.js +5 -24
- package/lib/exception/DOMException.js.map +1 -1
- package/lib/fetch/FetchHandler.js +18 -22
- package/lib/fetch/FetchHandler.js.map +1 -1
- package/lib/fetch/Headers.js +3 -23
- package/lib/fetch/Headers.js.map +1 -1
- package/lib/fetch/Request.js +61 -81
- package/lib/fetch/Request.js.map +1 -1
- package/lib/fetch/ResourceFetchHandler.js +18 -67
- package/lib/fetch/ResourceFetchHandler.js.map +1 -1
- package/lib/fetch/Response.js +61 -81
- package/lib/fetch/Response.js.map +1 -1
- package/lib/file/Blob.js +29 -78
- package/lib/file/Blob.js.map +1 -1
- package/lib/file/File.js +9 -27
- package/lib/file/File.js.map +1 -1
- package/lib/file/FileReader.js +57 -78
- package/lib/file/FileReader.js.map +1 -1
- package/lib/history/History.js +32 -37
- package/lib/history/History.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +69 -69
- package/lib/index.js.map +1 -1
- package/lib/location/Location.js +11 -28
- package/lib/location/Location.js.map +1 -1
- package/lib/location/RelativeURL.js +5 -8
- package/lib/location/RelativeURL.js.map +1 -1
- package/lib/location/URL.js +46 -59
- package/lib/location/URL.js.map +1 -1
- package/lib/match-media/MediaQueryList.js +28 -54
- package/lib/match-media/MediaQueryList.js.map +1 -1
- package/lib/mutation-observer/MutationListener.js +3 -4
- package/lib/mutation-observer/MutationListener.js.map +1 -1
- package/lib/mutation-observer/MutationObserver.js +12 -13
- package/lib/mutation-observer/MutationObserver.js.map +1 -1
- package/lib/mutation-observer/MutationRecord.js +3 -4
- package/lib/mutation-observer/MutationRecord.js.map +1 -1
- package/lib/navigator/MimeType.js +5 -6
- package/lib/navigator/MimeType.js.map +1 -1
- package/lib/navigator/MimeTypeArray.js +10 -11
- package/lib/navigator/MimeTypeArray.js.map +1 -1
- package/lib/navigator/Navigator.js +7 -8
- package/lib/navigator/Navigator.js.map +1 -1
- package/lib/navigator/Plugin.js +10 -11
- package/lib/navigator/Plugin.js.map +1 -1
- package/lib/navigator/PluginArray.js +12 -13
- package/lib/navigator/PluginArray.js.map +1 -1
- package/lib/nodes/character-data/CharacterData.js +119 -184
- package/lib/nodes/character-data/CharacterData.js.map +1 -1
- package/lib/nodes/character-data/CharacterDataUtility.js +12 -15
- package/lib/nodes/character-data/CharacterDataUtility.js.map +1 -1
- package/lib/nodes/child-node/ChildNodeUtility.js +24 -45
- package/lib/nodes/child-node/ChildNodeUtility.js.map +1 -1
- package/lib/nodes/child-node/NonDocumentChildNodeUtility.js +9 -12
- package/lib/nodes/child-node/NonDocumentChildNodeUtility.js.map +1 -1
- package/lib/nodes/comment/Comment.js +20 -43
- package/lib/nodes/comment/Comment.js.map +1 -1
- package/lib/nodes/document/Document.d.ts +3 -3
- package/lib/nodes/document/Document.js +334 -461
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/document/DocumentReadyStateManager.js +16 -19
- package/lib/nodes/document/DocumentReadyStateManager.js.map +1 -1
- package/lib/nodes/document/IDocument.d.ts +2 -2
- package/lib/nodes/document-fragment/DocumentFragment.js +93 -153
- package/lib/nodes/document-fragment/DocumentFragment.js.map +1 -1
- package/lib/nodes/document-type/DocumentType.js +22 -45
- package/lib/nodes/document-type/DocumentType.js.map +1 -1
- package/lib/nodes/element/DOMRect.js +3 -4
- package/lib/nodes/element/DOMRect.js.map +1 -1
- package/lib/nodes/element/Element.js +367 -496
- package/lib/nodes/element/Element.js.map +1 -1
- package/lib/nodes/element/HTMLCollection.js +4 -24
- package/lib/nodes/element/HTMLCollection.js.map +1 -1
- package/lib/nodes/element/HTMLCollectionFactory.js +6 -9
- package/lib/nodes/element/HTMLCollectionFactory.js.map +1 -1
- package/lib/nodes/element/Range.js +89 -114
- package/lib/nodes/element/Range.js.map +1 -1
- package/lib/nodes/html-base-element/HTMLBaseElement.js +41 -70
- package/lib/nodes/html-base-element/HTMLBaseElement.js.map +1 -1
- package/lib/nodes/html-document/HTMLDocument.js +3 -23
- package/lib/nodes/html-document/HTMLDocument.js.map +1 -1
- package/lib/nodes/html-element/DatasetUtility.js +9 -12
- package/lib/nodes/html-element/DatasetUtility.js.map +1 -1
- package/lib/nodes/html-element/HTMLElement.js +232 -290
- package/lib/nodes/html-element/HTMLElement.js.map +1 -1
- package/lib/nodes/html-form-element/HTMLFormElement.js +170 -235
- package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
- package/lib/nodes/html-image-element/HTMLImageElement.js +178 -237
- package/lib/nodes/html-image-element/HTMLImageElement.js.map +1 -1
- package/lib/nodes/html-image-element/Image.js +7 -27
- package/lib/nodes/html-image-element/Image.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElement.js +705 -872
- package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js +9 -12
- package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js +5 -8
- package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js.map +1 -1
- package/lib/nodes/html-input-element/ValidityState.js +47 -69
- package/lib/nodes/html-input-element/ValidityState.js.map +1 -1
- package/lib/nodes/html-label-element/HTMLLabelElement.js +53 -87
- package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElement.js +197 -252
- package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
- package/lib/nodes/html-meta-element/HTMLMetaElement.js +66 -102
- package/lib/nodes/html-meta-element/HTMLMetaElement.js.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElement.js +145 -193
- package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
- package/lib/nodes/html-script-element/ScriptUtility.js +58 -112
- package/lib/nodes/html-script-element/ScriptUtility.js.map +1 -1
- package/lib/nodes/html-slot-element/HTMLSlotElement.js +33 -65
- package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -1
- package/lib/nodes/html-style-element/HTMLStyleElement.js +75 -109
- package/lib/nodes/html-style-element/HTMLStyleElement.js.map +1 -1
- package/lib/nodes/html-template-element/HTMLTemplateElement.js +60 -99
- package/lib/nodes/html-template-element/HTMLTemplateElement.js.map +1 -1
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +349 -444
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
- package/lib/nodes/html-unknown-element/HTMLUnknownElement.js +17 -37
- package/lib/nodes/html-unknown-element/HTMLUnknownElement.js.map +1 -1
- package/lib/nodes/node/Node.js +193 -260
- package/lib/nodes/node/Node.js.map +1 -1
- package/lib/nodes/node/NodeList.js +4 -24
- package/lib/nodes/node/NodeList.js.map +1 -1
- package/lib/nodes/node/NodeListFactory.js +6 -9
- package/lib/nodes/node/NodeListFactory.js.map +1 -1
- package/lib/nodes/parent-node/ParentNodeUtility.js +43 -78
- package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
- package/lib/nodes/shadow-root/ShadowRoot.js +53 -83
- package/lib/nodes/shadow-root/ShadowRoot.js.map +1 -1
- package/lib/nodes/svg-document/SVGDocument.js +3 -23
- package/lib/nodes/svg-document/SVGDocument.js.map +1 -1
- package/lib/nodes/svg-element/DOMMatrix.js +3 -4
- package/lib/nodes/svg-element/DOMMatrix.js.map +1 -1
- package/lib/nodes/svg-element/SVGAngle.js +10 -11
- package/lib/nodes/svg-element/SVGAngle.js.map +1 -1
- package/lib/nodes/svg-element/SVGAnimatedRect.js +4 -5
- package/lib/nodes/svg-element/SVGAnimatedRect.js.map +1 -1
- package/lib/nodes/svg-element/SVGElement.js +58 -93
- package/lib/nodes/svg-element/SVGElement.js.map +1 -1
- package/lib/nodes/svg-element/SVGGraphicsElement.js +14 -32
- package/lib/nodes/svg-element/SVGGraphicsElement.js.map +1 -1
- package/lib/nodes/svg-element/SVGLength.js +16 -17
- package/lib/nodes/svg-element/SVGLength.js.map +1 -1
- package/lib/nodes/svg-element/SVGNumber.js +3 -4
- package/lib/nodes/svg-element/SVGNumber.js.map +1 -1
- package/lib/nodes/svg-element/SVGPoint.js +3 -4
- package/lib/nodes/svg-element/SVGPoint.js.map +1 -1
- package/lib/nodes/svg-element/SVGRect.js +3 -4
- package/lib/nodes/svg-element/SVGRect.js.map +1 -1
- package/lib/nodes/svg-element/SVGSVGElement.js +187 -248
- package/lib/nodes/svg-element/SVGSVGElement.js.map +1 -1
- package/lib/nodes/svg-element/SVGTransform.js +16 -17
- package/lib/nodes/svg-element/SVGTransform.js.map +1 -1
- package/lib/nodes/text/Text.js +20 -43
- package/lib/nodes/text/Text.js.map +1 -1
- package/lib/nodes/xml-document/XMLDocument.js +3 -23
- package/lib/nodes/xml-document/XMLDocument.js.map +1 -1
- package/lib/query-selector/QuerySelector.js +36 -44
- package/lib/query-selector/QuerySelector.js.map +1 -1
- package/lib/query-selector/SelectorItem.js +62 -66
- package/lib/query-selector/SelectorItem.js.map +1 -1
- package/lib/resize-observer/ResizeObserver.js +8 -11
- package/lib/resize-observer/ResizeObserver.js.map +1 -1
- package/lib/screen/Screen.js +3 -4
- package/lib/screen/Screen.js.map +1 -1
- package/lib/selection/Selection.js +29 -30
- package/lib/selection/Selection.js.map +1 -1
- package/lib/storage/Storage.js +22 -27
- package/lib/storage/Storage.js.map +1 -1
- package/lib/tree-walker/NodeFilterMask.js +1 -1
- package/lib/tree-walker/NodeFilterMask.js.map +1 -1
- package/lib/tree-walker/TreeWalker.js +30 -33
- package/lib/tree-walker/TreeWalker.js.map +1 -1
- package/lib/window/GlobalWindow.d.ts +90 -0
- package/lib/window/GlobalWindow.js +98 -0
- package/lib/window/GlobalWindow.js.map +1 -0
- package/lib/window/IWindow.d.ts +35 -18
- package/lib/window/VMGlobalPropertyScript.d.ts +2 -0
- package/lib/window/VMGlobalPropertyScript.js +65 -0
- package/lib/window/VMGlobalPropertyScript.js.map +1 -0
- package/lib/window/Window.d.ts +84 -105
- package/lib/window/Window.js +286 -490
- package/lib/window/Window.js.map +1 -1
- package/lib/xml-parser/XMLParser.js +65 -71
- package/lib/xml-parser/XMLParser.js.map +1 -1
- package/lib/xml-serializer/XMLSerializer.js +30 -37
- package/lib/xml-serializer/XMLSerializer.js.map +1 -1
- package/package.json +6 -7
- package/src/dom-parser/DOMParser.ts +4 -5
- package/src/event/IUIEventInit.ts +2 -2
- package/src/event/UIEvent.ts +2 -2
- package/src/fetch/FetchHandler.ts +3 -3
- package/src/fetch/ResourceFetchHandler.ts +2 -2
- package/src/index.ts +3 -3
- package/src/nodes/document/Document.ts +4 -4
- package/src/nodes/document/IDocument.ts +2 -2
- package/src/nodes/html-link-element/HTMLLinkElement.ts +8 -2
- package/src/nodes/html-script-element/ScriptUtility.ts +4 -4
- package/src/window/GlobalWindow.ts +91 -0
- package/src/window/IWindow.ts +31 -12
- package/src/window/VMGlobalPropertyScript.ts +62 -0
- package/src/window/Window.ts +125 -173
- package/tsconfig.json +1 -1
- package/lib/window/AsyncWindow.d.ts +0 -10
- package/lib/window/AsyncWindow.js +0 -38
- package/lib/window/AsyncWindow.js.map +0 -1
- package/src/window/AsyncWindow.ts +0 -17
package/lib/nodes/node/Node.js
CHANGED
@@ -1,225 +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];
|
162
|
-
}
|
163
|
-
return null;
|
164
|
-
},
|
165
|
-
enumerable: false,
|
166
|
-
configurable: true
|
167
|
-
});
|
168
|
-
Object.defineProperty(Node.prototype, "parentElement", {
|
169
|
-
/**
|
170
|
-
* Returns parent element.
|
171
|
-
*
|
172
|
-
* @returns Element.
|
173
|
-
*/
|
174
|
-
get: function () {
|
175
|
-
var parent = this.parentNode;
|
176
|
-
while (parent && parent.nodeType !== Node.ELEMENT_NODE) {
|
177
|
-
parent = parent.parentNode;
|
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];
|
178
83
|
}
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
if (base) {
|
193
|
-
return base.href;
|
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];
|
194
97
|
}
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
+
}
|
200
147
|
/**
|
201
148
|
* Returns "true" if the node has child nodes.
|
202
149
|
*
|
203
150
|
* @returns "true" if the node has child nodes.
|
204
151
|
*/
|
205
|
-
|
152
|
+
hasChildNodes() {
|
206
153
|
return this.childNodes.length > 0;
|
207
|
-
}
|
154
|
+
}
|
208
155
|
/**
|
209
156
|
* Returns "true" if this node contains the other node.
|
210
157
|
*
|
211
158
|
* @param otherNode Node to test with.
|
212
159
|
* @returns "true" if this node contains the other node.
|
213
160
|
*/
|
214
|
-
|
215
|
-
for (
|
216
|
-
var childNode = _a[_i];
|
161
|
+
contains(otherNode) {
|
162
|
+
for (const childNode of this.childNodes) {
|
217
163
|
if (childNode === otherNode || childNode.contains(otherNode)) {
|
218
164
|
return true;
|
219
165
|
}
|
220
166
|
}
|
221
167
|
return false;
|
222
|
-
}
|
168
|
+
}
|
223
169
|
/**
|
224
170
|
* Returns closest root node (Document or ShadowRoot).
|
225
171
|
*
|
@@ -227,64 +173,60 @@ var Node = /** @class */ (function (_super) {
|
|
227
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).
|
228
174
|
* @returns Node.
|
229
175
|
*/
|
230
|
-
|
176
|
+
getRootNode(options) {
|
231
177
|
if (!this.isConnected) {
|
232
178
|
return this;
|
233
179
|
}
|
234
|
-
if (this._rootNode && !
|
180
|
+
if (this._rootNode && !options?.composed) {
|
235
181
|
return this._rootNode;
|
236
182
|
}
|
237
183
|
return this.ownerDocument;
|
238
|
-
}
|
184
|
+
}
|
239
185
|
/**
|
240
186
|
* Clones a node.
|
241
187
|
*
|
242
188
|
* @param [deep=false] "true" to clone deep.
|
243
189
|
* @returns Cloned node.
|
244
190
|
*/
|
245
|
-
|
246
|
-
|
247
|
-
var clone = new this.constructor();
|
191
|
+
cloneNode(deep = false) {
|
192
|
+
const clone = new this.constructor();
|
248
193
|
// Document has childNodes directly when it is created
|
249
194
|
if (clone.childNodes.length) {
|
250
|
-
for (
|
251
|
-
var node = _a[_i];
|
195
|
+
for (const node of clone.childNodes.slice()) {
|
252
196
|
node.parentNode.removeChild(node);
|
253
197
|
}
|
254
198
|
}
|
255
199
|
if (deep) {
|
256
|
-
for (
|
257
|
-
|
258
|
-
var childClone = childNode.cloneNode(true);
|
200
|
+
for (const childNode of this.childNodes) {
|
201
|
+
const childClone = childNode.cloneNode(true);
|
259
202
|
childClone.parentNode = clone;
|
260
203
|
clone.childNodes.push(childClone);
|
261
204
|
}
|
262
205
|
}
|
263
206
|
clone.ownerDocument = this.ownerDocument;
|
264
207
|
return clone;
|
265
|
-
}
|
208
|
+
}
|
266
209
|
/**
|
267
210
|
* Append a child node to childNodes.
|
268
211
|
*
|
269
212
|
* @param node Node to append.
|
270
213
|
* @returns Appended node.
|
271
214
|
*/
|
272
|
-
|
215
|
+
appendChild(node) {
|
273
216
|
if (node === this) {
|
274
217
|
throw new DOMException_1.default('Not possible to append a node as a child of itself.');
|
275
218
|
}
|
276
219
|
// If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
|
277
220
|
// See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
278
221
|
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
279
|
-
for (
|
280
|
-
var child = _a[_i];
|
222
|
+
for (const child of node.childNodes.slice()) {
|
281
223
|
this.appendChild(child);
|
282
224
|
}
|
283
225
|
return node;
|
284
226
|
}
|
285
227
|
// Remove the node from its previous parent if it has any.
|
286
228
|
if (node.parentNode) {
|
287
|
-
|
229
|
+
const index = node.parentNode.childNodes.indexOf(node);
|
288
230
|
if (index !== -1) {
|
289
231
|
node.parentNode.childNodes.splice(index, 1);
|
290
232
|
}
|
@@ -293,12 +235,11 @@ var Node = /** @class */ (function (_super) {
|
|
293
235
|
node._connectToNode(this);
|
294
236
|
// MutationObserver
|
295
237
|
if (this._observers.length > 0) {
|
296
|
-
|
238
|
+
const record = new MutationRecord_1.default();
|
297
239
|
record.target = this;
|
298
240
|
record.type = MutationTypeEnum_1.default.childList;
|
299
241
|
record.addedNodes = [node];
|
300
|
-
for (
|
301
|
-
var observer = _c[_b];
|
242
|
+
for (const observer of this._observers) {
|
302
243
|
if (observer.options.subtree) {
|
303
244
|
node._observe(observer);
|
304
245
|
}
|
@@ -308,15 +249,15 @@ var Node = /** @class */ (function (_super) {
|
|
308
249
|
}
|
309
250
|
}
|
310
251
|
return node;
|
311
|
-
}
|
252
|
+
}
|
312
253
|
/**
|
313
254
|
* Remove Child element from childNodes array.
|
314
255
|
*
|
315
256
|
* @param node Node to remove.
|
316
257
|
* @returns Removed node.
|
317
258
|
*/
|
318
|
-
|
319
|
-
|
259
|
+
removeChild(node) {
|
260
|
+
const index = this.childNodes.indexOf(node);
|
320
261
|
if (index === -1) {
|
321
262
|
throw new DOMException_1.default('Failed to remove node. Node is not child of parent.');
|
322
263
|
}
|
@@ -324,12 +265,11 @@ var Node = /** @class */ (function (_super) {
|
|
324
265
|
node._connectToNode(null);
|
325
266
|
// MutationObserver
|
326
267
|
if (this._observers.length > 0) {
|
327
|
-
|
268
|
+
const record = new MutationRecord_1.default();
|
328
269
|
record.target = this;
|
329
270
|
record.type = MutationTypeEnum_1.default.childList;
|
330
271
|
record.removedNodes = [node];
|
331
|
-
for (
|
332
|
-
var observer = _a[_i];
|
272
|
+
for (const observer of this._observers) {
|
333
273
|
node._unobserve(observer);
|
334
274
|
if (observer.options.childList) {
|
335
275
|
observer.callback([record]);
|
@@ -337,7 +277,7 @@ var Node = /** @class */ (function (_super) {
|
|
337
277
|
}
|
338
278
|
}
|
339
279
|
return node;
|
340
|
-
}
|
280
|
+
}
|
341
281
|
/**
|
342
282
|
* Inserts a node before another.
|
343
283
|
*
|
@@ -345,12 +285,11 @@ var Node = /** @class */ (function (_super) {
|
|
345
285
|
* @param [referenceNode] Node to insert before.
|
346
286
|
* @returns Inserted node.
|
347
287
|
*/
|
348
|
-
|
288
|
+
insertBefore(newNode, referenceNode) {
|
349
289
|
// If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
|
350
290
|
// See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
351
291
|
if (newNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
352
|
-
for (
|
353
|
-
var child = _a[_i];
|
292
|
+
for (const child of newNode.childNodes.slice()) {
|
354
293
|
this.insertBefore(child, referenceNode);
|
355
294
|
}
|
356
295
|
return newNode;
|
@@ -362,26 +301,25 @@ var Node = /** @class */ (function (_super) {
|
|
362
301
|
if (referenceNode === undefined) {
|
363
302
|
throw new DOMException_1.default("Failed to execute 'insertBefore' on 'Node': 2 arguments required, but only 1 present.", 'TypeError');
|
364
303
|
}
|
365
|
-
|
304
|
+
const index = referenceNode ? this.childNodes.indexOf(referenceNode) : 0;
|
366
305
|
if (index === -1) {
|
367
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.");
|
368
307
|
}
|
369
308
|
if (newNode.parentNode) {
|
370
|
-
|
371
|
-
if (
|
372
|
-
newNode.parentNode.childNodes.splice(
|
309
|
+
const index = newNode.parentNode.childNodes.indexOf(newNode);
|
310
|
+
if (index !== -1) {
|
311
|
+
newNode.parentNode.childNodes.splice(index, 1);
|
373
312
|
}
|
374
313
|
}
|
375
314
|
this.childNodes.splice(index, 0, newNode);
|
376
315
|
newNode._connectToNode(this);
|
377
316
|
// MutationObserver
|
378
317
|
if (this._observers.length > 0) {
|
379
|
-
|
318
|
+
const record = new MutationRecord_1.default();
|
380
319
|
record.target = this;
|
381
320
|
record.type = MutationTypeEnum_1.default.childList;
|
382
321
|
record.addedNodes = [newNode];
|
383
|
-
for (
|
384
|
-
var observer = _c[_b];
|
322
|
+
for (const observer of this._observers) {
|
385
323
|
if (observer.options.subtree) {
|
386
324
|
newNode._observe(observer);
|
387
325
|
}
|
@@ -391,7 +329,7 @@ var Node = /** @class */ (function (_super) {
|
|
391
329
|
}
|
392
330
|
}
|
393
331
|
return newNode;
|
394
|
-
}
|
332
|
+
}
|
395
333
|
/**
|
396
334
|
* Replaces a node with another.
|
397
335
|
*
|
@@ -399,16 +337,16 @@ var Node = /** @class */ (function (_super) {
|
|
399
337
|
* @param oldChild Old child.
|
400
338
|
* @returns Replaced node.
|
401
339
|
*/
|
402
|
-
|
340
|
+
replaceChild(newChild, oldChild) {
|
403
341
|
this.insertBefore(newChild, oldChild);
|
404
342
|
this.removeChild(oldChild);
|
405
343
|
return oldChild;
|
406
|
-
}
|
344
|
+
}
|
407
345
|
/**
|
408
346
|
* @override
|
409
347
|
*/
|
410
|
-
|
411
|
-
|
348
|
+
dispatchEvent(event) {
|
349
|
+
const returnValue = super.dispatchEvent(event);
|
412
350
|
if (event.bubbles && !event._propagationStopped) {
|
413
351
|
if (this.parentNode) {
|
414
352
|
return this.parentNode.dispatchEvent(event);
|
@@ -420,56 +358,53 @@ var Node = /** @class */ (function (_super) {
|
|
420
358
|
}
|
421
359
|
}
|
422
360
|
return returnValue;
|
423
|
-
}
|
361
|
+
}
|
424
362
|
/**
|
425
363
|
* Converts the node to a string.
|
426
364
|
*
|
427
365
|
* @param listener Listener.
|
428
366
|
*/
|
429
|
-
|
430
|
-
return
|
431
|
-
}
|
367
|
+
toString() {
|
368
|
+
return `[object ${this.constructor.name}]`;
|
369
|
+
}
|
432
370
|
/**
|
433
371
|
* Observeres the node.
|
434
372
|
* Used by MutationObserver, but it is not part of the HTML standard.
|
435
373
|
*
|
436
374
|
* @param listener Listener.
|
437
375
|
*/
|
438
|
-
|
376
|
+
_observe(listener) {
|
439
377
|
this._observers.push(listener);
|
440
378
|
if (listener.options.subtree) {
|
441
|
-
for (
|
442
|
-
var node = _a[_i];
|
379
|
+
for (const node of this.childNodes) {
|
443
380
|
node._observe(listener);
|
444
381
|
}
|
445
382
|
}
|
446
|
-
}
|
383
|
+
}
|
447
384
|
/**
|
448
385
|
* Stops observing the node.
|
449
386
|
* Used by MutationObserver, but it is not part of the HTML standard.
|
450
387
|
*
|
451
388
|
* @param listener Listener.
|
452
389
|
*/
|
453
|
-
|
454
|
-
|
390
|
+
_unobserve(listener) {
|
391
|
+
const index = this._observers.indexOf(listener);
|
455
392
|
if (index !== -1) {
|
456
393
|
this._observers.splice(index, 1);
|
457
394
|
}
|
458
395
|
if (listener.options.subtree) {
|
459
|
-
for (
|
460
|
-
var node = _a[_i];
|
396
|
+
for (const node of this.childNodes) {
|
461
397
|
node._unobserve(listener);
|
462
398
|
}
|
463
399
|
}
|
464
|
-
}
|
400
|
+
}
|
465
401
|
/**
|
466
402
|
* Connects this element to another element.
|
467
403
|
*
|
468
404
|
* @param parentNode Parent node.
|
469
405
|
*/
|
470
|
-
|
471
|
-
|
472
|
-
var isConnected = !!parentNode && parentNode.isConnected;
|
406
|
+
_connectToNode(parentNode = null) {
|
407
|
+
const isConnected = !!parentNode && parentNode.isConnected;
|
473
408
|
if (this.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
|
474
409
|
this.parentNode = parentNode;
|
475
410
|
this._rootNode = isConnected && parentNode ? parentNode._rootNode : null;
|
@@ -482,8 +417,7 @@ var Node = /** @class */ (function (_super) {
|
|
482
417
|
else if (!isConnected && this.disconnectedCallback) {
|
483
418
|
this.disconnectedCallback();
|
484
419
|
}
|
485
|
-
for (
|
486
|
-
var child = _a[_i];
|
420
|
+
for (const child of this.childNodes) {
|
487
421
|
child._connectToNode(this);
|
488
422
|
}
|
489
423
|
// eslint-disable-next-line
|
@@ -492,16 +426,15 @@ var Node = /** @class */ (function (_super) {
|
|
492
426
|
this._shadowRoot._connectToNode(this);
|
493
427
|
}
|
494
428
|
}
|
495
|
-
}
|
496
|
-
|
497
|
-
Node.ELEMENT_NODE = 1;
|
498
|
-
Node.TEXT_NODE = 3;
|
499
|
-
Node.COMMENT_NODE = 8;
|
500
|
-
Node.DOCUMENT_NODE = 9;
|
501
|
-
Node.DOCUMENT_TYPE_NODE = 10;
|
502
|
-
Node.DOCUMENT_FRAGMENT_NODE = 11;
|
503
|
-
Node.ownerDocument = null;
|
504
|
-
return Node;
|
505
|
-
}(EventTarget_1.default));
|
429
|
+
}
|
430
|
+
}
|
506
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;
|
507
440
|
//# sourceMappingURL=Node.js.map
|