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.

Files changed (284) hide show
  1. package/README.md +26 -6
  2. package/lib/async-task-manager/AsyncTaskManager.js +34 -78
  3. package/lib/async-task-manager/AsyncTaskManager.js.map +1 -1
  4. package/lib/attribute/Attr.js +19 -28
  5. package/lib/attribute/Attr.js.map +1 -1
  6. package/lib/config/ElementTag.js +15 -15
  7. package/lib/config/ElementTag.js.map +1 -1
  8. package/lib/cookie/CookieUtility.js +21 -26
  9. package/lib/cookie/CookieUtility.js.map +1 -1
  10. package/lib/css/CSS.js +12 -18
  11. package/lib/css/CSS.js.map +1 -1
  12. package/lib/css/CSSParser.js +29 -33
  13. package/lib/css/CSSParser.js.map +1 -1
  14. package/lib/css/CSSRule.js +24 -29
  15. package/lib/css/CSSRule.js.map +1 -1
  16. package/lib/css/CSSStyleDeclaration.js +4516 -6005
  17. package/lib/css/CSSStyleDeclaration.js.map +1 -1
  18. package/lib/css/CSSStyleSheet.js +17 -59
  19. package/lib/css/CSSStyleSheet.js.map +1 -1
  20. package/lib/css/CSSUnitValue.js +4 -5
  21. package/lib/css/CSSUnitValue.js.map +1 -1
  22. package/lib/css/MediaList.js +23 -28
  23. package/lib/css/MediaList.js.map +1 -1
  24. package/lib/css/rules/CSSFontFaceRule.js +6 -24
  25. package/lib/css/rules/CSSFontFaceRule.js.map +1 -1
  26. package/lib/css/rules/CSSKeyframeRule.js +14 -36
  27. package/lib/css/rules/CSSKeyframeRule.js.map +1 -1
  28. package/lib/css/rules/CSSKeyframesRule.js +31 -54
  29. package/lib/css/rules/CSSKeyframesRule.js.map +1 -1
  30. package/lib/css/rules/CSSMediaRule.js +29 -56
  31. package/lib/css/rules/CSSMediaRule.js.map +1 -1
  32. package/lib/css/rules/CSSStyleRule.js +16 -38
  33. package/lib/css/rules/CSSStyleRule.js.map +1 -1
  34. package/lib/custom-element/CustomElementRegistry.js +21 -24
  35. package/lib/custom-element/CustomElementRegistry.js.map +1 -1
  36. package/lib/dom-implementation/DOMImplementation.js +12 -13
  37. package/lib/dom-implementation/DOMImplementation.js.map +1 -1
  38. package/lib/dom-parser/DOMParser.js +29 -35
  39. package/lib/dom-parser/DOMParser.js.map +1 -1
  40. package/lib/dom-token-list/DOMTokenList.js +64 -79
  41. package/lib/dom-token-list/DOMTokenList.js.map +1 -1
  42. package/lib/event/DataTransfer.js +4 -5
  43. package/lib/event/DataTransfer.js.map +1 -1
  44. package/lib/event/DataTransferItem.js +7 -8
  45. package/lib/event/DataTransferItem.js.map +1 -1
  46. package/lib/event/DataTransferItemList.js +10 -11
  47. package/lib/event/DataTransferItemList.js.map +1 -1
  48. package/lib/event/Event.js +11 -15
  49. package/lib/event/Event.js.map +1 -1
  50. package/lib/event/EventTarget.js +14 -16
  51. package/lib/event/EventTarget.js.map +1 -1
  52. package/lib/event/IUIEventInit.d.ts +2 -2
  53. package/lib/event/UIEvent.d.ts +2 -2
  54. package/lib/event/UIEvent.js +25 -46
  55. package/lib/event/UIEvent.js.map +1 -1
  56. package/lib/event/events/AnimationEvent.js +11 -29
  57. package/lib/event/events/AnimationEvent.js.map +1 -1
  58. package/lib/event/events/CustomEvent.js +9 -31
  59. package/lib/event/events/CustomEvent.js.map +1 -1
  60. package/lib/event/events/ErrorEvent.js +15 -34
  61. package/lib/event/events/ErrorEvent.js.map +1 -1
  62. package/lib/event/events/FocusEvent.js +7 -26
  63. package/lib/event/events/FocusEvent.js.map +1 -1
  64. package/lib/event/events/InputEvent.js +13 -32
  65. package/lib/event/events/InputEvent.js.map +1 -1
  66. package/lib/event/events/KeyboardEvent.js +27 -46
  67. package/lib/event/events/KeyboardEvent.js.map +1 -1
  68. package/lib/event/events/MouseEvent.js +33 -52
  69. package/lib/event/events/MouseEvent.js.map +1 -1
  70. package/lib/event/events/PointerEvent.js +25 -44
  71. package/lib/event/events/PointerEvent.js.map +1 -1
  72. package/lib/event/events/ProgressEvent.js +11 -30
  73. package/lib/event/events/ProgressEvent.js.map +1 -1
  74. package/lib/event/events/StorageEvent.js +13 -32
  75. package/lib/event/events/StorageEvent.js.map +1 -1
  76. package/lib/event/events/WheelEvent.js +16 -35
  77. package/lib/event/events/WheelEvent.js.map +1 -1
  78. package/lib/exception/DOMException.js +5 -24
  79. package/lib/exception/DOMException.js.map +1 -1
  80. package/lib/fetch/FetchHandler.js +18 -22
  81. package/lib/fetch/FetchHandler.js.map +1 -1
  82. package/lib/fetch/Headers.js +3 -23
  83. package/lib/fetch/Headers.js.map +1 -1
  84. package/lib/fetch/Request.js +61 -81
  85. package/lib/fetch/Request.js.map +1 -1
  86. package/lib/fetch/ResourceFetchHandler.js +18 -67
  87. package/lib/fetch/ResourceFetchHandler.js.map +1 -1
  88. package/lib/fetch/Response.js +61 -81
  89. package/lib/fetch/Response.js.map +1 -1
  90. package/lib/file/Blob.js +29 -78
  91. package/lib/file/Blob.js.map +1 -1
  92. package/lib/file/File.js +9 -27
  93. package/lib/file/File.js.map +1 -1
  94. package/lib/file/FileReader.js +57 -78
  95. package/lib/file/FileReader.js.map +1 -1
  96. package/lib/history/History.js +32 -37
  97. package/lib/history/History.js.map +1 -1
  98. package/lib/index.d.ts +3 -3
  99. package/lib/index.js +69 -69
  100. package/lib/index.js.map +1 -1
  101. package/lib/location/Location.js +11 -28
  102. package/lib/location/Location.js.map +1 -1
  103. package/lib/location/RelativeURL.js +5 -8
  104. package/lib/location/RelativeURL.js.map +1 -1
  105. package/lib/location/URL.js +46 -59
  106. package/lib/location/URL.js.map +1 -1
  107. package/lib/match-media/MediaQueryList.js +28 -54
  108. package/lib/match-media/MediaQueryList.js.map +1 -1
  109. package/lib/mutation-observer/MutationListener.js +3 -4
  110. package/lib/mutation-observer/MutationListener.js.map +1 -1
  111. package/lib/mutation-observer/MutationObserver.js +12 -13
  112. package/lib/mutation-observer/MutationObserver.js.map +1 -1
  113. package/lib/mutation-observer/MutationRecord.js +3 -4
  114. package/lib/mutation-observer/MutationRecord.js.map +1 -1
  115. package/lib/navigator/MimeType.js +5 -6
  116. package/lib/navigator/MimeType.js.map +1 -1
  117. package/lib/navigator/MimeTypeArray.js +10 -11
  118. package/lib/navigator/MimeTypeArray.js.map +1 -1
  119. package/lib/navigator/Navigator.js +7 -8
  120. package/lib/navigator/Navigator.js.map +1 -1
  121. package/lib/navigator/Plugin.js +10 -11
  122. package/lib/navigator/Plugin.js.map +1 -1
  123. package/lib/navigator/PluginArray.js +12 -13
  124. package/lib/navigator/PluginArray.js.map +1 -1
  125. package/lib/nodes/character-data/CharacterData.js +119 -184
  126. package/lib/nodes/character-data/CharacterData.js.map +1 -1
  127. package/lib/nodes/character-data/CharacterDataUtility.js +12 -15
  128. package/lib/nodes/character-data/CharacterDataUtility.js.map +1 -1
  129. package/lib/nodes/child-node/ChildNodeUtility.js +24 -45
  130. package/lib/nodes/child-node/ChildNodeUtility.js.map +1 -1
  131. package/lib/nodes/child-node/NonDocumentChildNodeUtility.js +9 -12
  132. package/lib/nodes/child-node/NonDocumentChildNodeUtility.js.map +1 -1
  133. package/lib/nodes/comment/Comment.js +20 -43
  134. package/lib/nodes/comment/Comment.js.map +1 -1
  135. package/lib/nodes/document/Document.d.ts +3 -3
  136. package/lib/nodes/document/Document.js +334 -461
  137. package/lib/nodes/document/Document.js.map +1 -1
  138. package/lib/nodes/document/DocumentReadyStateManager.js +16 -19
  139. package/lib/nodes/document/DocumentReadyStateManager.js.map +1 -1
  140. package/lib/nodes/document/IDocument.d.ts +2 -2
  141. package/lib/nodes/document-fragment/DocumentFragment.js +93 -153
  142. package/lib/nodes/document-fragment/DocumentFragment.js.map +1 -1
  143. package/lib/nodes/document-type/DocumentType.js +22 -45
  144. package/lib/nodes/document-type/DocumentType.js.map +1 -1
  145. package/lib/nodes/element/DOMRect.js +3 -4
  146. package/lib/nodes/element/DOMRect.js.map +1 -1
  147. package/lib/nodes/element/Element.js +367 -496
  148. package/lib/nodes/element/Element.js.map +1 -1
  149. package/lib/nodes/element/HTMLCollection.js +4 -24
  150. package/lib/nodes/element/HTMLCollection.js.map +1 -1
  151. package/lib/nodes/element/HTMLCollectionFactory.js +6 -9
  152. package/lib/nodes/element/HTMLCollectionFactory.js.map +1 -1
  153. package/lib/nodes/element/Range.js +89 -114
  154. package/lib/nodes/element/Range.js.map +1 -1
  155. package/lib/nodes/html-base-element/HTMLBaseElement.js +41 -70
  156. package/lib/nodes/html-base-element/HTMLBaseElement.js.map +1 -1
  157. package/lib/nodes/html-document/HTMLDocument.js +3 -23
  158. package/lib/nodes/html-document/HTMLDocument.js.map +1 -1
  159. package/lib/nodes/html-element/DatasetUtility.js +9 -12
  160. package/lib/nodes/html-element/DatasetUtility.js.map +1 -1
  161. package/lib/nodes/html-element/HTMLElement.js +232 -290
  162. package/lib/nodes/html-element/HTMLElement.js.map +1 -1
  163. package/lib/nodes/html-form-element/HTMLFormElement.js +170 -235
  164. package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
  165. package/lib/nodes/html-image-element/HTMLImageElement.js +178 -237
  166. package/lib/nodes/html-image-element/HTMLImageElement.js.map +1 -1
  167. package/lib/nodes/html-image-element/Image.js +7 -27
  168. package/lib/nodes/html-image-element/Image.js.map +1 -1
  169. package/lib/nodes/html-input-element/HTMLInputElement.js +705 -872
  170. package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
  171. package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js +9 -12
  172. package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js.map +1 -1
  173. package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js +5 -8
  174. package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js.map +1 -1
  175. package/lib/nodes/html-input-element/ValidityState.js +47 -69
  176. package/lib/nodes/html-input-element/ValidityState.js.map +1 -1
  177. package/lib/nodes/html-label-element/HTMLLabelElement.js +53 -87
  178. package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -1
  179. package/lib/nodes/html-link-element/HTMLLinkElement.js +197 -252
  180. package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
  181. package/lib/nodes/html-meta-element/HTMLMetaElement.js +66 -102
  182. package/lib/nodes/html-meta-element/HTMLMetaElement.js.map +1 -1
  183. package/lib/nodes/html-script-element/HTMLScriptElement.js +145 -193
  184. package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
  185. package/lib/nodes/html-script-element/ScriptUtility.js +58 -112
  186. package/lib/nodes/html-script-element/ScriptUtility.js.map +1 -1
  187. package/lib/nodes/html-slot-element/HTMLSlotElement.js +33 -65
  188. package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -1
  189. package/lib/nodes/html-style-element/HTMLStyleElement.js +75 -109
  190. package/lib/nodes/html-style-element/HTMLStyleElement.js.map +1 -1
  191. package/lib/nodes/html-template-element/HTMLTemplateElement.js +60 -99
  192. package/lib/nodes/html-template-element/HTMLTemplateElement.js.map +1 -1
  193. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +349 -444
  194. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
  195. package/lib/nodes/html-unknown-element/HTMLUnknownElement.js +17 -37
  196. package/lib/nodes/html-unknown-element/HTMLUnknownElement.js.map +1 -1
  197. package/lib/nodes/node/Node.js +193 -260
  198. package/lib/nodes/node/Node.js.map +1 -1
  199. package/lib/nodes/node/NodeList.js +4 -24
  200. package/lib/nodes/node/NodeList.js.map +1 -1
  201. package/lib/nodes/node/NodeListFactory.js +6 -9
  202. package/lib/nodes/node/NodeListFactory.js.map +1 -1
  203. package/lib/nodes/parent-node/ParentNodeUtility.js +43 -78
  204. package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
  205. package/lib/nodes/shadow-root/ShadowRoot.js +53 -83
  206. package/lib/nodes/shadow-root/ShadowRoot.js.map +1 -1
  207. package/lib/nodes/svg-document/SVGDocument.js +3 -23
  208. package/lib/nodes/svg-document/SVGDocument.js.map +1 -1
  209. package/lib/nodes/svg-element/DOMMatrix.js +3 -4
  210. package/lib/nodes/svg-element/DOMMatrix.js.map +1 -1
  211. package/lib/nodes/svg-element/SVGAngle.js +10 -11
  212. package/lib/nodes/svg-element/SVGAngle.js.map +1 -1
  213. package/lib/nodes/svg-element/SVGAnimatedRect.js +4 -5
  214. package/lib/nodes/svg-element/SVGAnimatedRect.js.map +1 -1
  215. package/lib/nodes/svg-element/SVGElement.js +58 -93
  216. package/lib/nodes/svg-element/SVGElement.js.map +1 -1
  217. package/lib/nodes/svg-element/SVGGraphicsElement.js +14 -32
  218. package/lib/nodes/svg-element/SVGGraphicsElement.js.map +1 -1
  219. package/lib/nodes/svg-element/SVGLength.js +16 -17
  220. package/lib/nodes/svg-element/SVGLength.js.map +1 -1
  221. package/lib/nodes/svg-element/SVGNumber.js +3 -4
  222. package/lib/nodes/svg-element/SVGNumber.js.map +1 -1
  223. package/lib/nodes/svg-element/SVGPoint.js +3 -4
  224. package/lib/nodes/svg-element/SVGPoint.js.map +1 -1
  225. package/lib/nodes/svg-element/SVGRect.js +3 -4
  226. package/lib/nodes/svg-element/SVGRect.js.map +1 -1
  227. package/lib/nodes/svg-element/SVGSVGElement.js +187 -248
  228. package/lib/nodes/svg-element/SVGSVGElement.js.map +1 -1
  229. package/lib/nodes/svg-element/SVGTransform.js +16 -17
  230. package/lib/nodes/svg-element/SVGTransform.js.map +1 -1
  231. package/lib/nodes/text/Text.js +20 -43
  232. package/lib/nodes/text/Text.js.map +1 -1
  233. package/lib/nodes/xml-document/XMLDocument.js +3 -23
  234. package/lib/nodes/xml-document/XMLDocument.js.map +1 -1
  235. package/lib/query-selector/QuerySelector.js +36 -44
  236. package/lib/query-selector/QuerySelector.js.map +1 -1
  237. package/lib/query-selector/SelectorItem.js +62 -66
  238. package/lib/query-selector/SelectorItem.js.map +1 -1
  239. package/lib/resize-observer/ResizeObserver.js +8 -11
  240. package/lib/resize-observer/ResizeObserver.js.map +1 -1
  241. package/lib/screen/Screen.js +3 -4
  242. package/lib/screen/Screen.js.map +1 -1
  243. package/lib/selection/Selection.js +29 -30
  244. package/lib/selection/Selection.js.map +1 -1
  245. package/lib/storage/Storage.js +22 -27
  246. package/lib/storage/Storage.js.map +1 -1
  247. package/lib/tree-walker/NodeFilterMask.js +1 -1
  248. package/lib/tree-walker/NodeFilterMask.js.map +1 -1
  249. package/lib/tree-walker/TreeWalker.js +30 -33
  250. package/lib/tree-walker/TreeWalker.js.map +1 -1
  251. package/lib/window/GlobalWindow.d.ts +90 -0
  252. package/lib/window/GlobalWindow.js +98 -0
  253. package/lib/window/GlobalWindow.js.map +1 -0
  254. package/lib/window/IWindow.d.ts +35 -18
  255. package/lib/window/VMGlobalPropertyScript.d.ts +2 -0
  256. package/lib/window/VMGlobalPropertyScript.js +65 -0
  257. package/lib/window/VMGlobalPropertyScript.js.map +1 -0
  258. package/lib/window/Window.d.ts +84 -105
  259. package/lib/window/Window.js +286 -490
  260. package/lib/window/Window.js.map +1 -1
  261. package/lib/xml-parser/XMLParser.js +65 -71
  262. package/lib/xml-parser/XMLParser.js.map +1 -1
  263. package/lib/xml-serializer/XMLSerializer.js +30 -37
  264. package/lib/xml-serializer/XMLSerializer.js.map +1 -1
  265. package/package.json +6 -7
  266. package/src/dom-parser/DOMParser.ts +4 -5
  267. package/src/event/IUIEventInit.ts +2 -2
  268. package/src/event/UIEvent.ts +2 -2
  269. package/src/fetch/FetchHandler.ts +3 -3
  270. package/src/fetch/ResourceFetchHandler.ts +2 -2
  271. package/src/index.ts +3 -3
  272. package/src/nodes/document/Document.ts +4 -4
  273. package/src/nodes/document/IDocument.ts +2 -2
  274. package/src/nodes/html-link-element/HTMLLinkElement.ts +8 -2
  275. package/src/nodes/html-script-element/ScriptUtility.ts +4 -4
  276. package/src/window/GlobalWindow.ts +91 -0
  277. package/src/window/IWindow.ts +31 -12
  278. package/src/window/VMGlobalPropertyScript.ts +62 -0
  279. package/src/window/Window.ts +125 -173
  280. package/tsconfig.json +1 -1
  281. package/lib/window/AsyncWindow.d.ts +0 -10
  282. package/lib/window/AsyncWindow.js +0 -38
  283. package/lib/window/AsyncWindow.js.map +0 -1
  284. package/src/window/AsyncWindow.ts +0 -17
