happy-dom 2.54.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of happy-dom might be problematic. Click here for more details.

Files changed (299) 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.d.ts +2 -1
  7. package/lib/config/ElementTag.js +16 -15
  8. package/lib/config/ElementTag.js.map +1 -1
  9. package/lib/config/NonImplemenetedElementClasses.js +0 -1
  10. package/lib/config/NonImplemenetedElementClasses.js.map +1 -1
  11. package/lib/cookie/CookieUtility.js +21 -26
  12. package/lib/cookie/CookieUtility.js.map +1 -1
  13. package/lib/css/CSS.js +12 -18
  14. package/lib/css/CSS.js.map +1 -1
  15. package/lib/css/CSSParser.js +29 -33
  16. package/lib/css/CSSParser.js.map +1 -1
  17. package/lib/css/CSSRule.js +24 -29
  18. package/lib/css/CSSRule.js.map +1 -1
  19. package/lib/css/CSSStyleDeclaration.js +4516 -6005
  20. package/lib/css/CSSStyleDeclaration.js.map +1 -1
  21. package/lib/css/CSSStyleSheet.js +17 -59
  22. package/lib/css/CSSStyleSheet.js.map +1 -1
  23. package/lib/css/CSSUnitValue.js +4 -5
  24. package/lib/css/CSSUnitValue.js.map +1 -1
  25. package/lib/css/MediaList.js +23 -28
  26. package/lib/css/MediaList.js.map +1 -1
  27. package/lib/css/rules/CSSFontFaceRule.js +6 -24
  28. package/lib/css/rules/CSSFontFaceRule.js.map +1 -1
  29. package/lib/css/rules/CSSKeyframeRule.js +14 -36
  30. package/lib/css/rules/CSSKeyframeRule.js.map +1 -1
  31. package/lib/css/rules/CSSKeyframesRule.js +31 -54
  32. package/lib/css/rules/CSSKeyframesRule.js.map +1 -1
  33. package/lib/css/rules/CSSMediaRule.js +29 -56
  34. package/lib/css/rules/CSSMediaRule.js.map +1 -1
  35. package/lib/css/rules/CSSStyleRule.js +16 -38
  36. package/lib/css/rules/CSSStyleRule.js.map +1 -1
  37. package/lib/custom-element/CustomElementRegistry.js +21 -24
  38. package/lib/custom-element/CustomElementRegistry.js.map +1 -1
  39. package/lib/dom-implementation/DOMImplementation.js +12 -13
  40. package/lib/dom-implementation/DOMImplementation.js.map +1 -1
  41. package/lib/dom-parser/DOMParser.js +29 -35
  42. package/lib/dom-parser/DOMParser.js.map +1 -1
  43. package/lib/dom-token-list/DOMTokenList.js +64 -79
  44. package/lib/dom-token-list/DOMTokenList.js.map +1 -1
  45. package/lib/event/DataTransfer.js +4 -5
  46. package/lib/event/DataTransfer.js.map +1 -1
  47. package/lib/event/DataTransferItem.js +7 -8
  48. package/lib/event/DataTransferItem.js.map +1 -1
  49. package/lib/event/DataTransferItemList.js +10 -11
  50. package/lib/event/DataTransferItemList.js.map +1 -1
  51. package/lib/event/Event.js +11 -15
  52. package/lib/event/Event.js.map +1 -1
  53. package/lib/event/EventTarget.js +14 -16
  54. package/lib/event/EventTarget.js.map +1 -1
  55. package/lib/event/IUIEventInit.d.ts +2 -2
  56. package/lib/event/UIEvent.d.ts +2 -2
  57. package/lib/event/UIEvent.js +25 -46
  58. package/lib/event/UIEvent.js.map +1 -1
  59. package/lib/event/events/AnimationEvent.js +11 -29
  60. package/lib/event/events/AnimationEvent.js.map +1 -1
  61. package/lib/event/events/CustomEvent.js +9 -31
  62. package/lib/event/events/CustomEvent.js.map +1 -1
  63. package/lib/event/events/ErrorEvent.js +15 -34
  64. package/lib/event/events/ErrorEvent.js.map +1 -1
  65. package/lib/event/events/FocusEvent.js +7 -26
  66. package/lib/event/events/FocusEvent.js.map +1 -1
  67. package/lib/event/events/InputEvent.js +13 -32
  68. package/lib/event/events/InputEvent.js.map +1 -1
  69. package/lib/event/events/KeyboardEvent.js +27 -46
  70. package/lib/event/events/KeyboardEvent.js.map +1 -1
  71. package/lib/event/events/MouseEvent.js +33 -52
  72. package/lib/event/events/MouseEvent.js.map +1 -1
  73. package/lib/event/events/PointerEvent.js +25 -44
  74. package/lib/event/events/PointerEvent.js.map +1 -1
  75. package/lib/event/events/ProgressEvent.js +11 -30
  76. package/lib/event/events/ProgressEvent.js.map +1 -1
  77. package/lib/event/events/StorageEvent.js +13 -32
  78. package/lib/event/events/StorageEvent.js.map +1 -1
  79. package/lib/event/events/WheelEvent.js +16 -35
  80. package/lib/event/events/WheelEvent.js.map +1 -1
  81. package/lib/exception/DOMException.js +5 -24
  82. package/lib/exception/DOMException.js.map +1 -1
  83. package/lib/fetch/FetchHandler.js +18 -22
  84. package/lib/fetch/FetchHandler.js.map +1 -1
  85. package/lib/fetch/Headers.js +3 -23
  86. package/lib/fetch/Headers.js.map +1 -1
  87. package/lib/fetch/Request.js +61 -81
  88. package/lib/fetch/Request.js.map +1 -1
  89. package/lib/fetch/ResourceFetchHandler.js +18 -67
  90. package/lib/fetch/ResourceFetchHandler.js.map +1 -1
  91. package/lib/fetch/Response.js +61 -81
  92. package/lib/fetch/Response.js.map +1 -1
  93. package/lib/file/Blob.js +29 -78
  94. package/lib/file/Blob.js.map +1 -1
  95. package/lib/file/File.js +9 -27
  96. package/lib/file/File.js.map +1 -1
  97. package/lib/file/FileReader.js +57 -78
  98. package/lib/file/FileReader.js.map +1 -1
  99. package/lib/history/History.js +32 -37
  100. package/lib/history/History.js.map +1 -1
  101. package/lib/index.d.ts +5 -3
  102. package/lib/index.js +71 -69
  103. package/lib/index.js.map +1 -1
  104. package/lib/location/Location.js +11 -28
  105. package/lib/location/Location.js.map +1 -1
  106. package/lib/location/RelativeURL.js +5 -8
  107. package/lib/location/RelativeURL.js.map +1 -1
  108. package/lib/location/URL.js +46 -59
  109. package/lib/location/URL.js.map +1 -1
  110. package/lib/match-media/MediaQueryList.js +28 -54
  111. package/lib/match-media/MediaQueryList.js.map +1 -1
  112. package/lib/mutation-observer/MutationListener.js +3 -4
  113. package/lib/mutation-observer/MutationListener.js.map +1 -1
  114. package/lib/mutation-observer/MutationObserver.js +12 -13
  115. package/lib/mutation-observer/MutationObserver.js.map +1 -1
  116. package/lib/mutation-observer/MutationRecord.js +3 -4
  117. package/lib/mutation-observer/MutationRecord.js.map +1 -1
  118. package/lib/navigator/MimeType.js +5 -6
  119. package/lib/navigator/MimeType.js.map +1 -1
  120. package/lib/navigator/MimeTypeArray.js +10 -11
  121. package/lib/navigator/MimeTypeArray.js.map +1 -1
  122. package/lib/navigator/Navigator.js +7 -8
  123. package/lib/navigator/Navigator.js.map +1 -1
  124. package/lib/navigator/Plugin.js +10 -11
  125. package/lib/navigator/Plugin.js.map +1 -1
  126. package/lib/navigator/PluginArray.js +12 -13
  127. package/lib/navigator/PluginArray.js.map +1 -1
  128. package/lib/nodes/character-data/CharacterData.js +119 -184
  129. package/lib/nodes/character-data/CharacterData.js.map +1 -1
  130. package/lib/nodes/character-data/CharacterDataUtility.js +12 -15
  131. package/lib/nodes/character-data/CharacterDataUtility.js.map +1 -1
  132. package/lib/nodes/child-node/ChildNodeUtility.js +24 -45
  133. package/lib/nodes/child-node/ChildNodeUtility.js.map +1 -1
  134. package/lib/nodes/child-node/NonDocumentChildNodeUtility.js +9 -12
  135. package/lib/nodes/child-node/NonDocumentChildNodeUtility.js.map +1 -1
  136. package/lib/nodes/comment/Comment.js +20 -43
  137. package/lib/nodes/comment/Comment.js.map +1 -1
  138. package/lib/nodes/document/Document.d.ts +3 -3
  139. package/lib/nodes/document/Document.js +334 -461
  140. package/lib/nodes/document/Document.js.map +1 -1
  141. package/lib/nodes/document/DocumentReadyStateManager.js +16 -19
  142. package/lib/nodes/document/DocumentReadyStateManager.js.map +1 -1
  143. package/lib/nodes/document/IDocument.d.ts +2 -2
  144. package/lib/nodes/document-fragment/DocumentFragment.js +93 -153
  145. package/lib/nodes/document-fragment/DocumentFragment.js.map +1 -1
  146. package/lib/nodes/document-type/DocumentType.js +22 -45
  147. package/lib/nodes/document-type/DocumentType.js.map +1 -1
  148. package/lib/nodes/element/DOMRect.js +3 -4
  149. package/lib/nodes/element/DOMRect.js.map +1 -1
  150. package/lib/nodes/element/Element.js +367 -496
  151. package/lib/nodes/element/Element.js.map +1 -1
  152. package/lib/nodes/element/HTMLCollection.js +4 -24
  153. package/lib/nodes/element/HTMLCollection.js.map +1 -1
  154. package/lib/nodes/element/HTMLCollectionFactory.js +6 -9
  155. package/lib/nodes/element/HTMLCollectionFactory.js.map +1 -1
  156. package/lib/nodes/element/Range.js +89 -114
  157. package/lib/nodes/element/Range.js.map +1 -1
  158. package/lib/nodes/html-base-element/HTMLBaseElement.d.ts +42 -0
  159. package/lib/nodes/html-base-element/HTMLBaseElement.js +62 -0
  160. package/lib/nodes/html-base-element/HTMLBaseElement.js.map +1 -0
  161. package/lib/nodes/html-base-element/IHTMLBaseElement.d.ts +19 -0
  162. package/lib/nodes/html-base-element/IHTMLBaseElement.js +3 -0
  163. package/lib/nodes/html-base-element/IHTMLBaseElement.js.map +1 -0
  164. package/lib/nodes/html-document/HTMLDocument.js +3 -23
  165. package/lib/nodes/html-document/HTMLDocument.js.map +1 -1
  166. package/lib/nodes/html-element/DatasetUtility.js +9 -12
  167. package/lib/nodes/html-element/DatasetUtility.js.map +1 -1
  168. package/lib/nodes/html-element/HTMLElement.js +232 -290
  169. package/lib/nodes/html-element/HTMLElement.js.map +1 -1
  170. package/lib/nodes/html-form-element/HTMLFormElement.js +170 -235
  171. package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
  172. package/lib/nodes/html-image-element/HTMLImageElement.js +178 -237
  173. package/lib/nodes/html-image-element/HTMLImageElement.js.map +1 -1
  174. package/lib/nodes/html-image-element/Image.js +7 -27
  175. package/lib/nodes/html-image-element/Image.js.map +1 -1
  176. package/lib/nodes/html-input-element/HTMLInputElement.js +705 -872
  177. package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
  178. package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js +9 -12
  179. package/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js.map +1 -1
  180. package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js +5 -8
  181. package/lib/nodes/html-input-element/HTMLInputElementValueStepping.js.map +1 -1
  182. package/lib/nodes/html-input-element/ValidityState.js +47 -69
  183. package/lib/nodes/html-input-element/ValidityState.js.map +1 -1
  184. package/lib/nodes/html-label-element/HTMLLabelElement.js +53 -87
  185. package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -1
  186. package/lib/nodes/html-link-element/HTMLLinkElement.js +197 -252
  187. package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
  188. package/lib/nodes/html-meta-element/HTMLMetaElement.js +66 -102
  189. package/lib/nodes/html-meta-element/HTMLMetaElement.js.map +1 -1
  190. package/lib/nodes/html-script-element/HTMLScriptElement.js +145 -193
  191. package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
  192. package/lib/nodes/html-script-element/ScriptUtility.js +58 -112
  193. package/lib/nodes/html-script-element/ScriptUtility.js.map +1 -1
  194. package/lib/nodes/html-slot-element/HTMLSlotElement.js +33 -65
  195. package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -1
  196. package/lib/nodes/html-style-element/HTMLStyleElement.js +75 -109
  197. package/lib/nodes/html-style-element/HTMLStyleElement.js.map +1 -1
  198. package/lib/nodes/html-template-element/HTMLTemplateElement.js +60 -99
  199. package/lib/nodes/html-template-element/HTMLTemplateElement.js.map +1 -1
  200. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +349 -444
  201. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
  202. package/lib/nodes/html-unknown-element/HTMLUnknownElement.js +17 -37
  203. package/lib/nodes/html-unknown-element/HTMLUnknownElement.js.map +1 -1
  204. package/lib/nodes/node/INode.d.ts +1 -0
  205. package/lib/nodes/node/Node.d.ts +6 -0
  206. package/lib/nodes/node/Node.js +193 -244
  207. package/lib/nodes/node/Node.js.map +1 -1
  208. package/lib/nodes/node/NodeList.js +4 -24
  209. package/lib/nodes/node/NodeList.js.map +1 -1
  210. package/lib/nodes/node/NodeListFactory.js +6 -9
  211. package/lib/nodes/node/NodeListFactory.js.map +1 -1
  212. package/lib/nodes/parent-node/ParentNodeUtility.js +43 -78
  213. package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
  214. package/lib/nodes/shadow-root/ShadowRoot.js +53 -83
  215. package/lib/nodes/shadow-root/ShadowRoot.js.map +1 -1
  216. package/lib/nodes/svg-document/SVGDocument.js +3 -23
  217. package/lib/nodes/svg-document/SVGDocument.js.map +1 -1
  218. package/lib/nodes/svg-element/DOMMatrix.js +3 -4
  219. package/lib/nodes/svg-element/DOMMatrix.js.map +1 -1
  220. package/lib/nodes/svg-element/SVGAngle.js +10 -11
  221. package/lib/nodes/svg-element/SVGAngle.js.map +1 -1
  222. package/lib/nodes/svg-element/SVGAnimatedRect.js +4 -5
  223. package/lib/nodes/svg-element/SVGAnimatedRect.js.map +1 -1
  224. package/lib/nodes/svg-element/SVGElement.js +58 -93
  225. package/lib/nodes/svg-element/SVGElement.js.map +1 -1
  226. package/lib/nodes/svg-element/SVGGraphicsElement.js +14 -32
  227. package/lib/nodes/svg-element/SVGGraphicsElement.js.map +1 -1
  228. package/lib/nodes/svg-element/SVGLength.js +16 -17
  229. package/lib/nodes/svg-element/SVGLength.js.map +1 -1
  230. package/lib/nodes/svg-element/SVGNumber.js +3 -4
  231. package/lib/nodes/svg-element/SVGNumber.js.map +1 -1
  232. package/lib/nodes/svg-element/SVGPoint.js +3 -4
  233. package/lib/nodes/svg-element/SVGPoint.js.map +1 -1
  234. package/lib/nodes/svg-element/SVGRect.js +3 -4
  235. package/lib/nodes/svg-element/SVGRect.js.map +1 -1
  236. package/lib/nodes/svg-element/SVGSVGElement.js +187 -248
  237. package/lib/nodes/svg-element/SVGSVGElement.js.map +1 -1
  238. package/lib/nodes/svg-element/SVGTransform.js +16 -17
  239. package/lib/nodes/svg-element/SVGTransform.js.map +1 -1
  240. package/lib/nodes/text/Text.js +20 -43
  241. package/lib/nodes/text/Text.js.map +1 -1
  242. package/lib/nodes/xml-document/XMLDocument.js +3 -23
  243. package/lib/nodes/xml-document/XMLDocument.js.map +1 -1
  244. package/lib/query-selector/QuerySelector.js +36 -44
  245. package/lib/query-selector/QuerySelector.js.map +1 -1
  246. package/lib/query-selector/SelectorItem.js +62 -66
  247. package/lib/query-selector/SelectorItem.js.map +1 -1
  248. package/lib/resize-observer/ResizeObserver.js +8 -11
  249. package/lib/resize-observer/ResizeObserver.js.map +1 -1
  250. package/lib/screen/Screen.js +3 -4
  251. package/lib/screen/Screen.js.map +1 -1
  252. package/lib/selection/Selection.js +29 -30
  253. package/lib/selection/Selection.js.map +1 -1
  254. package/lib/storage/Storage.js +22 -27
  255. package/lib/storage/Storage.js.map +1 -1
  256. package/lib/tree-walker/NodeFilterMask.js +1 -1
  257. package/lib/tree-walker/NodeFilterMask.js.map +1 -1
  258. package/lib/tree-walker/TreeWalker.js +30 -33
  259. package/lib/tree-walker/TreeWalker.js.map +1 -1
  260. package/lib/window/GlobalWindow.d.ts +84 -0
  261. package/lib/window/GlobalWindow.js +90 -0
  262. package/lib/window/GlobalWindow.js.map +1 -0
  263. package/lib/window/IWindow.d.ts +37 -18
  264. package/lib/window/VMGlobalPropertyScript.d.ts +2 -0
  265. package/lib/window/VMGlobalPropertyScript.js +65 -0
  266. package/lib/window/VMGlobalPropertyScript.js.map +1 -0
  267. package/lib/window/Window.d.ts +78 -105
  268. package/lib/window/Window.js +277 -489
  269. package/lib/window/Window.js.map +1 -1
  270. package/lib/xml-parser/XMLParser.js +65 -71
  271. package/lib/xml-parser/XMLParser.js.map +1 -1
  272. package/lib/xml-serializer/XMLSerializer.js +30 -37
  273. package/lib/xml-serializer/XMLSerializer.js.map +1 -1
  274. package/package.json +6 -7
  275. package/src/config/ElementTag.ts +2 -1
  276. package/src/config/NonImplemenetedElementClasses.ts +0 -1
  277. package/src/dom-parser/DOMParser.ts +4 -5
  278. package/src/event/IUIEventInit.ts +2 -2
  279. package/src/event/UIEvent.ts +2 -2
  280. package/src/fetch/FetchHandler.ts +3 -3
  281. package/src/fetch/ResourceFetchHandler.ts +3 -3
  282. package/src/index.ts +7 -3
  283. package/src/nodes/document/Document.ts +4 -4
  284. package/src/nodes/document/IDocument.ts +2 -2
  285. package/src/nodes/html-base-element/HTMLBaseElement.ts +61 -0
  286. package/src/nodes/html-base-element/IHTMLBaseElement.ts +21 -0
  287. package/src/nodes/html-link-element/HTMLLinkElement.ts +8 -2
  288. package/src/nodes/html-script-element/ScriptUtility.ts +4 -4
  289. package/src/nodes/node/INode.ts +1 -0
  290. package/src/nodes/node/Node.ts +14 -0
  291. package/src/window/GlobalWindow.ts +82 -0
  292. package/src/window/IWindow.ts +33 -12
  293. package/src/window/VMGlobalPropertyScript.ts +62 -0
  294. package/src/window/Window.ts +115 -173
  295. package/tsconfig.json +1 -1
  296. package/lib/window/AsyncWindow.d.ts +0 -10
  297. package/lib/window/AsyncWindow.js +0 -38
  298. package/lib/window/AsyncWindow.js.map +0 -1
  299. package/src/window/AsyncWindow.ts +0 -17
