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
@@ -1,330 +1,239 @@
|
|
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
|
-
|
6
|
+
const Node_1 = __importDefault(require("../node/Node"));
|
7
|
+
const ShadowRoot_1 = __importDefault(require("../shadow-root/ShadowRoot"));
|
8
|
+
const Attr_1 = __importDefault(require("../../attribute/Attr"));
|
9
|
+
const DOMRect_1 = __importDefault(require("./DOMRect"));
|
10
|
+
const Range_1 = __importDefault(require("./Range"));
|
11
|
+
const DOMTokenList_1 = __importDefault(require("../../dom-token-list/DOMTokenList"));
|
12
|
+
const QuerySelector_1 = __importDefault(require("../../query-selector/QuerySelector"));
|
13
|
+
const SelectorItem_1 = __importDefault(require("../../query-selector/SelectorItem"));
|
14
|
+
const MutationRecord_1 = __importDefault(require("../../mutation-observer/MutationRecord"));
|
15
|
+
const MutationTypeEnum_1 = __importDefault(require("../../mutation-observer/MutationTypeEnum"));
|
16
|
+
const NamespaceURI_1 = __importDefault(require("../../config/NamespaceURI"));
|
17
|
+
const XMLParser_1 = __importDefault(require("../../xml-parser/XMLParser"));
|
18
|
+
const XMLSerializer_1 = __importDefault(require("../../xml-serializer/XMLSerializer"));
|
19
|
+
const ChildNodeUtility_1 = __importDefault(require("../child-node/ChildNodeUtility"));
|
20
|
+
const ParentNodeUtility_1 = __importDefault(require("../parent-node/ParentNodeUtility"));
|
21
|
+
const NonDocumentChildNodeUtility_1 = __importDefault(require("../child-node/NonDocumentChildNodeUtility"));
|
22
|
+
const DOMException_1 = __importDefault(require("../../exception/DOMException"));
|
23
|
+
const HTMLCollectionFactory_1 = __importDefault(require("./HTMLCollectionFactory"));
|
48
24
|
/**
|
49
25
|
* Element.
|
50
26
|
*/
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
_this.namespaceURI = null;
|
27
|
+
class Element extends Node_1.default {
|
28
|
+
constructor() {
|
29
|
+
super(...arguments);
|
30
|
+
this.tagName = null;
|
31
|
+
this.nodeType = Node_1.default.ELEMENT_NODE;
|
32
|
+
this.shadowRoot = null;
|
33
|
+
this.scrollTop = 0;
|
34
|
+
this.scrollLeft = 0;
|
35
|
+
this.children = HTMLCollectionFactory_1.default.create();
|
36
|
+
this.namespaceURI = null;
|
62
37
|
// Used for being able to access closed shadow roots
|
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
|
-
|
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
|
-
get: function () {
|
154
|
-
return NonDocumentChildNodeUtility_1.default.previousElementSibling(this);
|
155
|
-
},
|
156
|
-
enumerable: false,
|
157
|
-
configurable: true
|
158
|
-
});
|
159
|
-
Object.defineProperty(Element.prototype, "nextElementSibling", {
|
160
|
-
/**
|
161
|
-
* Next element sibling.
|
162
|
-
*
|
163
|
-
* @returns Element.
|
164
|
-
*/
|
165
|
-
get: function () {
|
166
|
-
return NonDocumentChildNodeUtility_1.default.nextElementSibling(this);
|
167
|
-
},
|
168
|
-
enumerable: false,
|
169
|
-
configurable: true
|
170
|
-
});
|
171
|
-
Object.defineProperty(Element.prototype, "textContent", {
|
172
|
-
/**
|
173
|
-
* Get text value of children.
|
174
|
-
*
|
175
|
-
* @returns Text content.
|
176
|
-
*/
|
177
|
-
get: function () {
|
178
|
-
var result = '';
|
179
|
-
for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
|
180
|
-
var childNode = _a[_i];
|
181
|
-
if (childNode.nodeType === Node_1.default.ELEMENT_NODE || childNode.nodeType === Node_1.default.TEXT_NODE) {
|
182
|
-
result += childNode.textContent;
|
183
|
-
}
|
184
|
-
}
|
185
|
-
return result;
|
186
|
-
},
|
187
|
-
/**
|
188
|
-
* Sets text content.
|
189
|
-
*
|
190
|
-
* @param textContent Text content.
|
191
|
-
*/
|
192
|
-
set: function (textContent) {
|
193
|
-
for (var _i = 0, _a = this.childNodes.slice(); _i < _a.length; _i++) {
|
194
|
-
var child = _a[_i];
|
195
|
-
this.removeChild(child);
|
196
|
-
}
|
197
|
-
if (textContent) {
|
198
|
-
this.appendChild(this.ownerDocument.createTextNode(textContent));
|
199
|
-
}
|
200
|
-
},
|
201
|
-
enumerable: false,
|
202
|
-
configurable: true
|
203
|
-
});
|
204
|
-
Object.defineProperty(Element.prototype, "innerHTML", {
|
205
|
-
/**
|
206
|
-
* Returns inner HTML.
|
207
|
-
*
|
208
|
-
* @returns HTML.
|
209
|
-
*/
|
210
|
-
get: function () {
|
211
|
-
var xmlSerializer = new XMLSerializer_1.default();
|
212
|
-
var xml = '';
|
213
|
-
for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
|
214
|
-
var node = _a[_i];
|
215
|
-
xml += xmlSerializer.serializeToString(node);
|
216
|
-
}
|
217
|
-
return xml;
|
218
|
-
},
|
219
|
-
/**
|
220
|
-
* Sets inner HTML.
|
221
|
-
*
|
222
|
-
* @param html HTML.
|
223
|
-
*/
|
224
|
-
set: function (html) {
|
225
|
-
for (var _i = 0, _a = this.childNodes.slice(); _i < _a.length; _i++) {
|
226
|
-
var child = _a[_i];
|
227
|
-
this.removeChild(child);
|
228
|
-
}
|
229
|
-
for (var _b = 0, _c = XMLParser_1.default.parse(this.ownerDocument, html).childNodes.slice(); _b < _c.length; _b++) {
|
230
|
-
var node = _c[_b];
|
231
|
-
this.appendChild(node);
|
38
|
+
this._shadowRoot = null;
|
39
|
+
this._attributes = {};
|
40
|
+
this._classList = null;
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* Returns class list.
|
44
|
+
*
|
45
|
+
* @returns Class list.
|
46
|
+
*/
|
47
|
+
get classList() {
|
48
|
+
if (!this._classList) {
|
49
|
+
this._classList = new DOMTokenList_1.default(this, 'class');
|
50
|
+
}
|
51
|
+
return this._classList;
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Returns ID.
|
55
|
+
*
|
56
|
+
* @returns ID.
|
57
|
+
*/
|
58
|
+
get id() {
|
59
|
+
return this.getAttribute('id') || '';
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Sets ID.
|
63
|
+
*
|
64
|
+
* @param id ID.
|
65
|
+
*/
|
66
|
+
set id(id) {
|
67
|
+
this.setAttribute('id', id);
|
68
|
+
}
|
69
|
+
/**
|
70
|
+
* Returns class name.
|
71
|
+
*
|
72
|
+
* @returns Class name.
|
73
|
+
*/
|
74
|
+
get className() {
|
75
|
+
return this.getAttribute('class') || '';
|
76
|
+
}
|
77
|
+
/**
|
78
|
+
* Sets class name.
|
79
|
+
*
|
80
|
+
* @param className Class name.
|
81
|
+
*/
|
82
|
+
set className(className) {
|
83
|
+
this.setAttribute('class', className);
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* Node name.
|
87
|
+
*
|
88
|
+
* @returns Node name.
|
89
|
+
*/
|
90
|
+
get nodeName() {
|
91
|
+
return this.tagName;
|
92
|
+
}
|
93
|
+
/**
|
94
|
+
* Local name.
|
95
|
+
*
|
96
|
+
* @returns Local name.
|
97
|
+
*/
|
98
|
+
get localName() {
|
99
|
+
return this.tagName ? this.tagName.toLowerCase() : 'unknown';
|
100
|
+
}
|
101
|
+
/**
|
102
|
+
* Previous element sibling.
|
103
|
+
*
|
104
|
+
* @returns Element.
|
105
|
+
*/
|
106
|
+
get previousElementSibling() {
|
107
|
+
return NonDocumentChildNodeUtility_1.default.previousElementSibling(this);
|
108
|
+
}
|
109
|
+
/**
|
110
|
+
* Next element sibling.
|
111
|
+
*
|
112
|
+
* @returns Element.
|
113
|
+
*/
|
114
|
+
get nextElementSibling() {
|
115
|
+
return NonDocumentChildNodeUtility_1.default.nextElementSibling(this);
|
116
|
+
}
|
117
|
+
/**
|
118
|
+
* Get text value of children.
|
119
|
+
*
|
120
|
+
* @returns Text content.
|
121
|
+
*/
|
122
|
+
get textContent() {
|
123
|
+
let result = '';
|
124
|
+
for (const childNode of this.childNodes) {
|
125
|
+
if (childNode.nodeType === Node_1.default.ELEMENT_NODE || childNode.nodeType === Node_1.default.TEXT_NODE) {
|
126
|
+
result += childNode.textContent;
|
232
127
|
}
|
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
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
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
|
-
|
327
|
-
|
128
|
+
}
|
129
|
+
return result;
|
130
|
+
}
|
131
|
+
/**
|
132
|
+
* Sets text content.
|
133
|
+
*
|
134
|
+
* @param textContent Text content.
|
135
|
+
*/
|
136
|
+
set textContent(textContent) {
|
137
|
+
for (const child of this.childNodes.slice()) {
|
138
|
+
this.removeChild(child);
|
139
|
+
}
|
140
|
+
if (textContent) {
|
141
|
+
this.appendChild(this.ownerDocument.createTextNode(textContent));
|
142
|
+
}
|
143
|
+
}
|
144
|
+
/**
|
145
|
+
* Returns inner HTML.
|
146
|
+
*
|
147
|
+
* @returns HTML.
|
148
|
+
*/
|
149
|
+
get innerHTML() {
|
150
|
+
const xmlSerializer = new XMLSerializer_1.default();
|
151
|
+
let xml = '';
|
152
|
+
for (const node of this.childNodes) {
|
153
|
+
xml += xmlSerializer.serializeToString(node);
|
154
|
+
}
|
155
|
+
return xml;
|
156
|
+
}
|
157
|
+
/**
|
158
|
+
* Sets inner HTML.
|
159
|
+
*
|
160
|
+
* @param html HTML.
|
161
|
+
*/
|
162
|
+
set innerHTML(html) {
|
163
|
+
for (const child of this.childNodes.slice()) {
|
164
|
+
this.removeChild(child);
|
165
|
+
}
|
166
|
+
for (const node of XMLParser_1.default.parse(this.ownerDocument, html).childNodes.slice()) {
|
167
|
+
this.appendChild(node);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
/**
|
171
|
+
* Returns outer HTML.
|
172
|
+
*
|
173
|
+
* @returns HTML.
|
174
|
+
*/
|
175
|
+
get outerHTML() {
|
176
|
+
return new XMLSerializer_1.default().serializeToString(this);
|
177
|
+
}
|
178
|
+
/**
|
179
|
+
* Returns outer HTML.
|
180
|
+
*
|
181
|
+
* @param html HTML.
|
182
|
+
*/
|
183
|
+
set outerHTML(html) {
|
184
|
+
this.replaceWith(html);
|
185
|
+
}
|
186
|
+
/**
|
187
|
+
* Returns attributes.
|
188
|
+
*
|
189
|
+
* @returns Attributes.
|
190
|
+
*/
|
191
|
+
get attributes() {
|
192
|
+
const attributes = Object.values(this._attributes);
|
193
|
+
return Object.assign({}, this._attributes, attributes, {
|
194
|
+
length: attributes.length
|
195
|
+
});
|
196
|
+
}
|
197
|
+
/**
|
198
|
+
* First element child.
|
199
|
+
*
|
200
|
+
* @returns Element.
|
201
|
+
*/
|
202
|
+
get firstElementChild() {
|
203
|
+
return this.children ? this.children[0] || null : null;
|
204
|
+
}
|
205
|
+
/**
|
206
|
+
* Last element child.
|
207
|
+
*
|
208
|
+
* @returns Element.
|
209
|
+
*/
|
210
|
+
get lastElementChild() {
|
211
|
+
return this.children ? this.children[this.children.length - 1] || null : null;
|
212
|
+
}
|
213
|
+
/**
|
214
|
+
* Last element child.
|
215
|
+
*
|
216
|
+
* @returns Element.
|
217
|
+
*/
|
218
|
+
get childElementCount() {
|
219
|
+
return this.children.length;
|
220
|
+
}
|
221
|
+
/**
|
222
|
+
* Returns slot.
|
223
|
+
*
|
224
|
+
* @returns Slot.
|
225
|
+
*/
|
226
|
+
get slot() {
|
227
|
+
return this.getAttributeNS(null, 'slot') || '';
|
228
|
+
}
|
229
|
+
/**
|
230
|
+
* Returns slot.
|
231
|
+
*
|
232
|
+
* @param slot Slot.
|
233
|
+
*/
|
234
|
+
set slot(title) {
|
235
|
+
this.setAttributeNS(null, 'slot', title);
|
236
|
+
}
|
328
237
|
/**
|
329
238
|
* Returns inner HTML and optionally the content of shadow roots.
|
330
239
|
*
|
@@ -336,15 +245,14 @@ var Element = /** @class */ (function (_super) {
|
|
336
245
|
* @param [options.includeShadowRoots] Set to "true" to include shadow roots.
|
337
246
|
* @returns HTML.
|
338
247
|
*/
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
for (
|
343
|
-
var node = _a[_i];
|
248
|
+
getInnerHTML(options) {
|
249
|
+
const xmlSerializer = new XMLSerializer_1.default();
|
250
|
+
let xml = '';
|
251
|
+
for (const node of this.childNodes) {
|
344
252
|
xml += xmlSerializer.serializeToString(node, options);
|
345
253
|
}
|
346
254
|
return xml;
|
347
|
-
}
|
255
|
+
}
|
348
256
|
/**
|
349
257
|
* Clones a node.
|
350
258
|
*
|
@@ -352,18 +260,15 @@ var Element = /** @class */ (function (_super) {
|
|
352
260
|
* @param [deep=false] "true" to clone deep.
|
353
261
|
* @returns Cloned node.
|
354
262
|
*/
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
var key = _a[_i];
|
360
|
-
var attr = Object.assign(new Attr_1.default(), this._attributes[key]);
|
263
|
+
cloneNode(deep = false) {
|
264
|
+
const clone = super.cloneNode(deep);
|
265
|
+
for (const key of Object.keys(this._attributes)) {
|
266
|
+
const attr = Object.assign(new Attr_1.default(), this._attributes[key]);
|
361
267
|
attr.ownerElement = clone;
|
362
268
|
clone._attributes[key] = attr;
|
363
269
|
}
|
364
270
|
if (deep) {
|
365
|
-
for (
|
366
|
-
var node = _c[_b];
|
271
|
+
for (const node of clone.childNodes) {
|
367
272
|
if (node.nodeType === Node_1.default.ELEMENT_NODE) {
|
368
273
|
clone.children.push(node);
|
369
274
|
}
|
@@ -374,7 +279,7 @@ var Element = /** @class */ (function (_super) {
|
|
374
279
|
clone.scrollTop = this.scrollTop;
|
375
280
|
clone.namespaceURI = this.namespaceURI;
|
376
281
|
return clone;
|
377
|
-
}
|
282
|
+
}
|
378
283
|
/**
|
379
284
|
* Append a child node to childNodes.
|
380
285
|
*
|
@@ -382,12 +287,12 @@ var Element = /** @class */ (function (_super) {
|
|
382
287
|
* @param node Node to append.
|
383
288
|
* @returns Appended node.
|
384
289
|
*/
|
385
|
-
|
290
|
+
appendChild(node) {
|
386
291
|
// If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
|
387
292
|
// See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
388
293
|
if (node.nodeType !== Node_1.default.DOCUMENT_FRAGMENT_NODE) {
|
389
294
|
if (node.parentNode && node.parentNode['children']) {
|
390
|
-
|
295
|
+
const index = node.parentNode['children'].indexOf(node);
|
391
296
|
if (index !== -1) {
|
392
297
|
node.parentNode['children'].splice(index, 1);
|
393
298
|
}
|
@@ -396,29 +301,29 @@ var Element = /** @class */ (function (_super) {
|
|
396
301
|
this.children.push(node);
|
397
302
|
}
|
398
303
|
}
|
399
|
-
return
|
400
|
-
}
|
304
|
+
return super.appendChild(node);
|
305
|
+
}
|
401
306
|
/**
|
402
307
|
* Remove Child element from childNodes array.
|
403
308
|
*
|
404
309
|
* @override
|
405
310
|
* @param node Node to remove.
|
406
311
|
*/
|
407
|
-
|
312
|
+
removeChild(node) {
|
408
313
|
if (node.nodeType === Node_1.default.ELEMENT_NODE) {
|
409
|
-
|
314
|
+
const index = this.children.indexOf(node);
|
410
315
|
if (index !== -1) {
|
411
316
|
this.children.splice(index, 1);
|
412
317
|
}
|
413
318
|
}
|
414
|
-
return
|
415
|
-
}
|
319
|
+
return super.removeChild(node);
|
320
|
+
}
|
416
321
|
/**
|
417
322
|
* Removes the node from its parent.
|
418
323
|
*/
|
419
|
-
|
324
|
+
remove() {
|
420
325
|
ChildNodeUtility_1.default.remove(this);
|
421
|
-
}
|
326
|
+
}
|
422
327
|
/**
|
423
328
|
* Inserts a node before another.
|
424
329
|
*
|
@@ -427,99 +332,74 @@ var Element = /** @class */ (function (_super) {
|
|
427
332
|
* @param [referenceNode] Node to insert before.
|
428
333
|
* @returns Inserted node.
|
429
334
|
*/
|
430
|
-
|
431
|
-
|
335
|
+
insertBefore(newNode, referenceNode) {
|
336
|
+
const returnValue = super.insertBefore(newNode, referenceNode);
|
432
337
|
// If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
|
433
338
|
// See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
434
339
|
if (newNode.nodeType !== Node_1.default.DOCUMENT_FRAGMENT_NODE) {
|
435
340
|
if (newNode.parentNode && newNode.parentNode['children']) {
|
436
|
-
|
341
|
+
const index = newNode.parentNode['children'].indexOf(newNode);
|
437
342
|
if (index !== -1) {
|
438
343
|
newNode.parentNode['children'].splice(index, 1);
|
439
344
|
}
|
440
345
|
}
|
441
346
|
this.children.length = 0;
|
442
|
-
for (
|
443
|
-
var node = _a[_i];
|
347
|
+
for (const node of this.childNodes) {
|
444
348
|
if (node.nodeType === Node_1.default.ELEMENT_NODE) {
|
445
349
|
this.children.push(node);
|
446
350
|
}
|
447
351
|
}
|
448
352
|
}
|
449
353
|
return returnValue;
|
450
|
-
}
|
354
|
+
}
|
451
355
|
/**
|
452
356
|
* The Node.replaceWith() method replaces this Node in the children list of its parent with a set of Node or DOMString objects.
|
453
357
|
*
|
454
358
|
* @param nodes List of Node or DOMString.
|
455
359
|
*/
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
nodes[_i] = arguments[_i];
|
460
|
-
}
|
461
|
-
ChildNodeUtility_1.default.replaceWith.apply(ChildNodeUtility_1.default, __spreadArray([this], nodes, false));
|
462
|
-
};
|
360
|
+
replaceWith(...nodes) {
|
361
|
+
ChildNodeUtility_1.default.replaceWith(this, ...nodes);
|
362
|
+
}
|
463
363
|
/**
|
464
364
|
* Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just before this ChildNode. DOMString objects are inserted as equivalent Text nodes.
|
465
365
|
*
|
466
366
|
* @param nodes List of Node or DOMString.
|
467
367
|
*/
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
nodes[_i] = arguments[_i];
|
472
|
-
}
|
473
|
-
ChildNodeUtility_1.default.before.apply(ChildNodeUtility_1.default, __spreadArray([this], nodes, false));
|
474
|
-
};
|
368
|
+
before(...nodes) {
|
369
|
+
ChildNodeUtility_1.default.before(this, ...nodes);
|
370
|
+
}
|
475
371
|
/**
|
476
372
|
* Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just after this ChildNode. DOMString objects are inserted as equivalent Text nodes.
|
477
373
|
*
|
478
374
|
* @param nodes List of Node or DOMString.
|
479
375
|
*/
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
nodes[_i] = arguments[_i];
|
484
|
-
}
|
485
|
-
ChildNodeUtility_1.default.after.apply(ChildNodeUtility_1.default, __spreadArray([this], nodes, false));
|
486
|
-
};
|
376
|
+
after(...nodes) {
|
377
|
+
ChildNodeUtility_1.default.after(this, ...nodes);
|
378
|
+
}
|
487
379
|
/**
|
488
380
|
* Inserts a set of Node objects or DOMString objects after the last child of the ParentNode. DOMString objects are inserted as equivalent Text nodes.
|
489
381
|
*
|
490
382
|
* @param nodes List of Node or DOMString.
|
491
383
|
*/
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
nodes[_i] = arguments[_i];
|
496
|
-
}
|
497
|
-
ParentNodeUtility_1.default.append.apply(ParentNodeUtility_1.default, __spreadArray([this], nodes, false));
|
498
|
-
};
|
384
|
+
append(...nodes) {
|
385
|
+
ParentNodeUtility_1.default.append(this, ...nodes);
|
386
|
+
}
|
499
387
|
/**
|
500
388
|
* Inserts a set of Node objects or DOMString objects before the first child of the ParentNode. DOMString objects are inserted as equivalent Text nodes.
|
501
389
|
*
|
502
390
|
* @param nodes List of Node or DOMString.
|
503
391
|
*/
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
nodes[_i] = arguments[_i];
|
508
|
-
}
|
509
|
-
ParentNodeUtility_1.default.prepend.apply(ParentNodeUtility_1.default, __spreadArray([this], nodes, false));
|
510
|
-
};
|
392
|
+
prepend(...nodes) {
|
393
|
+
ParentNodeUtility_1.default.prepend(this, ...nodes);
|
394
|
+
}
|
511
395
|
/**
|
512
396
|
* Replaces the existing children of a node with a specified new set of children.
|
513
397
|
*
|
514
398
|
* @param nodes List of Node or DOMString.
|
515
399
|
*/
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
nodes[_i] = arguments[_i];
|
520
|
-
}
|
521
|
-
ParentNodeUtility_1.default.replaceChildren.apply(ParentNodeUtility_1.default, __spreadArray([this], nodes, false));
|
522
|
-
};
|
400
|
+
replaceChildren(...nodes) {
|
401
|
+
ParentNodeUtility_1.default.replaceChildren(this, ...nodes);
|
402
|
+
}
|
523
403
|
/**
|
524
404
|
* Inserts a node to the given position.
|
525
405
|
*
|
@@ -527,7 +407,7 @@ var Element = /** @class */ (function (_super) {
|
|
527
407
|
* @param element Node to insert.
|
528
408
|
* @returns Inserted node or null if couldn't insert.
|
529
409
|
*/
|
530
|
-
|
410
|
+
insertAdjacentElement(position, element) {
|
531
411
|
if (position === 'beforebegin') {
|
532
412
|
if (!this.parentElement) {
|
533
413
|
return null;
|
@@ -547,43 +427,42 @@ var Element = /** @class */ (function (_super) {
|
|
547
427
|
this.parentElement.insertBefore(element, this.nextSibling);
|
548
428
|
}
|
549
429
|
return element;
|
550
|
-
}
|
430
|
+
}
|
551
431
|
/**
|
552
432
|
* Inserts an HTML string to the given position.
|
553
433
|
*
|
554
434
|
* @param position Position to insert text.
|
555
435
|
* @param text HTML string to insert.
|
556
436
|
*/
|
557
|
-
|
558
|
-
for (
|
559
|
-
var node = _a[_i];
|
437
|
+
insertAdjacentHTML(position, text) {
|
438
|
+
for (const node of XMLParser_1.default.parse(this.ownerDocument, text).childNodes.slice()) {
|
560
439
|
this.insertAdjacentElement(position, node);
|
561
440
|
}
|
562
|
-
}
|
441
|
+
}
|
563
442
|
/**
|
564
443
|
* Inserts text to the given position.
|
565
444
|
*
|
566
445
|
* @param position Position to insert text.
|
567
446
|
* @param text String to insert.
|
568
447
|
*/
|
569
|
-
|
448
|
+
insertAdjacentText(position, text) {
|
570
449
|
if (!text) {
|
571
450
|
return;
|
572
451
|
}
|
573
|
-
|
452
|
+
const textNode = this.ownerDocument.createTextNode(text);
|
574
453
|
this.insertAdjacentElement(position, textNode);
|
575
|
-
}
|
454
|
+
}
|
576
455
|
/**
|
577
456
|
* Sets an attribute.
|
578
457
|
*
|
579
458
|
* @param name Name.
|
580
459
|
* @param value Value.
|
581
460
|
*/
|
582
|
-
|
583
|
-
|
461
|
+
setAttribute(name, value) {
|
462
|
+
const attribute = this.ownerDocument.createAttributeNS(null, name);
|
584
463
|
attribute.value = String(value);
|
585
464
|
this.setAttributeNode(attribute);
|
586
|
-
}
|
465
|
+
}
|
587
466
|
/**
|
588
467
|
* Sets a namespace attribute.
|
589
468
|
*
|
@@ -591,53 +470,53 @@ var Element = /** @class */ (function (_super) {
|
|
591
470
|
* @param name Name.
|
592
471
|
* @param value Value.
|
593
472
|
*/
|
594
|
-
|
595
|
-
|
473
|
+
setAttributeNS(namespaceURI, name, value) {
|
474
|
+
const attribute = this.ownerDocument.createAttributeNS(namespaceURI, name);
|
596
475
|
attribute.value = String(value);
|
597
476
|
this.setAttributeNode(attribute);
|
598
|
-
}
|
477
|
+
}
|
599
478
|
/**
|
600
479
|
* Returns attribute names.
|
601
480
|
*
|
602
481
|
* @returns Attribute names.
|
603
482
|
*/
|
604
|
-
|
483
|
+
getAttributeNames() {
|
605
484
|
return Object.keys(this._attributes);
|
606
|
-
}
|
485
|
+
}
|
607
486
|
/**
|
608
487
|
* Returns attribute value.
|
609
488
|
*
|
610
489
|
* @param name Name.
|
611
490
|
*/
|
612
|
-
|
613
|
-
|
491
|
+
getAttribute(name) {
|
492
|
+
const attribute = this.getAttributeNode(name);
|
614
493
|
if (attribute) {
|
615
494
|
return attribute.value;
|
616
495
|
}
|
617
496
|
return null;
|
618
|
-
}
|
497
|
+
}
|
619
498
|
/**
|
620
499
|
* Returns namespace attribute value.
|
621
500
|
*
|
622
501
|
* @param namespace Namespace URI.
|
623
502
|
* @param localName Local name.
|
624
503
|
*/
|
625
|
-
|
626
|
-
|
504
|
+
getAttributeNS(namespace, localName) {
|
505
|
+
const attribute = this.getAttributeNodeNS(namespace, localName);
|
627
506
|
if (attribute) {
|
628
507
|
return attribute.value;
|
629
508
|
}
|
630
509
|
return null;
|
631
|
-
}
|
510
|
+
}
|
632
511
|
/**
|
633
512
|
* Returns a boolean value indicating whether the specified element has the attribute or not.
|
634
513
|
*
|
635
514
|
* @param name Attribute name.
|
636
515
|
* @returns True if attribute exists, false otherwise.
|
637
516
|
*/
|
638
|
-
|
517
|
+
hasAttribute(name) {
|
639
518
|
return !!this.getAttributeNode(name);
|
640
|
-
}
|
519
|
+
}
|
641
520
|
/**
|
642
521
|
* Returns a boolean value indicating whether the specified element has the namespace attribute or not.
|
643
522
|
*
|
@@ -645,50 +524,48 @@ var Element = /** @class */ (function (_super) {
|
|
645
524
|
* @param localName Local name.
|
646
525
|
* @returns True if attribute exists, false otherwise.
|
647
526
|
*/
|
648
|
-
|
649
|
-
for (
|
650
|
-
|
651
|
-
var attribute = this._attributes[name];
|
527
|
+
hasAttributeNS(namespace, localName) {
|
528
|
+
for (const name of Object.keys(this._attributes)) {
|
529
|
+
const attribute = this._attributes[name];
|
652
530
|
if (attribute.namespaceURI === namespace && attribute.localName === localName) {
|
653
531
|
return true;
|
654
532
|
}
|
655
533
|
}
|
656
534
|
return false;
|
657
|
-
}
|
535
|
+
}
|
658
536
|
/**
|
659
537
|
* Returns "true" if the element has attributes.
|
660
538
|
*
|
661
539
|
* @returns "true" if the element has attributes.
|
662
540
|
*/
|
663
|
-
|
541
|
+
hasAttributes() {
|
664
542
|
return Object.keys(this._attributes).length > 0;
|
665
|
-
}
|
543
|
+
}
|
666
544
|
/**
|
667
545
|
* Removes an attribute.
|
668
546
|
*
|
669
547
|
* @param name Name.
|
670
548
|
*/
|
671
|
-
|
672
|
-
|
549
|
+
removeAttribute(name) {
|
550
|
+
const attribute = this._attributes[this._getAttributeName(name)];
|
673
551
|
if (attribute) {
|
674
552
|
this.removeAttributeNode(attribute);
|
675
553
|
}
|
676
|
-
}
|
554
|
+
}
|
677
555
|
/**
|
678
556
|
* Removes a namespace attribute.
|
679
557
|
*
|
680
558
|
* @param namespace Namespace URI.
|
681
559
|
* @param localName Local name.
|
682
560
|
*/
|
683
|
-
|
684
|
-
for (
|
685
|
-
|
686
|
-
var attribute = this._attributes[name];
|
561
|
+
removeAttributeNS(namespace, localName) {
|
562
|
+
for (const name of Object.keys(this._attributes)) {
|
563
|
+
const attribute = this._attributes[name];
|
687
564
|
if (attribute.namespaceURI === namespace && attribute.localName === localName) {
|
688
565
|
this.removeAttribute(attribute.name);
|
689
566
|
}
|
690
567
|
}
|
691
|
-
}
|
568
|
+
}
|
692
569
|
/**
|
693
570
|
* Attaches a shadow root.
|
694
571
|
*
|
@@ -697,7 +574,7 @@ var Element = /** @class */ (function (_super) {
|
|
697
574
|
* @param shadowRootInit.mode
|
698
575
|
* @returns Shadow root.
|
699
576
|
*/
|
700
|
-
|
577
|
+
attachShadow(shadowRootInit) {
|
701
578
|
if (this._shadowRoot) {
|
702
579
|
throw new DOMException_1.default('Shadow root has already been attached.');
|
703
580
|
}
|
@@ -710,63 +587,62 @@ var Element = /** @class */ (function (_super) {
|
|
710
587
|
this.shadowRoot = this._shadowRoot;
|
711
588
|
}
|
712
589
|
return this._shadowRoot;
|
713
|
-
}
|
590
|
+
}
|
714
591
|
/**
|
715
592
|
* Converts to string.
|
716
593
|
*
|
717
594
|
* @returns String.
|
718
595
|
*/
|
719
|
-
|
596
|
+
toString() {
|
720
597
|
return this.outerHTML;
|
721
|
-
}
|
598
|
+
}
|
722
599
|
/**
|
723
600
|
* Returns the size of an element and its position relative to the viewport.
|
724
601
|
*
|
725
602
|
* @returns DOM rect.
|
726
603
|
*/
|
727
|
-
|
604
|
+
getBoundingClientRect() {
|
728
605
|
return new DOMRect_1.default();
|
729
|
-
}
|
606
|
+
}
|
730
607
|
/**
|
731
608
|
* Returns a range.
|
732
609
|
*
|
733
610
|
* @returns Range.
|
734
611
|
*/
|
735
|
-
|
612
|
+
createTextRange() {
|
736
613
|
return new Range_1.default();
|
737
|
-
}
|
614
|
+
}
|
738
615
|
/**
|
739
616
|
* The matches() method checks to see if the Element would be selected by the provided selectorString.
|
740
617
|
*
|
741
618
|
* @param selector Selector.
|
742
619
|
* @returns "true" if matching.
|
743
620
|
*/
|
744
|
-
|
745
|
-
for (
|
746
|
-
var part = _a[_i];
|
621
|
+
matches(selector) {
|
622
|
+
for (const part of selector.split(',')) {
|
747
623
|
if (new SelectorItem_1.default(part.trim()).match(this)) {
|
748
624
|
return true;
|
749
625
|
}
|
750
626
|
}
|
751
627
|
return false;
|
752
|
-
}
|
628
|
+
}
|
753
629
|
/**
|
754
630
|
* Traverses the Element and its parents (heading toward the document root) until it finds a node that matches the provided selector string.
|
755
631
|
*
|
756
632
|
* @param selector Selector.
|
757
633
|
* @returns Closest matching element.
|
758
634
|
*/
|
759
|
-
|
760
|
-
|
635
|
+
closest(selector) {
|
636
|
+
let rootElement = this.ownerDocument.documentElement;
|
761
637
|
if (!this.isConnected) {
|
762
638
|
rootElement = this;
|
763
639
|
while (rootElement.parentNode) {
|
764
640
|
rootElement = rootElement.parentNode;
|
765
641
|
}
|
766
642
|
}
|
767
|
-
|
643
|
+
const elements = rootElement.querySelectorAll(selector);
|
768
644
|
// eslint-disable-next-line
|
769
|
-
|
645
|
+
let parent = this;
|
770
646
|
while (parent) {
|
771
647
|
if (elements.includes(parent)) {
|
772
648
|
return parent;
|
@@ -779,43 +655,43 @@ var Element = /** @class */ (function (_super) {
|
|
779
655
|
return rootElement;
|
780
656
|
}
|
781
657
|
return null;
|
782
|
-
}
|
658
|
+
}
|
783
659
|
/**
|
784
660
|
* Query CSS selector to find matching nodes.
|
785
661
|
*
|
786
662
|
* @param selector CSS selector.
|
787
663
|
* @returns Matching elements.
|
788
664
|
*/
|
789
|
-
|
665
|
+
querySelectorAll(selector) {
|
790
666
|
return QuerySelector_1.default.querySelectorAll(this, selector);
|
791
|
-
}
|
667
|
+
}
|
792
668
|
/**
|
793
669
|
* Query CSS Selector to find matching node.
|
794
670
|
*
|
795
671
|
* @param selector CSS selector.
|
796
672
|
* @returns Matching element.
|
797
673
|
*/
|
798
|
-
|
674
|
+
querySelector(selector) {
|
799
675
|
return QuerySelector_1.default.querySelector(this, selector);
|
800
|
-
}
|
676
|
+
}
|
801
677
|
/**
|
802
678
|
* Returns an elements by class name.
|
803
679
|
*
|
804
680
|
* @param className Tag name.
|
805
681
|
* @returns Matching element.
|
806
682
|
*/
|
807
|
-
|
683
|
+
getElementsByClassName(className) {
|
808
684
|
return ParentNodeUtility_1.default.getElementsByClassName(this, className);
|
809
|
-
}
|
685
|
+
}
|
810
686
|
/**
|
811
687
|
* Returns an elements by tag name.
|
812
688
|
*
|
813
689
|
* @param tagName Tag name.
|
814
690
|
* @returns Matching element.
|
815
691
|
*/
|
816
|
-
|
692
|
+
getElementsByTagName(tagName) {
|
817
693
|
return ParentNodeUtility_1.default.getElementsByTagName(this, tagName);
|
818
|
-
}
|
694
|
+
}
|
819
695
|
/**
|
820
696
|
* Returns an elements by tag name and namespace.
|
821
697
|
*
|
@@ -823,19 +699,19 @@ var Element = /** @class */ (function (_super) {
|
|
823
699
|
* @param tagName Tag name.
|
824
700
|
* @returns Matching element.
|
825
701
|
*/
|
826
|
-
|
702
|
+
getElementsByTagNameNS(namespaceURI, tagName) {
|
827
703
|
return ParentNodeUtility_1.default.getElementsByTagNameNS(this, namespaceURI, tagName);
|
828
|
-
}
|
704
|
+
}
|
829
705
|
/**
|
830
706
|
* The setAttributeNode() method adds a new Attr node to the specified element.
|
831
707
|
*
|
832
708
|
* @param attribute Attribute.
|
833
709
|
* @returns Replaced attribute.
|
834
710
|
*/
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
711
|
+
setAttributeNode(attribute) {
|
712
|
+
const name = this._getAttributeName(attribute.name);
|
713
|
+
const replacedAttribute = this._attributes[name];
|
714
|
+
const oldValue = replacedAttribute ? replacedAttribute.value : null;
|
839
715
|
attribute.name = name;
|
840
716
|
attribute.ownerElement = this;
|
841
717
|
attribute.ownerDocument = this.ownerDocument;
|
@@ -848,11 +724,10 @@ var Element = /** @class */ (function (_super) {
|
|
848
724
|
}
|
849
725
|
// MutationObserver
|
850
726
|
if (this._observers.length > 0) {
|
851
|
-
for (
|
852
|
-
var observer = _a[_i];
|
727
|
+
for (const observer of this._observers) {
|
853
728
|
if (observer.options.attributes &&
|
854
729
|
(!observer.options.attributeFilter || observer.options.attributeFilter.includes(name))) {
|
855
|
-
|
730
|
+
const record = new MutationRecord_1.default();
|
856
731
|
record.target = this;
|
857
732
|
record.type = MutationTypeEnum_1.default.attributes;
|
858
733
|
record.attributeName = name;
|
@@ -862,25 +737,25 @@ var Element = /** @class */ (function (_super) {
|
|
862
737
|
}
|
863
738
|
}
|
864
739
|
return replacedAttribute || null;
|
865
|
-
}
|
740
|
+
}
|
866
741
|
/**
|
867
742
|
* The setAttributeNodeNS() method adds a new Attr node to the specified element.
|
868
743
|
*
|
869
744
|
* @param attribute Attribute.
|
870
745
|
* @returns Replaced attribute.
|
871
746
|
*/
|
872
|
-
|
747
|
+
setAttributeNodeNS(attribute) {
|
873
748
|
return this.setAttributeNode(attribute);
|
874
|
-
}
|
749
|
+
}
|
875
750
|
/**
|
876
751
|
* Returns an Attr node.
|
877
752
|
*
|
878
753
|
* @param name Name.
|
879
754
|
* @returns Replaced attribute.
|
880
755
|
*/
|
881
|
-
|
756
|
+
getAttributeNode(name) {
|
882
757
|
return this._attributes[this._getAttributeName(name)] || null;
|
883
|
-
}
|
758
|
+
}
|
884
759
|
/**
|
885
760
|
* Returns a namespaced Attr node.
|
886
761
|
*
|
@@ -888,28 +763,27 @@ var Element = /** @class */ (function (_super) {
|
|
888
763
|
* @param name Name.
|
889
764
|
* @returns Replaced attribute.
|
890
765
|
*/
|
891
|
-
|
892
|
-
|
766
|
+
getAttributeNodeNS(namespace, name) {
|
767
|
+
const attributeName = this._getAttributeName(name);
|
893
768
|
if (this._attributes[attributeName] &&
|
894
769
|
this._attributes[attributeName].namespaceURI === namespace &&
|
895
770
|
this._attributes[attributeName].localName === attributeName) {
|
896
771
|
return this._attributes[attributeName];
|
897
772
|
}
|
898
|
-
for (
|
899
|
-
|
900
|
-
var attribute = this._attributes[name_1];
|
773
|
+
for (const name of Object.keys(this._attributes)) {
|
774
|
+
const attribute = this._attributes[name];
|
901
775
|
if (attribute.namespaceURI === namespace && attribute.localName === attributeName) {
|
902
776
|
return attribute;
|
903
777
|
}
|
904
778
|
}
|
905
779
|
return null;
|
906
|
-
}
|
780
|
+
}
|
907
781
|
/**
|
908
782
|
* Removes an Attr node.
|
909
783
|
*
|
910
784
|
* @param attribute Attribute.
|
911
785
|
*/
|
912
|
-
|
786
|
+
removeAttributeNode(attribute) {
|
913
787
|
delete this._attributes[attribute.name];
|
914
788
|
this._updateDomListIndices();
|
915
789
|
if (this.attributeChangedCallback &&
|
@@ -919,12 +793,11 @@ var Element = /** @class */ (function (_super) {
|
|
919
793
|
}
|
920
794
|
// MutationObserver
|
921
795
|
if (this._observers.length > 0) {
|
922
|
-
for (
|
923
|
-
var observer = _a[_i];
|
796
|
+
for (const observer of this._observers) {
|
924
797
|
if (observer.options.attributes &&
|
925
798
|
(!observer.options.attributeFilter ||
|
926
799
|
observer.options.attributeFilter.includes(attribute.name))) {
|
927
|
-
|
800
|
+
const record = new MutationRecord_1.default();
|
928
801
|
record.target = this;
|
929
802
|
record.type = MutationTypeEnum_1.default.attributes;
|
930
803
|
record.attributeName = attribute.name;
|
@@ -933,31 +806,30 @@ var Element = /** @class */ (function (_super) {
|
|
933
806
|
}
|
934
807
|
}
|
935
808
|
}
|
936
|
-
}
|
809
|
+
}
|
937
810
|
/**
|
938
811
|
* Removes an Attr node.
|
939
812
|
*
|
940
813
|
* @param attribute Attribute.
|
941
814
|
*/
|
942
|
-
|
815
|
+
removeAttributeNodeNS(attribute) {
|
943
816
|
this.removeAttributeNode(attribute);
|
944
|
-
}
|
817
|
+
}
|
945
818
|
/**
|
946
819
|
* Scrolls to a particular set of coordinates.
|
947
820
|
*
|
948
821
|
* @param x X position or options object.
|
949
822
|
* @param y Y position.
|
950
823
|
*/
|
951
|
-
|
952
|
-
var _this = this;
|
824
|
+
scroll(x, y) {
|
953
825
|
if (typeof x === 'object') {
|
954
826
|
if (x.behavior === 'smooth') {
|
955
|
-
this.ownerDocument.defaultView.setTimeout(
|
827
|
+
this.ownerDocument.defaultView.setTimeout(() => {
|
956
828
|
if (x.top !== undefined) {
|
957
|
-
|
829
|
+
this.scrollTop = x.top;
|
958
830
|
}
|
959
831
|
if (x.left !== undefined) {
|
960
|
-
|
832
|
+
this.scrollLeft = x.left;
|
961
833
|
}
|
962
834
|
});
|
963
835
|
}
|
@@ -974,37 +846,36 @@ var Element = /** @class */ (function (_super) {
|
|
974
846
|
this.scrollLeft = x;
|
975
847
|
this.scrollTop = y;
|
976
848
|
}
|
977
|
-
}
|
849
|
+
}
|
978
850
|
/**
|
979
851
|
* Scrolls to a particular set of coordinates.
|
980
852
|
*
|
981
853
|
* @param x X position or options object.
|
982
854
|
* @param y Y position.
|
983
855
|
*/
|
984
|
-
|
856
|
+
scrollTo(x, y) {
|
985
857
|
this.scroll(x, y);
|
986
|
-
}
|
858
|
+
}
|
987
859
|
/**
|
988
860
|
* Returns attribute name.
|
989
861
|
*
|
990
862
|
* @param name Name.
|
991
863
|
* @returns Attribute name based on namespace.
|
992
864
|
*/
|
993
|
-
|
865
|
+
_getAttributeName(name) {
|
994
866
|
if (this.namespaceURI === NamespaceURI_1.default.svg) {
|
995
867
|
return name;
|
996
868
|
}
|
997
869
|
return name.toLowerCase();
|
998
|
-
}
|
870
|
+
}
|
999
871
|
/**
|
1000
872
|
* Updates DOM list indices.
|
1001
873
|
*/
|
1002
|
-
|
874
|
+
_updateDomListIndices() {
|
1003
875
|
if (this._classList) {
|
1004
876
|
this._classList._updateIndices();
|
1005
877
|
}
|
1006
|
-
}
|
1007
|
-
|
1008
|
-
}(Node_1.default));
|
878
|
+
}
|
879
|
+
}
|
1009
880
|
exports.default = Element;
|
1010
881
|
//# sourceMappingURL=Element.js.map
|