@@ -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
- var EventTarget_1 = __importDefault(require("../../event/EventTarget"));
22
- var MutationRecord_1 = __importDefault(require("../../mutation-observer/MutationRecord"));
23
- var MutationTypeEnum_1 = __importDefault(require("../../mutation-observer/MutationTypeEnum"));
24
- var DOMException_1 = __importDefault(require("../../exception/DOMException"));
25
- var NodeListFactory_1 = __importDefault(require("./NodeListFactory"));
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
- var Node = /** @class */ (function (_super) {
30
- __extends(Node, _super);
14
+ class Node extends EventTarget_1.default {
31
15
  /**
32
16
  * Constructor.
33
17
  */
34
- function Node() {
35
- var _this = _super.call(this) || this;
36
- _this.ELEMENT_NODE = 1;
37
- _this.TEXT_NODE = 3;
38
- _this.COMMENT_NODE = 8;
39
- _this.DOCUMENT_NODE = 9;
40
- _this.DOCUMENT_TYPE_NODE = 10;
41
- _this.DOCUMENT_FRAGMENT_NODE = 11;
42
- _this.ownerDocument = null;
43
- _this.parentNode = null;
44
- _this.childNodes = NodeListFactory_1.default.create();
45
- _this.isConnected = false;
46
- _this._rootNode = null;
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
- _this._observers = [];
49
- _this.ownerDocument = _this.constructor.ownerDocument;
50
- return _this;
32
+ this._observers = [];
33
+ this.ownerDocument = this.constructor.ownerDocument;
51
34
  }
52
- Object.defineProperty(Node.prototype, "textContent", {
53
- /**
54
- * Get text value of children.
55
- *
56
- * @returns Text content.
57
- */
58
- get: function () {
59
- return null;
60
- },
61
- /**
62
- * Sets text content.
63
- *
64
- * @param textContent Text content.
65
- */
66
- set: function (_textContent) {
67
- // Do nothing.
68
- },
69
- enumerable: false,
70
- configurable: true
71
- });
72
- Object.defineProperty(Node.prototype, "nodeValue", {
73
- /**
74
- * Node value.
75
- *
76
- * @returns Node value.
77
- */
78
- get: function () {
79
- return null;
80
- },
81
- /**
82
- * Sets node value.
83
- */
84
- set: function (_nodeValue) {
85
- // Do nothing
86
- },
87
- enumerable: false,
88
- configurable: true
89
- });
90
- Object.defineProperty(Node.prototype, "nodeName", {
91
- /**
92
- * Node name.
93
- *
94
- * @returns Node name.
95
- */
96
- get: function () {
97
- return '';
98
- },
99
- enumerable: false,
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
- return parent;
180
- },
181
- enumerable: false,
182
- configurable: true
183
- });
184
- Object.defineProperty(Node.prototype, "baseURI", {
185
- /**
186
- * Returns base URI.
187
- *
188
- * @returns Base URI.
189
- */
190
- get: function () {
191
- var base = this.ownerDocument.querySelector('base');
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
- return this.ownerDocument.location.href;
196
- },
197
- enumerable: false,
198
- configurable: true
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
- Node.prototype.hasChildNodes = function () {
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
- Node.prototype.contains = function (otherNode) {
215
- for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
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
- Node.prototype.getRootNode = function (options) {
176
+ getRootNode(options) {
231
177
  if (!this.isConnected) {
232
178
  return this;
233
179
  }
234
- if (this._rootNode && !(options === null || options === void 0 ? void 0 : options.composed)) {
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
- Node.prototype.cloneNode = function (deep) {
246
- if (deep === void 0) { deep = false; }
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 (var _i = 0, _a = clone.childNodes.slice(); _i < _a.length; _i++) {
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 (var _b = 0, _c = this.childNodes; _b < _c.length; _b++) {
257
- var childNode = _c[_b];
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
- Node.prototype.appendChild = function (node) {
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 (var _i = 0, _a = node.childNodes.slice(); _i < _a.length; _i++) {
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
- var index = node.parentNode.childNodes.indexOf(node);
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
- var record = new MutationRecord_1.default();
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 (var _b = 0, _c = this._observers; _b < _c.length; _b++) {
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
- Node.prototype.removeChild = function (node) {
319
- var index = this.childNodes.indexOf(node);
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
- var record = new MutationRecord_1.default();
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 (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
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
- Node.prototype.insertBefore = function (newNode, referenceNode) {
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 (var _i = 0, _a = newNode.childNodes.slice(); _i < _a.length; _i++) {
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
- var index = referenceNode ? this.childNodes.indexOf(referenceNode) : 0;
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
- var index_1 = newNode.parentNode.childNodes.indexOf(newNode);
371
- if (index_1 !== -1) {
372
- newNode.parentNode.childNodes.splice(index_1, 1);
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
- var record = new MutationRecord_1.default();
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 (var _b = 0, _c = this._observers; _b < _c.length; _b++) {
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
- Node.prototype.replaceChild = function (newChild, oldChild) {
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
- Node.prototype.dispatchEvent = function (event) {
411
- var returnValue = _super.prototype.dispatchEvent.call(this, event);
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
- Node.prototype.toString = function () {
430
- return "[object ".concat(this.constructor.name, "]");
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
- Node.prototype._observe = function (listener) {
376
+ _observe(listener) {
439
377
  this._observers.push(listener);
440
378
  if (listener.options.subtree) {
441
- for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
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
- Node.prototype._unobserve = function (listener) {
454
- var index = this._observers.indexOf(listener);
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 (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
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
- Node.prototype._connectToNode = function (parentNode) {
471
- if (parentNode === void 0) { parentNode = null; }
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 (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
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
- // Public properties
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