@@ -1,209 +1,171 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
4
  };
20
5
  Object.defineProperty(exports, "__esModule", { value: true });
21
- 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];
35
+ /**
36
+ * Get text value of children.
37
+ *
38
+ * @returns Text content.
39
+ */
40
+ get textContent() {
41
+ return null;
42
+ }
43
+ /**
44
+ * Sets text content.
45
+ *
46
+ * @param textContent Text content.
47
+ */
48
+ set textContent(_textContent) {
49
+ // Do nothing.
50
+ }
51
+ /**
52
+ * Node value.
53
+ *
54
+ * @returns Node value.
55
+ */
56
+ get nodeValue() {
57
+ return null;
58
+ }
59
+ /**
60
+ * Sets node value.
61
+ */
62
+ set nodeValue(_nodeValue) {
63
+ // Do nothing
64
+ }
65
+ /**
66
+ * Node name.
67
+ *
68
+ * @returns Node name.
69
+ */
70
+ get nodeName() {
71
+ return '';
72
+ }
73
+ /**
74
+ * Previous sibling.
75
+ *
76
+ * @returns Node.
77
+ */
78
+ get previousSibling() {
79
+ if (this.parentNode) {
80
+ const index = this.parentNode.childNodes.indexOf(this);
81
+ if (index > 0) {
82
+ return this.parentNode.childNodes[index - 1];
162
83
  }
163
- 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;
84
+ }
85
+ return null;
86
+ }
87
+ /**
88
+ * Next sibling.
89
+ *
90
+ * @returns Node.
91
+ */
92
+ get nextSibling() {
93
+ if (this.parentNode) {
94
+ const index = this.parentNode.childNodes.indexOf(this);
95
+ if (index > -1 && index + 1 < this.parentNode.childNodes.length) {
96
+ return this.parentNode.childNodes[index + 1];
178
97
  }
179
- return parent;
180
- },
181
- enumerable: false,
182
- configurable: true
183
- });
98
+ }
99
+ return null;
100
+ }
101
+ /**
102
+ * First child.
103
+ *
104
+ * @returns Node.
105
+ */
106
+ get firstChild() {
107
+ if (this.childNodes.length > 0) {
108
+ return this.childNodes[0];
109
+ }
110
+ return null;
111
+ }
112
+ /**
113
+ * Last child.
114
+ *
115
+ * @returns Node.
116
+ */
117
+ get lastChild() {
118
+ if (this.childNodes.length > 0) {
119
+ return this.childNodes[this.childNodes.length - 1];
120
+ }
121
+ return null;
122
+ }
123
+ /**
124
+ * Returns parent element.
125
+ *
126
+ * @returns Element.
127
+ */
128
+ get parentElement() {
129
+ let parent = this.parentNode;
130
+ while (parent && parent.nodeType !== Node.ELEMENT_NODE) {
131
+ parent = parent.parentNode;
132
+ }
133
+ return parent;
134
+ }
135
+ /**
136
+ * Returns base URI.
137
+ *
138
+ * @returns Base URI.
139
+ */
140
+ get baseURI() {
141
+ const base = this.ownerDocument.querySelector('base');
142
+ if (base) {
143
+ return base.href;
144
+ }
145
+ return this.ownerDocument.location.href;
146
+ }
184
147
  /**
185
148
  * Returns "true" if the node has child nodes.
186
149
  *
187
150
  * @returns "true" if the node has child nodes.
188
151
  */
