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,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
- var Node_1 = __importDefault(require("../node/Node"));
31
- var ShadowRoot_1 = __importDefault(require("../shadow-root/ShadowRoot"));
32
- var Attr_1 = __importDefault(require("../../attribute/Attr"));
33
- var DOMRect_1 = __importDefault(require("./DOMRect"));
34
- var Range_1 = __importDefault(require("./Range"));
35
- var DOMTokenList_1 = __importDefault(require("../../dom-token-list/DOMTokenList"));
36
- var QuerySelector_1 = __importDefault(require("../../query-selector/QuerySelector"));
37
- var SelectorItem_1 = __importDefault(require("../../query-selector/SelectorItem"));
38
- var MutationRecord_1 = __importDefault(require("../../mutation-observer/MutationRecord"));
39
- var MutationTypeEnum_1 = __importDefault(require("../../mutation-observer/MutationTypeEnum"));
40
- var NamespaceURI_1 = __importDefault(require("../../config/NamespaceURI"));
41
- var XMLParser_1 = __importDefault(require("../../xml-parser/XMLParser"));
42
- var XMLSerializer_1 = __importDefault(require("../../xml-serializer/XMLSerializer"));
43
- var ChildNodeUtility_1 = __importDefault(require("../child-node/ChildNodeUtility"));
44
- var ParentNodeUtility_1 = __importDefault(require("../parent-node/ParentNodeUtility"));
45
- var NonDocumentChildNodeUtility_1 = __importDefault(require("../child-node/NonDocumentChildNodeUtility"));
46
- var DOMException_1 = __importDefault(require("../../exception/DOMException"));
47
- var HTMLCollectionFactory_1 = __importDefault(require("./HTMLCollectionFactory"));
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
- var Element = /** @class */ (function (_super) {
52
- __extends(Element, _super);
53
- function Element() {
54
- var _this = _super !== null && _super.apply(this, arguments) || this;
55
- _this.tagName = null;
56
- _this.nodeType = Node_1.default.ELEMENT_NODE;
57
- _this.shadowRoot = null;
58
- _this.scrollTop = 0;
59
- _this.scrollLeft = 0;
60
- _this.children = HTMLCollectionFactory_1.default.create();
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
- _this._shadowRoot = null;
64
- _this._attributes = {};
65
- _this._classList = null;
66
- return _this;
67
- }
68
- Object.defineProperty(Element.prototype, "classList", {
69
- /**
70
- * Returns class list.
71
- *
72
- * @returns Class list.
73
- */
74
- get: function () {
75
- if (!this._classList) {
76
- this._classList = new DOMTokenList_1.default(this, 'class');
77
- }
78
- return this._classList;
79
- },
80
- enumerable: false,
81
- configurable: true
82
- });
83
- Object.defineProperty(Element.prototype, "id", {
84
- /**
85
- * Returns ID.
86
- *
87
- * @returns ID.
88
- */
89
- get: function () {
90
- return this.getAttribute('id') || '';
91
- },
92
- /**
93
- * Sets ID.
94
- *
95
- * @param id ID.
96
- */
97
- set: function (id) {
98
- this.setAttribute('id', id);
99
- },
100
- enumerable: false,
101
- configurable: true
102
- });
103
- Object.defineProperty(Element.prototype, "className", {
104
- /**
105
- * Returns class name.
106
- *
107
- * @returns Class name.
108
- */
109
- get: function () {
110
- return this.getAttribute('class') || '';
111
- },
112
- /**
113
- * Sets class name.
114
- *
115
- * @param className Class name.
116
- */
117
- set: function (className) {
118
- this.setAttribute('class', className);
119
- },
120
- enumerable: false,
121
- configurable: true
122
- });
123
- Object.defineProperty(Element.prototype, "nodeName", {
124
- /**
125
- * Node name.
126
- *
127
- * @returns Node name.
128
- */
129
- get: function () {
130
- return this.tagName;
131
- },
132
- enumerable: false,
133
- configurable: true
134
- });
135
- Object.defineProperty(Element.prototype, "localName", {
136
- /**
137
- * Local name.
138
- *
139
- * @returns Local name.
140
- */
141
- get: function () {
142
- return this.tagName ? this.tagName.toLowerCase() : 'unknown';
143
- },
144
- enumerable: false,
145
- configurable: true
146
- });
147
- Object.defineProperty(Element.prototype, "previousElementSibling", {
148
- /**
149
- * Previous element sibling.
150
- *
151
- * @returns Element.
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
- enumerable: false,
235
- configurable: true
236
- });
237
- Object.defineProperty(Element.prototype, "outerHTML", {
238
- /**
239
- * Returns outer HTML.
240
- *
241
- * @returns HTML.
242
- */
243
- get: function () {
244
- return new XMLSerializer_1.default().serializeToString(this);
245
- },
246
- /**
247
- * Returns outer HTML.
248
- *
249
- * @param html HTML.
250
- */
251
- set: function (html) {
252
- this.replaceWith(html);
253
- },
254
- enumerable: false,
255
- configurable: true
256
- });
257
- Object.defineProperty(Element.prototype, "attributes", {
258
- /**
259
- * Returns attributes.
260
- *
261
- * @returns Attributes.
262
- */
263
- get: function () {
264
- var attributes = Object.values(this._attributes);
265
- return Object.assign({}, this._attributes, attributes, {
266
- length: attributes.length
267
- });
268
- },
269
- enumerable: false,
270
- configurable: true
271
- });
272
- Object.defineProperty(Element.prototype, "firstElementChild", {
273
- /**
274
- * First element child.
275
- *
276
- * @returns Element.
277
- */
278
- get: function () {
279
- return this.children ? this.children[0] || null : null;
280
- },
281
- enumerable: false,
282
- configurable: true
283
- });
284
- Object.defineProperty(Element.prototype, "lastElementChild", {
285
- /**
286
- * Last element child.
287
- *
288
- * @returns Element.
289
- */
290
- get: function () {
291
- return this.children ? this.children[this.children.length - 1] || null : null;
292
- },
293
- enumerable: false,
294
- configurable: true
295
- });
296
- Object.defineProperty(Element.prototype, "childElementCount", {
297
- /**
298
- * Last element child.
299
- *
300
- * @returns Element.
301
- */
302
- get: function () {
303
- return this.children.length;
304
- },
305
- enumerable: false,
306
- configurable: true
307
- });
308
- Object.defineProperty(Element.prototype, "slot", {
309
- /**
310
- * Returns slot.
311
- *
312
- * @returns Slot.
313
- */
314
- get: function () {
315
- return this.getAttributeNS(null, 'slot') || '';
316
- },
317
- /**
318
- * Returns slot.
319
- *
320
- * @param slot Slot.
321
- */
322
- set: function (title) {
323
- this.setAttributeNS(null, 'slot', title);
324
- },
325
- enumerable: false,
326
- configurable: true
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
- Element.prototype.getInnerHTML = function (options) {
340
- var xmlSerializer = new XMLSerializer_1.default();
341
- var xml = '';
342
- for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
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
- Element.prototype.cloneNode = function (deep) {
356
- if (deep === void 0) { deep = false; }
357
- var clone = _super.prototype.cloneNode.call(this, deep);
358
- for (var _i = 0, _a = Object.keys(this._attributes); _i < _a.length; _i++) {
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 (var _b = 0, _c = clone.childNodes; _b < _c.length; _b++) {
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
- Element.prototype.appendChild = function (node) {
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
- var index = node.parentNode['children'].indexOf(node);
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 _super.prototype.appendChild.call(this, node);
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
- Element.prototype.removeChild = function (node) {
312
+ removeChild(node) {
408
313
  if (node.nodeType === Node_1.default.ELEMENT_NODE) {
409
- var index = this.children.indexOf(node);
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 _super.prototype.removeChild.call(this, node);
415
- };
319
+ return super.removeChild(node);
320
+ }
416
321
  /**
417
322
  * Removes the node from its parent.
418
323
  */
419
- Element.prototype.remove = function () {
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
- Element.prototype.insertBefore = function (newNode, referenceNode) {
431
- var returnValue = _super.prototype.insertBefore.call(this, newNode, referenceNode);
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
- var index = newNode.parentNode['children'].indexOf(newNode);
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 (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
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
- Element.prototype.replaceWith = function () {
457
- var nodes = [];
458
- for (var _i = 0; _i < arguments.length; _i++) {
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
- Element.prototype.before = function () {
469
- var nodes = [];
470
- for (var _i = 0; _i < arguments.length; _i++) {
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
- Element.prototype.after = function () {
481
- var nodes = [];
482
- for (var _i = 0; _i < arguments.length; _i++) {
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
- Element.prototype.append = function () {
493
- var nodes = [];
494
- for (var _i = 0; _i < arguments.length; _i++) {
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
- Element.prototype.prepend = function () {
505
- var nodes = [];
506
- for (var _i = 0; _i < arguments.length; _i++) {
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
- Element.prototype.replaceChildren = function () {
517
- var nodes = [];
518
- for (var _i = 0; _i < arguments.length; _i++) {
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
- Element.prototype.insertAdjacentElement = function (position, element) {
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
- Element.prototype.insertAdjacentHTML = function (position, text) {
558
- for (var _i = 0, _a = XMLParser_1.default.parse(this.ownerDocument, text).childNodes.slice(); _i < _a.length; _i++) {
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
- Element.prototype.insertAdjacentText = function (position, text) {
448
+ insertAdjacentText(position, text) {
570
449
  if (!text) {
571
450
  return;
572
451
  }
573
- var textNode = this.ownerDocument.createTextNode(text);
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
- Element.prototype.setAttribute = function (name, value) {
583
- var attribute = this.ownerDocument.createAttributeNS(null, name);
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
- Element.prototype.setAttributeNS = function (namespaceURI, name, value) {
595
- var attribute = this.ownerDocument.createAttributeNS(namespaceURI, name);
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
- Element.prototype.getAttributeNames = function () {
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
- Element.prototype.getAttribute = function (name) {
613
- var attribute = this.getAttributeNode(name);
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
- Element.prototype.getAttributeNS = function (namespace, localName) {
626
- var attribute = this.getAttributeNodeNS(namespace, localName);
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
- Element.prototype.hasAttribute = function (name) {
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
- Element.prototype.hasAttributeNS = function (namespace, localName) {
649
- for (var _i = 0, _a = Object.keys(this._attributes); _i < _a.length; _i++) {
650
- var name = _a[_i];
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
- Element.prototype.hasAttributes = function () {
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
- Element.prototype.removeAttribute = function (name) {
672
- var attribute = this._attributes[this._getAttributeName(name)];
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
- Element.prototype.removeAttributeNS = function (namespace, localName) {
684
- for (var _i = 0, _a = Object.keys(this._attributes); _i < _a.length; _i++) {
685
- var name = _a[_i];
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
- Element.prototype.attachShadow = function (shadowRootInit) {
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
- Element.prototype.toString = function () {
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
- Element.prototype.getBoundingClientRect = function () {
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
- Element.prototype.createTextRange = function () {
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
- Element.prototype.matches = function (selector) {
745
- for (var _i = 0, _a = selector.split(','); _i < _a.length; _i++) {
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
- Element.prototype.closest = function (selector) {
760
- var rootElement = this.ownerDocument.documentElement;
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
- var elements = rootElement.querySelectorAll(selector);
643
+ const elements = rootElement.querySelectorAll(selector);
768
644
  // eslint-disable-next-line
769
- var parent = this;
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
- Element.prototype.querySelectorAll = function (selector) {
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
- Element.prototype.querySelector = function (selector) {
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
- Element.prototype.getElementsByClassName = function (className) {
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
- Element.prototype.getElementsByTagName = function (tagName) {
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
- Element.prototype.getElementsByTagNameNS = function (namespaceURI, tagName) {
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
- Element.prototype.setAttributeNode = function (attribute) {
836
- var name = this._getAttributeName(attribute.name);
837
- var replacedAttribute = this._attributes[name];
838
- var oldValue = replacedAttribute ? replacedAttribute.value : null;
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 (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
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
- var record = new MutationRecord_1.default();
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
- Element.prototype.setAttributeNodeNS = function (attribute) {
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
- Element.prototype.getAttributeNode = function (name) {
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
- Element.prototype.getAttributeNodeNS = function (namespace, name) {
892
- var attributeName = this._getAttributeName(name);
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 (var _i = 0, _a = Object.keys(this._attributes); _i < _a.length; _i++) {
899
- var name_1 = _a[_i];
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
- Element.prototype.removeAttributeNode = function (attribute) {
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 (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
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
- var record = new MutationRecord_1.default();
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
- Element.prototype.removeAttributeNodeNS = function (attribute) {
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
- Element.prototype.scroll = function (x, y) {
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(function () {
827
+ this.ownerDocument.defaultView.setTimeout(() => {
956
828
  if (x.top !== undefined) {
957
- _this.scrollTop = x.top;
829
+ this.scrollTop = x.top;
958
830
  }
959
831
  if (x.left !== undefined) {
960
- _this.scrollLeft = x.left;
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
- Element.prototype.scrollTo = function (x, y) {
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
- Element.prototype._getAttributeName = function (name) {
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
- Element.prototype._updateDomListIndices = function () {
874
+ _updateDomListIndices() {
1003
875
  if (this._classList) {
1004
876
  this._classList._updateIndices();
1005
877
  }
1006
- };
1007
- return Element;
1008
- }(Node_1.default));
878
+ }
879
+ }
1009
880
  exports.default = Element;
1010
881
  //# sourceMappingURL=Element.js.map