@remote-dom/polyfill 1.5.1 → 1.6.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.
Files changed (304) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +51 -3
  3. package/build/cjs/Attr.cjs +33 -4
  4. package/build/cjs/CharacterData.cjs +10 -0
  5. package/build/cjs/ChildNode.cjs +79 -13
  6. package/build/cjs/Comment.cjs +1 -1
  7. package/build/cjs/CustomElementRegistry.cjs +27 -2
  8. package/build/cjs/CustomEvent.cjs +2 -2
  9. package/build/cjs/Document.cjs +56 -32
  10. package/build/cjs/DocumentFragment.cjs +6 -2
  11. package/build/cjs/Element.cjs +68 -8
  12. package/build/cjs/Event.cjs +29 -27
  13. package/build/cjs/EventTarget.cjs +128 -58
  14. package/build/cjs/HTMLTemplateElement.cjs +1 -0
  15. package/build/cjs/MutationObserver.cjs +167 -1
  16. package/build/cjs/NamedNodeMap.cjs +82 -45
  17. package/build/cjs/Node.cjs +47 -11
  18. package/build/cjs/NodeList.cjs +9 -1
  19. package/build/cjs/ParentNode.cjs +319 -77
  20. package/build/cjs/SVGElement.cjs +1 -1
  21. package/build/cjs/Text.cjs +1 -1
  22. package/build/cjs/Window.cjs +131 -38
  23. package/build/cjs/attribute-reactions.cjs +20 -0
  24. package/build/cjs/constants.cjs +48 -24
  25. package/build/cjs/custom-element-reactions.cjs +52 -0
  26. package/build/cjs/dom-exception.cjs +15 -0
  27. package/build/cjs/hook-effects.cjs +51 -0
  28. package/build/cjs/names.cjs +61 -0
  29. package/build/cjs/selectors.cjs +213 -122
  30. package/build/cjs/serialization.cjs +168 -65
  31. package/build/cjs/shared.cjs +177 -28
  32. package/build/esm/Attr.mjs +34 -5
  33. package/build/esm/CharacterData.mjs +10 -0
  34. package/build/esm/ChildNode.mjs +76 -15
  35. package/build/esm/Comment.mjs +2 -2
  36. package/build/esm/CustomElementRegistry.mjs +27 -2
  37. package/build/esm/CustomEvent.mjs +2 -2
  38. package/build/esm/Document.mjs +60 -35
  39. package/build/esm/DocumentFragment.mjs +7 -3
  40. package/build/esm/Element.mjs +69 -9
  41. package/build/esm/Event.mjs +27 -27
  42. package/build/esm/EventTarget.mjs +130 -60
  43. package/build/esm/HTMLTemplateElement.mjs +2 -1
  44. package/build/esm/MutationObserver.mjs +166 -2
  45. package/build/esm/NamedNodeMap.mjs +83 -46
  46. package/build/esm/Node.mjs +48 -12
  47. package/build/esm/NodeList.mjs +9 -1
  48. package/build/esm/ParentNode.mjs +322 -81
  49. package/build/esm/SVGElement.mjs +2 -2
  50. package/build/esm/Text.mjs +2 -2
  51. package/build/esm/Window.mjs +132 -39
  52. package/build/esm/attribute-reactions.mjs +16 -0
  53. package/build/esm/constants.mjs +28 -23
  54. package/build/esm/custom-element-reactions.mjs +47 -0
  55. package/build/esm/dom-exception.mjs +11 -0
  56. package/build/esm/hook-effects.mjs +46 -0
  57. package/build/esm/names.mjs +54 -0
  58. package/build/esm/selectors.mjs +202 -124
  59. package/build/esm/serialization.mjs +169 -66
  60. package/build/esm/shared.mjs +173 -30
  61. package/build/esnext/Attr.esnext +45 -5
  62. package/build/esnext/CharacterData.esnext +10 -0
  63. package/build/esnext/ChildNode.esnext +84 -15
  64. package/build/esnext/Comment.esnext +2 -2
  65. package/build/esnext/CustomElementRegistry.esnext +42 -0
  66. package/build/esnext/CustomEvent.esnext +2 -2
  67. package/build/esnext/Document.esnext +69 -32
  68. package/build/esnext/DocumentFragment.esnext +6 -2
  69. package/build/esnext/Element.esnext +78 -9
  70. package/build/esnext/Event.esnext +36 -37
  71. package/build/esnext/EventTarget.esnext +133 -61
  72. package/build/esnext/HTMLTemplateElement.esnext +3 -1
  73. package/build/esnext/MutationObserver.esnext +163 -2
  74. package/build/esnext/NamedNodeMap.esnext +110 -42
  75. package/build/esnext/Node.esnext +50 -12
  76. package/build/esnext/NodeList.esnext +1 -1
  77. package/build/esnext/ParentNode.esnext +352 -79
  78. package/build/esnext/SVGElement.esnext +2 -2
  79. package/build/esnext/Text.esnext +2 -2
  80. package/build/esnext/Window.esnext +120 -16
  81. package/build/esnext/attribute-reactions.esnext +21 -0
  82. package/build/esnext/constants.esnext +34 -21
  83. package/build/esnext/custom-element-reactions.esnext +49 -0
  84. package/build/esnext/dom-exception.esnext +11 -0
  85. package/build/esnext/hook-effects.esnext +46 -0
  86. package/build/esnext/names.esnext +61 -0
  87. package/build/esnext/selectors.esnext +202 -100
  88. package/build/esnext/serialization.esnext +171 -48
  89. package/build/esnext/shared.esnext +181 -34
  90. package/build/tsconfig.tsbuildinfo +1 -1
  91. package/build/typescript/Attr.d.ts +6 -4
  92. package/build/typescript/Attr.d.ts.map +1 -1
  93. package/build/typescript/CharacterData.d.ts.map +1 -1
  94. package/build/typescript/ChildNode.d.ts +5 -0
  95. package/build/typescript/ChildNode.d.ts.map +1 -1
  96. package/build/typescript/ClipboardEvent.d.ts.map +1 -1
  97. package/build/typescript/Comment.d.ts +2 -2
  98. package/build/typescript/Comment.d.ts.map +1 -1
  99. package/build/typescript/CustomElementRegistry.d.ts +1 -0
  100. package/build/typescript/CustomElementRegistry.d.ts.map +1 -1
  101. package/build/typescript/CustomEvent.d.ts.map +1 -1
  102. package/build/typescript/Document.d.ts +10 -5
  103. package/build/typescript/Document.d.ts.map +1 -1
  104. package/build/typescript/DocumentFragment.d.ts +2 -1
  105. package/build/typescript/DocumentFragment.d.ts.map +1 -1
  106. package/build/typescript/Element.d.ts +16 -7
  107. package/build/typescript/Element.d.ts.map +1 -1
  108. package/build/typescript/ErrorEvent.d.ts.map +1 -1
  109. package/build/typescript/Event.d.ts +9 -10
  110. package/build/typescript/Event.d.ts.map +1 -1
  111. package/build/typescript/EventTarget.d.ts +20 -3
  112. package/build/typescript/EventTarget.d.ts.map +1 -1
  113. package/build/typescript/FocusEvent.d.ts.map +1 -1
  114. package/build/typescript/HTMLTemplateElement.d.ts.map +1 -1
  115. package/build/typescript/MutationObserver.d.ts +42 -0
  116. package/build/typescript/MutationObserver.d.ts.map +1 -1
  117. package/build/typescript/NamedNodeMap.d.ts +5 -3
  118. package/build/typescript/NamedNodeMap.d.ts.map +1 -1
  119. package/build/typescript/Node.d.ts +4 -3
  120. package/build/typescript/Node.d.ts.map +1 -1
  121. package/build/typescript/NodeList.d.ts +3 -2
  122. package/build/typescript/NodeList.d.ts.map +1 -1
  123. package/build/typescript/ParentNode.d.ts +29 -10
  124. package/build/typescript/ParentNode.d.ts.map +1 -1
  125. package/build/typescript/PromiseRejectionEvent.d.ts.map +1 -1
  126. package/build/typescript/SVGElement.d.ts +1 -1
  127. package/build/typescript/SVGElement.d.ts.map +1 -1
  128. package/build/typescript/Text.d.ts +1 -1
  129. package/build/typescript/Text.d.ts.map +1 -1
  130. package/build/typescript/ToggleEvent.d.ts.map +1 -1
  131. package/build/typescript/Window.d.ts +5 -1
  132. package/build/typescript/Window.d.ts.map +1 -1
  133. package/build/typescript/attribute-reactions.d.ts +4 -0
  134. package/build/typescript/attribute-reactions.d.ts.map +1 -0
  135. package/build/typescript/constants.d.ts +27 -18
  136. package/build/typescript/constants.d.ts.map +1 -1
  137. package/build/typescript/custom-element-reactions.d.ts +6 -0
  138. package/build/typescript/custom-element-reactions.d.ts.map +1 -0
  139. package/build/typescript/dom-exception.d.ts +2 -0
  140. package/build/typescript/dom-exception.d.ts.map +1 -0
  141. package/build/typescript/extensions.d.ts +4 -0
  142. package/build/typescript/extensions.d.ts.map +1 -0
  143. package/build/typescript/hook-effects.d.ts +6 -0
  144. package/build/typescript/hook-effects.d.ts.map +1 -0
  145. package/build/typescript/hooks.d.ts +3 -3
  146. package/build/typescript/hooks.d.ts.map +1 -1
  147. package/build/typescript/index.d.ts +1 -0
  148. package/build/typescript/index.d.ts.map +1 -1
  149. package/build/typescript/names.d.ts +11 -0
  150. package/build/typescript/names.d.ts.map +1 -0
  151. package/build/typescript/selectors.d.ts +21 -22
  152. package/build/typescript/selectors.d.ts.map +1 -1
  153. package/build/typescript/serialization.d.ts.map +1 -1
  154. package/build/typescript/shared.d.ts +10 -0
  155. package/build/typescript/shared.d.ts.map +1 -1
  156. package/build/typescript/tests/ChildNode.test.d.ts +2 -0
  157. package/build/typescript/tests/ChildNode.test.d.ts.map +1 -0
  158. package/build/typescript/tests/MutationObserver.test.d.ts +2 -0
  159. package/build/typescript/tests/MutationObserver.test.d.ts.map +1 -0
  160. package/build/typescript/tests/adopt-inserted-subtrees.test.d.ts +2 -0
  161. package/build/typescript/tests/adopt-inserted-subtrees.test.d.ts.map +1 -0
  162. package/build/typescript/tests/attr-mutation.test.d.ts +2 -0
  163. package/build/typescript/tests/attr-mutation.test.d.ts.map +1 -0
  164. package/build/typescript/tests/child-node-before-after.test.d.ts +2 -0
  165. package/build/typescript/tests/child-node-before-after.test.d.ts.map +1 -0
  166. package/build/typescript/tests/child-node-replace-with.test.d.ts +2 -0
  167. package/build/typescript/tests/child-node-replace-with.test.d.ts.map +1 -0
  168. package/build/typescript/tests/clone-import-namespaces.test.d.ts +2 -0
  169. package/build/typescript/tests/clone-import-namespaces.test.d.ts.map +1 -0
  170. package/build/typescript/tests/constants.test.d.ts +2 -0
  171. package/build/typescript/tests/constants.test.d.ts.map +1 -0
  172. package/build/typescript/tests/create-element-namespaces.test.d.ts +2 -0
  173. package/build/typescript/tests/create-element-namespaces.test.d.ts.map +1 -0
  174. package/build/typescript/tests/create-text-node.test.d.ts +2 -0
  175. package/build/typescript/tests/create-text-node.test.d.ts.map +1 -0
  176. package/build/typescript/tests/custom-element-reactions.test.d.ts +2 -0
  177. package/build/typescript/tests/custom-element-reactions.test.d.ts.map +1 -0
  178. package/build/typescript/tests/custom-element-registry.test.d.ts +2 -0
  179. package/build/typescript/tests/custom-element-registry.test.d.ts.map +1 -0
  180. package/build/typescript/tests/custom-event.test.d.ts +2 -0
  181. package/build/typescript/tests/custom-event.test.d.ts.map +1 -0
  182. package/build/typescript/tests/document-clone-import-contract.test.d.ts +2 -0
  183. package/build/typescript/tests/document-clone-import-contract.test.d.ts.map +1 -0
  184. package/build/typescript/tests/document.test.d.ts +2 -0
  185. package/build/typescript/tests/document.test.d.ts.map +1 -0
  186. package/build/typescript/tests/dom-mutation-selector-errors.test.d.ts +2 -0
  187. package/build/typescript/tests/dom-mutation-selector-errors.test.d.ts.map +1 -0
  188. package/build/typescript/tests/event-dispatch.test.d.ts +2 -0
  189. package/build/typescript/tests/event-dispatch.test.d.ts.map +1 -0
  190. package/build/typescript/tests/event-target.test.d.ts +2 -0
  191. package/build/typescript/tests/event-target.test.d.ts.map +1 -0
  192. package/build/typescript/tests/event.test.d.ts +2 -0
  193. package/build/typescript/tests/event.test.d.ts.map +1 -0
  194. package/build/typescript/tests/extensions.test.d.ts +2 -0
  195. package/build/typescript/tests/extensions.test.d.ts.map +1 -0
  196. package/build/typescript/tests/get-elements-by-tag-name.test.d.ts +2 -0
  197. package/build/typescript/tests/get-elements-by-tag-name.test.d.ts.map +1 -0
  198. package/build/typescript/tests/getElementsByClassName.test.d.ts +2 -0
  199. package/build/typescript/tests/getElementsByClassName.test.d.ts.map +1 -0
  200. package/build/typescript/tests/hooks.test.d.ts +2 -0
  201. package/build/typescript/tests/hooks.test.d.ts.map +1 -0
  202. package/build/typescript/tests/inner-html-parsing.test.d.ts +2 -0
  203. package/build/typescript/tests/inner-html-parsing.test.d.ts.map +1 -0
  204. package/build/typescript/tests/is-default-namespace.test.d.ts +2 -0
  205. package/build/typescript/tests/is-default-namespace.test.d.ts.map +1 -0
  206. package/build/typescript/tests/name-and-namespace-normalization.test.d.ts +2 -0
  207. package/build/typescript/tests/name-and-namespace-normalization.test.d.ts.map +1 -0
  208. package/build/typescript/tests/named-node-map.test.d.ts +2 -0
  209. package/build/typescript/tests/named-node-map.test.d.ts.map +1 -0
  210. package/build/typescript/tests/namespaced-attribute-reactions.test.d.ts +2 -0
  211. package/build/typescript/tests/namespaced-attribute-reactions.test.d.ts.map +1 -0
  212. package/build/typescript/tests/node.test.d.ts +2 -0
  213. package/build/typescript/tests/node.test.d.ts.map +1 -0
  214. package/build/typescript/tests/parent-node-mutation-return-values.test.d.ts +2 -0
  215. package/build/typescript/tests/parent-node-mutation-return-values.test.d.ts.map +1 -0
  216. package/build/typescript/tests/parent-node-mutation-validation.test.d.ts +2 -0
  217. package/build/typescript/tests/parent-node-mutation-validation.test.d.ts.map +1 -0
  218. package/build/typescript/tests/parent-node.test.d.ts +2 -0
  219. package/build/typescript/tests/parent-node.test.d.ts.map +1 -0
  220. package/build/typescript/tests/serialization-template.test.d.ts +2 -0
  221. package/build/typescript/tests/serialization-template.test.d.ts.map +1 -0
  222. package/build/typescript/tests/slot-attribute.test.d.ts +2 -0
  223. package/build/typescript/tests/slot-attribute.test.d.ts.map +1 -0
  224. package/build/typescript/tests/text-content.test.d.ts +2 -0
  225. package/build/typescript/tests/text-content.test.d.ts.map +1 -0
  226. package/build/typescript/tests/toggle-attribute.test.d.ts +2 -0
  227. package/build/typescript/tests/toggle-attribute.test.d.ts.map +1 -0
  228. package/build/typescript/tests/wide-tree-traversal.test.d.ts +2 -0
  229. package/build/typescript/tests/wide-tree-traversal.test.d.ts.map +1 -0
  230. package/build/typescript/tests/window-set-global.test.d.ts +2 -0
  231. package/build/typescript/tests/window-set-global.test.d.ts.map +1 -0
  232. package/package.json +1 -1
  233. package/source/Attr.ts +60 -8
  234. package/source/CharacterData.ts +13 -0
  235. package/source/ChildNode.ts +107 -14
  236. package/source/Comment.ts +2 -2
  237. package/source/CustomElementRegistry.ts +56 -0
  238. package/source/CustomEvent.ts +2 -2
  239. package/source/Document.ts +104 -38
  240. package/source/DocumentFragment.ts +12 -2
  241. package/source/Element.ts +129 -14
  242. package/source/Event.ts +34 -32
  243. package/source/EventTarget.ts +203 -79
  244. package/source/HTMLTemplateElement.ts +2 -1
  245. package/source/MutationObserver.ts +279 -1
  246. package/source/NamedNodeMap.ts +141 -60
  247. package/source/Node.ts +70 -14
  248. package/source/NodeList.ts +13 -3
  249. package/source/ParentNode.ts +500 -88
  250. package/source/SVGElement.ts +2 -2
  251. package/source/Text.ts +2 -2
  252. package/source/Window.ts +156 -17
  253. package/source/attribute-reactions.ts +32 -0
  254. package/source/constants.ts +40 -17
  255. package/source/custom-element-reactions.ts +64 -0
  256. package/source/dom-exception.ts +14 -0
  257. package/source/extensions.ts +4 -0
  258. package/source/hook-effects.ts +56 -0
  259. package/source/hooks.ts +11 -3
  260. package/source/index.ts +1 -0
  261. package/source/names.ts +94 -0
  262. package/source/selectors.ts +301 -138
  263. package/source/serialization.ts +224 -66
  264. package/source/shared.ts +269 -40
  265. package/source/tests/ChildNode.test.ts +178 -0
  266. package/source/tests/MutationObserver.test.ts +303 -0
  267. package/source/tests/adopt-inserted-subtrees.test.ts +584 -0
  268. package/source/tests/attr-mutation.test.ts +112 -0
  269. package/source/tests/child-node-before-after.test.ts +421 -0
  270. package/source/tests/child-node-replace-with.test.ts +251 -0
  271. package/source/tests/clone-import-namespaces.test.ts +365 -0
  272. package/source/tests/constants.test.ts +46 -0
  273. package/source/tests/create-element-namespaces.test.ts +142 -0
  274. package/source/tests/create-text-node.test.ts +38 -0
  275. package/source/tests/custom-element-reactions.test.ts +600 -0
  276. package/source/tests/custom-element-registry.test.ts +137 -0
  277. package/source/tests/custom-event.test.ts +26 -0
  278. package/source/tests/document-clone-import-contract.test.ts +77 -0
  279. package/source/tests/document.test.ts +122 -0
  280. package/source/tests/dom-mutation-selector-errors.test.ts +484 -0
  281. package/source/tests/event-dispatch.test.ts +270 -0
  282. package/source/tests/event-target.test.ts +208 -0
  283. package/source/tests/event.test.ts +98 -0
  284. package/source/tests/extensions.test.ts +159 -0
  285. package/source/tests/get-elements-by-tag-name.test.ts +79 -0
  286. package/source/tests/getElementsByClassName.test.ts +109 -0
  287. package/source/tests/hooks.test.ts +43 -0
  288. package/source/tests/inner-html-parsing.test.ts +461 -0
  289. package/source/tests/is-default-namespace.test.ts +111 -0
  290. package/source/tests/name-and-namespace-normalization.test.ts +319 -0
  291. package/source/tests/named-node-map.test.ts +122 -0
  292. package/source/tests/namespaced-attribute-reactions.test.ts +141 -0
  293. package/source/tests/node.test.ts +56 -0
  294. package/source/tests/parent-node-mutation-return-values.test.ts +63 -0
  295. package/source/tests/parent-node-mutation-validation.test.ts +362 -0
  296. package/source/tests/parent-node.test.ts +169 -0
  297. package/source/tests/selectors.test.ts +533 -22
  298. package/source/tests/serialization-template.test.ts +232 -0
  299. package/source/tests/slot-attribute.test.ts +133 -0
  300. package/source/tests/text-content.test.ts +440 -0
  301. package/source/tests/toggle-attribute.test.ts +113 -0
  302. package/source/tests/wide-tree-traversal.test.ts +699 -0
  303. package/source/tests/window-set-global.test.ts +321 -0
  304. package/tsconfig.json +1 -1