189
- Node.prototype.hasChildNodes = function () {
152
+ hasChildNodes() {
190
153
  return this.childNodes.length > 0;
191
- };
154
+ }
192
155
  /**
193
156
  * Returns "true" if this node contains the other node.
194
157
  *
195
158
  * @param otherNode Node to test with.
196
159
  * @returns "true" if this node contains the other node.
197
160
  */
198
- Node.prototype.contains = function (otherNode) {
199
- for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
200
- var childNode = _a[_i];
161
+ contains(otherNode) {
162
+ for (const childNode of this.childNodes) {
201
163
  if (childNode === otherNode || childNode.contains(otherNode)) {
202
164
  return true;
203
165
  }
204
166
  }
205
167
  return false;
206
- };
168
+ }
207
169
  /**
208
170
  * Returns closest root node (Document or ShadowRoot).
209
171
  *
@@ -211,64 +173,60 @@ var Node = /** @class */ (function (_super) {
211
173
  * @param options.composed A Boolean that indicates whether the shadow root should be returned (false, the default), or a root node beyond shadow root (true).
212
174
  * @returns Node.
213
175
  */
214
- Node.prototype.getRootNode = function (options) {
176
+ getRootNode(options) {
215
177
  if (!this.isConnected) {
216
178
  return this;
217
179
  }
218
- if (this._rootNode && !(options === null || options === void 0 ? void 0 : options.composed)) {
180
+ if (this._rootNode && !options?.composed) {
219
181
  return this._rootNode;
220
182
  }
221
183
  return this.ownerDocument;
222
- };
184
+ }
223
185
  /**
224
186
  * Clones a node.
225
187
  *
226
188
  * @param [deep=false] "true" to clone deep.
227
189
  * @returns Cloned node.
228
190
  */
229
- Node.prototype.cloneNode = function (deep) {
230
- if (deep === void 0) { deep = false; }
231
- var clone = new this.constructor();
191
+ cloneNode(deep = false) {
192
+ const clone = new this.constructor();
232
193
  // Document has childNodes directly when it is created
233
194
  if (clone.childNodes.length) {
234
- for (var _i = 0, _a = clone.childNodes.slice(); _i < _a.length; _i++) {
235
- var node = _a[_i];
195
+ for (const node of clone.childNodes.slice()) {
236
196
  node.parentNode.removeChild(node);
237
197
  }
238
198
  }
239
199
  if (deep) {
240
- for (var _b = 0, _c = this.childNodes; _b < _c.length; _b++) {
241
- var childNode = _c[_b];
242
- var childClone = childNode.cloneNode(true);
200
+ for (const childNode of this.childNodes) {
201
+ const childClone = childNode.cloneNode(true);
243
202
  childClone.parentNode = clone;
244
203
  clone.childNodes.push(childClone);
245
204
  }
246
205
  }
247
206
  clone.ownerDocument = this.ownerDocument;
248
207
  return clone;
249
- };
208
+ }
250
209
  /**
251
210
  * Append a child node to childNodes.
252
211
  *
253
212
  * @param node Node to append.
254
213
  * @returns Appended node.
255
214
  */
256
- Node.prototype.appendChild = function (node) {
215
+ appendChild(node) {
257
216
  if (node === this) {
258
217
  throw new DOMException_1.default('Not possible to append a node as a child of itself.');
259
218
  }
260
219
  // If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
261
220
  // See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
262
221
  if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
263
- for (var _i = 0, _a = node.childNodes.slice(); _i < _a.length; _i++) {
264
- var child = _a[_i];
222
+ for (const child of node.childNodes.slice()) {
265
223
  this.appendChild(child);
266
224
  }
267
225
  return node;
268
226
  }
269
227
  // Remove the node from its previous parent if it has any.
270
228
  if (node.parentNode) {
271
- var index = node.parentNode.childNodes.indexOf(node);
229
+ const index = node.parentNode.childNodes.indexOf(node);
272
230
  if (index !== -1) {
273
231
  node.parentNode.childNodes.splice(index, 1);
274
232
  }
@@ -277,12 +235,11 @@ var Node = /** @class */ (function (_super) {
277
235
  node._connectToNode(this);
278
236
  // MutationObserver
279
237
  if (this._observers.length > 0) {
280
- var record = new MutationRecord_1.default();
238
+ const record = new MutationRecord_1.default();
281
239
  record.target = this;
282
240
  record.type = MutationTypeEnum_1.default.childList;
283
241
  record.addedNodes = [node];
284
- for (var _b = 0, _c = this._observers; _b < _c.length; _b++) {
285
- var observer = _c[_b];
242
+ for (const observer of this._observers) {
286
243
  if (observer.options.subtree) {
287
244
  node._observe(observer);
288
245
  }
@@ -292,15 +249,15 @@ var Node = /** @class */ (function (_super) {
292
249
  }
293
250
  }
294
251
  return node;
295
- };
252
+ }
296
253
  /**
297
254
  * Remove Child element from childNodes array.
298
255
  *
299
256
  * @param node Node to remove.
300
257
  * @returns Removed node.
301
258
  */
302
- Node.prototype.removeChild = function (node) {
303
- var index = this.childNodes.indexOf(node);
259
+ removeChild(node) {
260
+ const index = this.childNodes.indexOf(node);
304
261
  if (index === -1) {
305
262
  throw new DOMException_1.default('Failed to remove node. Node is not child of parent.');
306
263
  }
@@ -308,12 +265,11 @@ var Node = /** @class */ (function (_super) {
308
265
  node._connectToNode(null);
309
266
  // MutationObserver
310
267
  if (this._observers.length > 0) {
311
- var record = new MutationRecord_1.default();
268
+ const record = new MutationRecord_1.default();
312
269
  record.target = this;
313
270
  record.type = MutationTypeEnum_1.default.childList;
314
271
  record.removedNodes = [node];
315
- for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
316
- var observer = _a[_i];
272
+ for (const observer of this._observers) {
317
273
  node._unobserve(observer);
318
274
  if (observer.options.childList) {
319
275
  observer.callback([record]);
@@ -321,7 +277,7 @@ var Node = /** @class */ (function (_super) {
321
277
  }
322
278
  }
323
279
  return node;
324
- };
280
+ }
325
281
  /**
326
282
  * Inserts a node before another.
327
283
  *
@@ -329,12 +285,11 @@ var Node = /** @class */ (function (_super) {
329
285
  * @param [referenceNode] Node to insert before.
330
286
  * @returns Inserted node.
331
287
  */
332
- Node.prototype.insertBefore = function (newNode, referenceNode) {
288
+ insertBefore(newNode, referenceNode) {
333
289
  // If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
334
290
  // See: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
335
291
  if (newNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
336
- for (var _i = 0, _a = newNode.childNodes.slice(); _i < _a.length; _i++) {
337
- var child = _a[_i];
292
+ for (const child of newNode.childNodes.slice()) {
338
293
  this.insertBefore(child, referenceNode);
339
294
  }
340
295
  return newNode;
@@ -346,26 +301,25 @@ var Node = /** @class */ (function (_super) {
346
301
  if (referenceNode === undefined) {
347
302
  throw new DOMException_1.default("Failed to execute 'insertBefore' on 'Node': 2 arguments required, but only 1 present.", 'TypeError');
348
303
  }
349
- var index = referenceNode ? this.childNodes.indexOf(referenceNode) : 0;
304
+ const index = referenceNode ? this.childNodes.indexOf(referenceNode) : 0;
350
305
  if (index === -1) {
351
306
  throw new DOMException_1.default("Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.");
352
307
  }
353
308
  if (newNode.parentNode) {
354
- var index_1 = newNode.parentNode.childNodes.indexOf(newNode);
355
- if (index_1 !== -1) {
356
- 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);
357
312
  }
358
313
  }
359
314
  this.childNodes.splice(index, 0, newNode);
360
315
  newNode._connectToNode(this);
361
316
  // MutationObserver
362
317
  if (this._observers.length > 0) {
363
- var record = new MutationRecord_1.default();
318
+ const record = new MutationRecord_1.default();
364
319
  record.target = this;
365
320
  record.type = MutationTypeEnum_1.default.childList;
366
321
  record.addedNodes = [newNode];
367
- for (var _b = 0, _c = this._observers; _b < _c.length; _b++) {
368
- var observer = _c[_b];
322
+ for (const observer of this._observers) {
369
323
  if (observer.options.subtree) {
370
324
  newNode._observe(observer);
371
325
  }
@@ -375,7 +329,7 @@ var Node = /** @class */ (function (_super) {
375
329
  }
376
330
  }
377
331
  return newNode;
378
- };
332
+ }
379
333
  /**
380
334
  * Replaces a node with another.
381
335
  *
@@ -383,16 +337,16 @@ var Node = /** @class */ (function (_super) {
383
337
  * @param oldChild Old child.
384
338
  * @returns Replaced node.
385
339
  */
386
- Node.prototype.replaceChild = function (newChild, oldChild) {
340
+ replaceChild(newChild, oldChild) {
387
341
  this.insertBefore(newChild, oldChild);
388
342
  this.removeChild(oldChild);
389
343
  return oldChild;
390
- };
344
+ }
391
345
  /**
392
346
  * @override
393
347
  */
394
- Node.prototype.dispatchEvent = function (event) {
395
- var returnValue = _super.prototype.dispatchEvent.call(this, event);
348
+ dispatchEvent(event) {
349
+ const returnValue = super.dispatchEvent(event);
396
350
  if (event.bubbles && !event._propagationStopped) {
397
351
  if (this.parentNode) {
398
352
  return this.parentNode.dispatchEvent(event);
@@ -404,56 +358,53 @@ var Node = /** @class */ (function (_super) {
404
358
  }
405
359
  }
406
360
  return returnValue;
407
- };
361
+ }
408
362
  /**
409
363
  * Converts the node to a string.
410
364
  *
411
365
  * @param listener Listener.
412
366
  */
413
- Node.prototype.toString = function () {
414
- return "[object ".concat(this.constructor.name, "]");
415
- };
367
+ toString() {
368
+ return `[object ${this.constructor.name}]`;
369
+ }
416
370
  /**
417
371
  * Observeres the node.
418
372
  * Used by MutationObserver, but it is not part of the HTML standard.
419
373
  *
420
374
  * @param listener Listener.
421
375
  */
422
- Node.prototype._observe = function (listener) {
376
+ _observe(listener) {
423
377
  this._observers.push(listener);
424
378
  if (listener.options.subtree) {
425
- for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
426
- var node = _a[_i];
379
+ for (const node of this.childNodes) {
427
380
  node._observe(listener);
428
381
  }
429
382
  }
430
- };
383
+ }
431
384
  /**
432
385
  * Stops observing the node.
433
386
  * Used by MutationObserver, but it is not part of the HTML standard.
434
387
  *
435
388
  * @param listener Listener.
436
389
  */
437
- Node.prototype._unobserve = function (listener) {
438
- var index = this._observers.indexOf(listener);
390
+ _unobserve(listener) {
391
+ const index = this._observers.indexOf(listener);
439
392
  if (index !== -1) {
440
393
  this._observers.splice(index, 1);
441
394
  }
442
395
  if (listener.options.subtree) {
443
- for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
444
- var node = _a[_i];
396
+ for (const node of this.childNodes) {
445
397
  node._unobserve(listener);
446
398
  }
447
399
  }
448
- };
400
+ }
449
401
  /**
450
402
  * Connects this element to another element.
451
403
  *
452
404
  * @param parentNode Parent node.
453
405
  */
454
- Node.prototype._connectToNode = function (parentNode) {
455
- if (parentNode === void 0) { parentNode = null; }
456
- var isConnected = !!parentNode && parentNode.isConnected;
406
+ _connectToNode(parentNode = null) {
407
+ const isConnected = !!parentNode && parentNode.isConnected;
457
408
  if (this.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
458
409
  this.parentNode = parentNode;
459
410
  this._rootNode = isConnected && parentNode ? parentNode._rootNode : null;
@@ -466,8 +417,7 @@ var Node = /** @class */ (function (_super) {
466
417
  else if (!isConnected && this.disconnectedCallback) {
467
418
  this.disconnectedCallback();
468
419
  }
469
- for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
470
- var child = _a[_i];
420
+ for (const child of this.childNodes) {
471
421
  child._connectToNode(this);
472
422
  }
473
423
  // eslint-disable-next-line
@@ -476,16 +426,15 @@ var Node = /** @class */ (function (_super) {
476
426
  this._shadowRoot._connectToNode(this);
477
427
  }
478
428
  }
479
- };
480
- // Public properties
481
- Node.ELEMENT_NODE = 1;
482
- Node.TEXT_NODE = 3;
483
- Node.COMMENT_NODE = 8;
484
- Node.DOCUMENT_NODE = 9;
485
- Node.DOCUMENT_TYPE_NODE = 10;
486
- Node.DOCUMENT_FRAGMENT_NODE = 11;
487
- Node.ownerDocument = null;
488
- return Node;
489
- }(EventTarget_1.default));
429
+ }
430
+ }
490
431
  exports.default = Node;
432
+ // Public properties
433
+ Node.ELEMENT_NODE = 1;
434
+ Node.TEXT_NODE = 3;
435
+ Node.COMMENT_NODE = 8;
436
+ Node.DOCUMENT_NODE = 9;
437
+ Node.DOCUMENT_TYPE_NODE = 10;
438
+ Node.DOCUMENT_FRAGMENT_NODE = 11;
439
+ Node.ownerDocument = null;
491
440
  //# sourceMappingURL=Node.js.map