@@ -1,6 +1,12 @@
1
- import { NEXT } from './constants.esnext';
1
+ import { PARENT, HOST, NEXT, PREV } from './constants.esnext';
2
+ import { performWithCustomElementReactions } from './custom-element-reactions.esnext';
3
+ import { performHookEffects } from './hook-effects.esnext';
4
+ import { createDOMException } from './dom-exception.esnext';
2
5
  import { Node } from './Node.esnext';
3
6
 
7
+ const INSERT_NODE = Symbol("insertNode");
8
+ const PREFLIGHT_INSERTIONS = Symbol("preflightInsertions");
9
+ const REPLACE_NODE = Symbol("replaceNode");
4
10
  class ChildNode extends Node {
5
11
  remove() {
6
12
  const parent = this.parentNode;
@@ -8,35 +14,98 @@ class ChildNode extends Node {
8
14
  parent.removeChild(this);
9
15
  }
10
16
  replaceWith(...nodes) {
17
+ const staged = stageNodes(nodes);
11
18
  const parent = this.parentNode;
12
19
  if (!parent) return;
13
- const node = toNode(parent, nodes[0]);
14
- const next = node[NEXT];
15
- parent.replaceChild(this, node);
16
- for (let i = 1; i < nodes.length; i++) {
17
- parent.insertBefore(toNode(parent, nodes[i]), next);
18
- }
20
+ return performChildNodeMutation((hookEffects) => {
21
+ validateInsertionNodes(parent, staged);
22
+ let next = this[NEXT];
23
+ while (next && staged.includes(next)) next = next[NEXT];
24
+ const replacement = convertNodesIntoNode(parent, staged, hookEffects);
25
+ if (this.parentNode === parent) {
26
+ parent[REPLACE_NODE](replacement, this, hookEffects);
27
+ } else {
28
+ parent[INSERT_NODE](replacement, next, hookEffects);
29
+ }
30
+ });
19
31
  }
20
32
  before(...nodes) {
33
+ const staged = stageNodes(nodes);
21
34
  const parent = this.parentNode;
22
35
  if (!parent) return;
23
- for (const node of nodes) {
24
- parent.insertBefore(toNode(parent, node), this);
25
- }
36
+ return performChildNodeMutation((hookEffects) => {
37
+ validateInsertionNodes(parent, staged);
38
+ let previous = this[PREV];
39
+ while (previous && staged.includes(previous)) previous = previous[PREV];
40
+ const node = convertNodesIntoNode(parent, staged, hookEffects);
41
+ parent[INSERT_NODE](
42
+ node,
43
+ previous ? previous[NEXT] : parent.firstChild,
44
+ hookEffects
45
+ );
46
+ });
26
47
  }
27
48
  after(...nodes) {
49
+ const staged = stageNodes(nodes);
28
50
  const parent = this.parentNode;
29
51
  if (!parent) return;
30
- const next = this[NEXT];
31
- for (const node of nodes) {
32
- parent.insertBefore(toNode(parent, node), next);
33
- }
52
+ return performChildNodeMutation((hookEffects) => {
53
+ validateInsertionNodes(parent, staged);
54
+ let next = this[NEXT];
55
+ while (next && staged.includes(next)) next = next[NEXT];
56
+ const node = convertNodesIntoNode(parent, staged, hookEffects);
57
+ parent[INSERT_NODE](node, next, hookEffects);
58
+ });
34
59
  }
35
60
  }
61
+ function performChildNodeMutation(mutation) {
62
+ return performWithCustomElementReactions(() => {
63
+ const hookEffects = [];
64
+ try {
65
+ mutation(hookEffects);
66
+ } catch (error) {
67
+ try {
68
+ performHookEffects(hookEffects);
69
+ } catch {
70
+ }
71
+ throw error;
72
+ }
73
+ performHookEffects(hookEffects);
74
+ });
75
+ }
76
+ function stageNodes(nodes) {
77
+ return nodes.map((node) => node instanceof Node ? node : String(node));
78
+ }
36
79
  function toNode(parent, node) {
37
80
  if (node instanceof Node) return node;
38
81
  const ownerDocument = parent.ownerDocument;
39
82
  return ownerDocument.createTextNode(String(node));
40
83
  }
84
+ function validateInsertionNodes(parent, nodes) {
85
+ for (const node of nodes) {
86
+ if (!(node instanceof Node)) continue;
87
+ let ancestor = parent;
88
+ while (ancestor) {
89
+ if (ancestor === node) {
90
+ throw createDOMException(
91
+ "Cannot insert a node into itself or one of its descendants",
92
+ "HierarchyRequestError"
93
+ );
94
+ }
95
+ ancestor = ancestor[PARENT] ?? ancestor[HOST];
96
+ }
97
+ }
98
+ }
99
+ function convertNodesIntoNode(parent, nodes, hookEffects) {
100
+ const convertedNodes = [];
101
+ for (const node of nodes) convertedNodes.push(toNode(parent, node));
102
+ if (convertedNodes.length === 1) return convertedNodes[0];
103
+ const fragment = parent.ownerDocument.createDocumentFragment();
104
+ fragment[PREFLIGHT_INSERTIONS](convertedNodes);
105
+ for (const node of convertedNodes) {
106
+ fragment[INSERT_NODE](node, null, hookEffects);
107
+ }
108
+ return fragment;
109
+ }
41
110
 
42
- export { ChildNode, toNode };
111
+ export { ChildNode, INSERT_NODE, PREFLIGHT_INSERTIONS, REPLACE_NODE, stageNodes, toNode, validateInsertionNodes };
@@ -1,8 +1,8 @@
1
- import { NAME } from './constants.esnext';
1
+ import { NODE_TYPE_COMMENT, NAME } from './constants.esnext';
2
2
  import { CharacterData } from './CharacterData.esnext';
3
3
 
4
4
  class Comment extends CharacterData {
5
- nodeType = 8;
5
+ nodeType = NODE_TYPE_COMMENT;
6
6
  [NAME] = "#comment";
7
7
  }
8
8
 
@@ -1,7 +1,44 @@
1
+ import { createDOMException } from './dom-exception.esnext';
2
+
3
+ const VALID_CUSTOM_ELEMENT_NAME = /^[a-z][^A-Z\u0000\t\n\f\r />]*-[^A-Z\u0000\t\n\f\r />]*$/u;
4
+ const RESERVED_CUSTOM_ELEMENT_NAMES = /* @__PURE__ */ new Set([
5
+ "annotation-xml",
6
+ "color-profile",
7
+ "font-face",
8
+ "font-face-src",
9
+ "font-face-uri",
10
+ "font-face-format",
11
+ "font-face-name",
12
+ "missing-glyph"
13
+ ]);
14
+ function isValidCustomElementName(name) {
15
+ return VALID_CUSTOM_ELEMENT_NAME.test(name) && !RESERVED_CUSTOM_ELEMENT_NAMES.has(name);
16
+ }
17
+ function createInvalidCustomElementNameError(name) {
18
+ return createDOMException(
19
+ `Invalid custom element name: "${name}"`,
20
+ "SyntaxError"
21
+ );
22
+ }
1
23
  class CustomElementRegistryImplementation {
2
24
  registry = /* @__PURE__ */ new Map();
3
25
  listenersByName = /* @__PURE__ */ new Map();
4
26
  define(name, Constructor, _options) {
27
+ if (!isValidCustomElementName(name)) {
28
+ throw createInvalidCustomElementNameError(name);
29
+ }
30
+ if (this.registry.has(name)) {
31
+ throw createDOMException(
32
+ `A custom element named "${name}" has already been defined`,
33
+ "NotSupportedError"
34
+ );
35
+ }
36
+ if (this.getName(Constructor) != null) {
37
+ throw createDOMException(
38
+ "This constructor has already been registered in this custom element registry",
39
+ "NotSupportedError"
40
+ );
41
+ }
5
42
  this.registry.set(name, Constructor);
6
43
  const listeners = this.listenersByName.get(name);
7
44
  if (listeners == null) return;
@@ -20,6 +57,9 @@ class CustomElementRegistryImplementation {
20
57
  return null;
21
58
  }
22
59
  whenDefined(name) {
60
+ if (!isValidCustomElementName(name)) {
61
+ return Promise.reject(createInvalidCustomElementNameError(name));
62
+ }
23
63
  const Constructor = this.registry.get(name);
24
64
  if (Constructor != null) return Promise.resolve(Constructor);
25
65
  let listeners = this.listenersByName.get(name);
@@ -33,6 +73,8 @@ class CustomElementRegistryImplementation {
33
73
  }
34
74
  upgrade(_root) {
35
75
  }
76
+ initialize(_root) {
77
+ }
36
78
  }
37
79
 
38
80
  export { CustomElementRegistryImplementation };
@@ -9,7 +9,7 @@ class CustomEvent extends Event {
9
9
  detail;
10
10
  constructor(type, eventInitDict) {
11
11
  super(type, eventInitDict);
12
- this.detail = eventInitDict?.detail;
12
+ this.detail = eventInitDict?.detail ?? null;
13
13
  }
14
14
  /**
15
15
  * Returns any custom data event was created with. Typically used for synthetic events.
@@ -18,7 +18,7 @@ class CustomEvent extends Event {
18
18
  */
19
19
  initCustomEvent(type, bubbles, cancelable, detail) {
20
20
  super.initEvent(type, bubbles, cancelable);
21
- this.detail = detail;
21
+ this.detail = detail ?? null;
22
22
  }
23
23
  }
24
24
 
@@ -1,19 +1,22 @@
1
- import { NodeType, NAME, IS_CONNECTED, OWNER_DOCUMENT, HOOKS, NamespaceURI, NS } from './constants.esnext';
1
+ import { NODE_TYPE_DOCUMENT, NAME, IS_CONNECTED, OWNER_DOCUMENT, HTML_NAMESPACE, asciiLowercase, CREATE_ELEMENT, HOOKS, PREFIX, NS, SVG_NAMESPACE } from './constants.esnext';
2
+ import { validateElementLocalName, validateAndExtractQualifiedName } from './names.esnext';
2
3
  import { Event } from './Event.esnext';
3
- import { ParentNode } from './ParentNode.esnext';
4
+ import { ParentNode, removeChildForAdoption } from './ParentNode.esnext';
4
5
  import { Element } from './Element.esnext';
5
6
  import { SVGElement } from './SVGElement.esnext';
6
7
  import { Text } from './Text.esnext';
7
8
  import { Comment } from './Comment.esnext';
8
9
  import { DocumentFragment } from './DocumentFragment.esnext';
9
10
  import { HTMLTemplateElement } from './HTMLTemplateElement.esnext';
10
- import { cloneNode, isParentNode } from './shared.esnext';
11
+ import { getElementsByClassName, getElementById, getElementsByTagName, cloneNode, collectAdoptionSnapshot, adoptNodes } from './shared.esnext';
11
12
  import { HTMLBodyElement } from './HTMLBodyElement.esnext';
12
13
  import { HTMLHeadElement } from './HTMLHeadElement.esnext';
13
14
  import { HTMLHtmlElement } from './HTMLHtmlElement.esnext';
15
+ import { performWithCustomElementReactions } from './custom-element-reactions.esnext';
16
+ import { createDOMException } from './dom-exception.esnext';
14
17
 
15
18
  class Document extends ParentNode {
16
- nodeType = NodeType.DOCUMENT_NODE;
19
+ nodeType = NODE_TYPE_DOCUMENT;
17
20
  [NAME] = "#document";
18
21
  body;
19
22
  head;
@@ -31,15 +34,39 @@ class Document extends ParentNode {
31
34
  this.documentElement.appendChild(this.head);
32
35
  this.documentElement.appendChild(this.body);
33
36
  }
37
+ get textContent() {
38
+ return null;
39
+ }
40
+ set textContent(data) {
41
+ }
42
+ getElementsByClassName(classNames) {
43
+ return getElementsByClassName(this, classNames);
44
+ }
34
45
  createElement(localName) {
35
- return createElement(this, localName);
46
+ const name = String(localName);
47
+ validateElementLocalName(name);
48
+ return createElement(this, asciiLowercase(name));
49
+ }
50
+ createElementNS(namespaceURI, qualifiedName) {
51
+ const name = validateAndExtractQualifiedName(
52
+ namespaceURI,
53
+ qualifiedName,
54
+ "element"
55
+ );
56
+ return createElement(
57
+ this,
58
+ name.qualifiedName,
59
+ name.namespace,
60
+ name.prefix,
61
+ name.localName
62
+ );
36
63
  }
37
- createElementNS(namespaceURI, localName) {
38
- return createElement(this, localName, namespaceURI);
64
+ [CREATE_ELEMENT](qualifiedName, namespace, prefix, localName) {
65
+ return createElement(this, qualifiedName, namespace, prefix, localName);
39
66
  }
40
67
  createTextNode(data) {
41
68
  const text = createNode(new Text(data), this);
42
- this[HOOKS].createText?.(text, String(data));
69
+ this[HOOKS].createText?.(text, text.data);
43
70
  return text;
44
71
  }
45
72
  createComment(data) {
@@ -51,14 +78,30 @@ class Document extends ParentNode {
51
78
  createEvent() {
52
79
  return new Event("");
53
80
  }
81
+ getElementById(elementId) {
82
+ return getElementById(this, elementId);
83
+ }
84
+ getElementsByTagName(qualifiedName) {
85
+ return getElementsByTagName(this, qualifiedName);
86
+ }
54
87
  importNode(node, deep) {
88
+ if (node.nodeType === NODE_TYPE_DOCUMENT) {
89
+ throw createDOMException(
90
+ "Cannot import a document node",
91
+ "NotSupportedError"
92
+ );
93
+ }
55
94
  return cloneNode(node, deep, this);
56
95
  }
57
96
  adoptNode(node) {
58
97
  if (node[OWNER_DOCUMENT] === this) return node;
59
- node.parentNode?.removeChild(node);
60
- adoptNode(node, this);
61
- return node;
98
+ const adoption = collectAdoptionSnapshot(node);
99
+ return performWithCustomElementReactions(() => {
100
+ const parent = node.parentNode;
101
+ if (parent) removeChildForAdoption(parent, node, adoption, this);
102
+ else adoptNodes(adoption.nodes, this);
103
+ return node;
104
+ });
62
105
  }
63
106
  }
64
107
  function createNode(node, ownerDocument) {
@@ -69,35 +112,29 @@ function createNode(node, ownerDocument) {
69
112
  });
70
113
  return node;
71
114
  }
72
- function createElement(ownerDocument, name, namespace) {
115
+ function createElement(ownerDocument, qualifiedName, namespace = HTML_NAMESPACE, prefix = null, localName = qualifiedName) {
73
116
  let element;
74
- const lowerName = String(name).toLowerCase();
75
- if (namespace === NamespaceURI.SVG) {
117
+ if (namespace === SVG_NAMESPACE) {
76
118
  element = new SVGElement();
77
- } else if (lowerName === "template") {
119
+ } else if (namespace === HTML_NAMESPACE && localName === "template") {
78
120
  element = new HTMLTemplateElement();
79
- } else {
80
- const CustomElement = ownerDocument.defaultView.customElements.get(name);
121
+ } else if (namespace === HTML_NAMESPACE) {
122
+ const CustomElement = ownerDocument.defaultView.customElements.get(localName);
81
123
  element = CustomElement ? new CustomElement() : new Element();
124
+ } else {
125
+ element = new Element();
82
126
  }
83
- return setupElement(element, ownerDocument, name, namespace);
127
+ return setupElement(element, ownerDocument, qualifiedName, namespace, prefix);
84
128
  }
85
- function setupElement(element, ownerDocument, name, namespace) {
129
+ function setupElement(element, ownerDocument, qualifiedName, namespace = HTML_NAMESPACE, prefix = null) {
86
130
  createNode(element, ownerDocument);
87
- Object.defineProperty(element, NAME, { value: name });
88
- if (namespace) {
89
- Object.defineProperty(element, NS, { value: namespace });
90
- }
131
+ Object.defineProperties(element, {
132
+ [NAME]: { value: qualifiedName },
133
+ [NS]: { value: namespace },
134
+ [PREFIX]: { value: prefix }
135
+ });
91
136
  ownerDocument[HOOKS].createElement?.(element, namespace);
92
137
  return element;
93
138
  }
94
- function adoptNode(node, document) {
95
- node[OWNER_DOCUMENT] = document;
96
- if (isParentNode(node)) {
97
- for (const child of node.childNodes) {
98
- adoptNode(child, document);
99
- }
100
- }
101
- }
102
139
 
103
- export { Document, adoptNode, createElement, createNode, setupElement };
140
+ export { Document, createElement, createNode, setupElement };
@@ -1,10 +1,14 @@
1
- import { NodeType, NAME, OWNER_DOCUMENT } from './constants.esnext';
1
+ import { NODE_TYPE_DOCUMENT_FRAGMENT, NAME, OWNER_DOCUMENT } from './constants.esnext';
2
2
  import { ParentNode } from './ParentNode.esnext';
3
+ import { getElementById } from './shared.esnext';
3
4
 
4
5
  class DocumentFragment extends ParentNode {
5
- nodeType = NodeType.DOCUMENT_FRAGMENT_NODE;
6
+ nodeType = NODE_TYPE_DOCUMENT_FRAGMENT;
6
7
  [NAME] = "#document-fragment";
7
8
  [OWNER_DOCUMENT] = typeof window !== "undefined" ? window.document : null;
9
+ getElementById(elementId) {
10
+ return getElementById(this, elementId);
11
+ }
8
12
  }
9
13
 
10
14
  export { DocumentFragment };
@@ -1,26 +1,45 @@
1
- import { NodeType, NS, NamespaceURI, ATTRIBUTES } from './constants.esnext';
1
+ import { NODE_TYPE_ELEMENT, HTML_NAMESPACE, NS, PREFIX, NAME, asciiUppercase, ATTRIBUTES, asciiLowercase } from './constants.esnext';
2
+ import { validateAttributeLocalName, validateAndExtractQualifiedName, normalizeNamespace } from './names.esnext';
2
3
  import { ParentNode } from './ParentNode.esnext';
3
4
  import { NamedNodeMap } from './NamedNodeMap.esnext';
4
5
  import { Attr } from './Attr.esnext';
5
6
  import { serializeNode, serializeChildren, parseHtml } from './serialization.esnext';
7
+ import { getElementsByTagName, getElementsByClassName } from './shared.esnext';
6
8
 
7
9
  class Element extends ParentNode {
8
10
  static observedAttributes;
9
- nodeType = NodeType.ELEMENT_NODE;
10
- [NS] = NamespaceURI.XHTML;
11
+ nodeType = NODE_TYPE_ELEMENT;
12
+ [NS] = HTML_NAMESPACE;
13
+ [PREFIX] = null;
11
14
  get namespaceURI() {
12
15
  return this[NS];
13
16
  }
17
+ get prefix() {
18
+ return this[PREFIX];
19
+ }
20
+ get localName() {
21
+ const prefix = this[PREFIX];
22
+ return prefix == null ? this[NAME] : this[NAME].slice(prefix.length + 1);
23
+ }
24
+ get nodeName() {
25
+ return this[NS] === HTML_NAMESPACE ? asciiUppercase(this[NAME]) : this[NAME];
26
+ }
14
27
  get tagName() {
15
28
  return this.nodeName;
16
29
  }
17
30
  [ATTRIBUTES];
31
+ get id() {
32
+ return this.getAttributeNS(null, "id") ?? "";
33
+ }
34
+ set id(id) {
35
+ this.setAttribute("id", String(id));
36
+ }
18
37
  get slot() {
19
- return this.getAttribute("slot") ?? "";
38
+ return this.getAttributeNS(null, "slot") ?? "";
20
39
  }
21
40
  set slot(slot) {
22
41
  const finalSlot = String(slot);
23
- if (this.getAttribute("slot") !== finalSlot) {
42
+ if (this.getAttributeNS(null, "slot") !== finalSlot) {
24
43
  this.attributes.setNamedItem(new Attr("slot", finalSlot));
25
44
  }
26
45
  }
@@ -35,9 +54,15 @@ class Element extends ParentNode {
35
54
  getAttributeNames() {
36
55
  return [...this.attributes].map((attr) => attr.name);
37
56
  }
57
+ getElementsByTagName(qualifiedName) {
58
+ return getElementsByTagName(this, qualifiedName);
59
+ }
38
60
  get firstElementChild() {
39
61
  return this.children[0] ?? null;
40
62
  }
63
+ getElementsByClassName(classNames) {
64
+ return getElementsByClassName(this, classNames);
65
+ }
41
66
  get lastElementChild() {
42
67
  return this.children[this.children.length - 1] ?? null;
43
68
  }
@@ -52,10 +77,52 @@ class Element extends ParentNode {
52
77
  return sib;
53
78
  }
54
79
  setAttribute(name, value) {
55
- this.attributes.setNamedItem(new Attr(name, String(value)));
80
+ const qualifiedName = String(name);
81
+ const normalizedValue = String(value);
82
+ validateAttributeLocalName(qualifiedName);
83
+ const normalizedName = this[NS] === HTML_NAMESPACE ? asciiLowercase(qualifiedName) : qualifiedName;
84
+ const attribute = this.attributes.getNamedItemNS(null, normalizedName);
85
+ if (attribute) {
86
+ attribute.value = normalizedValue;
87
+ } else {
88
+ this.attributes.setNamedItem(new Attr(normalizedName, normalizedValue));
89
+ }
90
+ }
91
+ setAttributeNS(namespace, qualifiedName, value) {
92
+ const normalizedNamespace = normalizeNamespace(namespace);
93
+ const normalizedQualifiedName = String(qualifiedName);
94
+ const normalizedValue = String(value);
95
+ const name = validateAndExtractQualifiedName(
96
+ normalizedNamespace,
97
+ normalizedQualifiedName,
98
+ "attribute"
99
+ );
100
+ const attribute = this.attributes.getNamedItemNS(
101
+ name.namespace,
102
+ name.localName
103
+ );
104
+ if (attribute) {
105
+ attribute.value = normalizedValue;
106
+ } else {
107
+ this.attributes.setNamedItemNS(
108
+ new Attr(name.qualifiedName, normalizedValue, name.namespace)
109
+ );
110
+ }
56
111
  }
57
- setAttributeNS(namespace, name, value) {
58
- this.attributes.setNamedItemNS(new Attr(name, String(value), namespace));
112
+ toggleAttribute(name, force) {
113
+ const qualifiedName = String(name);
114
+ validateAttributeLocalName(qualifiedName);
115
+ const normalizedName = this[NS] === HTML_NAMESPACE ? asciiLowercase(qualifiedName) : qualifiedName;
116
+ const attribute = this.attributes.getNamedItemNS(null, normalizedName);
117
+ const normalizedForce = force === void 0 ? void 0 : Boolean(force);
118
+ if (attribute == null) {
119
+ if (normalizedForce === false) return false;
120
+ this.attributes.setNamedItem(new Attr(normalizedName, ""));
121
+ return true;
122
+ }
123
+ if (normalizedForce === true) return true;
124
+ this.attributes.removeNamedItemNS(null, normalizedName);
125
+ return false;
59
126
  }
60
127
  getAttribute(name) {
61
128
  const attr = this.attributes.getNamedItem(name);
@@ -74,7 +141,9 @@ class Element extends ParentNode {
74
141
  return attr != null;
75
142
  }
76
143
  removeAttribute(name) {
77
- this.attributes.removeNamedItem(name);
144
+ const qualifiedName = String(name);
145
+ const normalizedName = this[NS] === HTML_NAMESPACE ? asciiLowercase(qualifiedName) : qualifiedName;
146
+ this.attributes.removeNamedItemNS(null, normalizedName);
78
147
  }
79
148
  removeAttributeNS(namespace, name) {
80
149
  this.attributes.removeNamedItemNS(namespace, name);
@@ -1,32 +1,20 @@
1
- import { IS_TRUSTED, PATH, STOP_IMMEDIATE_PROPAGATION, LISTENERS } from './constants.esnext';
1
+ import { PATH, IS_TRUSTED, STOP_IMMEDIATE_PROPAGATION, DISPATCHING, LISTENERS } from './constants.esnext';
2
2
 
3
- var EventPhase = /* @__PURE__ */ ((EventPhase2) => {
4
- EventPhase2[EventPhase2["NONE"] = 0] = "NONE";
5
- EventPhase2[EventPhase2["CAPTURING_PHASE"] = 1] = "CAPTURING_PHASE";
6
- EventPhase2[EventPhase2["AT_TARGET"] = 2] = "AT_TARGET";
7
- EventPhase2[EventPhase2["BUBBLING_PHASE"] = 3] = "BUBBLING_PHASE";
8
- return EventPhase2;
9
- })(EventPhase || {});
10
- const CAPTURE_MARKER = "@";
3
+ const EVENT_PHASE_NONE = 0;
4
+ const EVENT_PHASE_CAPTURING = 1;
5
+ const EVENT_PHASE_AT_TARGET = 2;
6
+ const EVENT_PHASE_BUBBLING = 3;
11
7
  const now = typeof performance === "undefined" ? Date.now : performance.now.bind(performance);
12
8
  class Event {
13
- constructor(type, options) {
14
- this.type = type;
15
- Object.defineProperty(this, IS_TRUSTED, { writable: true, value: false });
16
- if (options) {
17
- if (options.bubbles) this.bubbles = options.bubbles;
18
- if (options.cancelable) this.cancelable = options.cancelable;
19
- if (options.composed) this.composed = options.composed;
20
- }
21
- }
22
- static NONE = 0 /* NONE */;
23
- static CAPTURING_PHASE = 1 /* CAPTURING_PHASE */;
24
- static AT_TARGET = 2 /* AT_TARGET */;
25
- static BUBBLING_PHASE = 3 /* BUBBLING_PHASE */;
26
- // NONE = EventPhase.NONE;
27
- // CAPTURING_PHASE = EventPhase.CAPTURING_PHASE;
28
- // AT_TARGET = EventPhase.AT_TARGET;
29
- // BUBBLING_PHASE = EventPhase.BUBBLING_PHASE;
9
+ static NONE = EVENT_PHASE_NONE;
10
+ static CAPTURING_PHASE = EVENT_PHASE_CAPTURING;
11
+ static AT_TARGET = EVENT_PHASE_AT_TARGET;
12
+ static BUBBLING_PHASE = EVENT_PHASE_BUBBLING;
13
+ // NONE = EVENT_PHASE_NONE;
14
+ // CAPTURING_PHASE = EVENT_PHASE_CAPTURING;
15
+ // AT_TARGET = EVENT_PHASE_AT_TARGET;
16
+ // BUBBLING_PHASE = EVENT_PHASE_BUBBLING;
17
+ type;
30
18
  timeStamp = now();
31
19
  target = null;
32
20
  currentTarget = null;
@@ -36,17 +24,27 @@ class Event {
36
24
  composed = false;
37
25
  defaultPrevented = false;
38
26
  cancelBubble = false;
39
- eventPhase = 0;
27
+ eventPhase = EVENT_PHASE_NONE;
40
28
  // private inPassiveListener = false;
41
29
  data;
42
30
  [PATH] = [];
43
31
  [IS_TRUSTED];
44
32
  [STOP_IMMEDIATE_PROPAGATION] = false;
33
+ [DISPATCHING] = false;
34
+ constructor(type, options) {
35
+ this.type = type;
36
+ Object.defineProperty(this, IS_TRUSTED, { writable: true, value: false });
37
+ if (options) {
38
+ if (options.bubbles) this.bubbles = options.bubbles;
39
+ if (options.cancelable) this.cancelable = options.cancelable;
40
+ if (options.composed) this.composed = options.composed;
41
+ }
42
+ }
45
43
  get isTrusted() {
46
44
  return this[IS_TRUSTED];
47
45
  }
48
46
  composedPath() {
49
- return this[PATH];
47
+ return [...this[PATH]];
50
48
  }
51
49
  stopPropagation() {
52
50
  this.cancelBubble = true;
@@ -56,13 +54,13 @@ class Event {
56
54
  this.cancelBubble = true;
57
55
  }
58
56
  preventDefault() {
59
- this.defaultPrevented = true;
57
+ if (this.cancelable) this.defaultPrevented = true;
60
58
  }
61
59
  set returnValue(value) {
62
- this.defaultPrevented = value;
60
+ if (!value) this.preventDefault();
63
61
  }
64
62
  get returnValue() {
65
- return this.defaultPrevented;
63
+ return !this.defaultPrevented;
66
64
  }
67
65
  /** @deprecated */
68
66
  initEvent(type, bubbles, cancelable) {
@@ -72,14 +70,15 @@ class Event {
72
70
  }
73
71
  }
74
72
  function fireEvent(event, currentTarget, phase) {
73
+ if (event.cancelBubble) return;
75
74
  const listeners = currentTarget[LISTENERS];
76
- const list = listeners?.get(
77
- `${event.type}${phase === 1 /* CAPTURING_PHASE */ ? CAPTURE_MARKER : ""}`
78
- );
75
+ const list = listeners?.get(event.type)?.[phase === EVENT_PHASE_CAPTURING ? "capture" : "bubble"];
79
76
  if (!list) return;
80
- for (const listener of list) {
81
- event.eventPhase = event.target === currentTarget ? 2 /* AT_TARGET */ : phase;
77
+ for (const registration of [...list]) {
78
+ if (!list.has(registration) || registration.signal?.aborted) continue;
79
+ event.eventPhase = event.target === currentTarget ? EVENT_PHASE_AT_TARGET : phase;
82
80
  event.currentTarget = currentTarget;
81
+ const listener = registration.normalizedListener;
83
82
  try {
84
83
  if (typeof listener === "object") {
85
84
  listener.handleEvent(event);
@@ -96,4 +95,4 @@ function thrower(error) {
96
95
  throw error;
97
96
  }
98
97
 
99
- export { CAPTURE_MARKER, Event, EventPhase, fireEvent };
98
+ export { EVENT_PHASE_AT_TARGET, EVENT_PHASE_BUBBLING, EVENT_PHASE_CAPTURING, EVENT_PHASE_NONE, Event, fireEvent };