@remote-dom/polyfill 1.5.0 → 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 +94 -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 +7 -3
  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 +15 -3
  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
@@ -3,26 +3,45 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const constants = require('./constants.cjs');
6
+ const names = require('./names.cjs');
6
7
  const ParentNode = require('./ParentNode.cjs');
7
8
  const NamedNodeMap = require('./NamedNodeMap.cjs');
8
9
  const Attr = require('./Attr.cjs');
9
10
  const serialization = require('./serialization.cjs');
11
+ const shared = require('./shared.cjs');
10
12
 
11
13
  class Element extends ParentNode.ParentNode {
12
- nodeType = (() => constants.NodeType.ELEMENT_NODE)();
13
- [constants.NS] = (() => constants.NamespaceURI.XHTML)();
14
+ nodeType = constants.NODE_TYPE_ELEMENT;
15
+ [constants.NS] = constants.HTML_NAMESPACE;
16
+ [constants.PREFIX] = null;
14
17
  get namespaceURI() {
15
18
  return this[constants.NS];
16
19
  }
20
+ get prefix() {
21
+ return this[constants.PREFIX];
22
+ }
23
+ get localName() {
24
+ const prefix = this[constants.PREFIX];
25
+ return prefix == null ? this[constants.NAME] : this[constants.NAME].slice(prefix.length + 1);
26
+ }
27
+ get nodeName() {
28
+ return this[constants.NS] === constants.HTML_NAMESPACE ? constants.asciiUppercase(this[constants.NAME]) : this[constants.NAME];
29
+ }
17
30
  get tagName() {
18
31
  return this.nodeName;
19
32
  }
33
+ get id() {
34
+ return this.getAttributeNS(null, 'id') ?? '';
35
+ }
36
+ set id(id) {
37
+ this.setAttribute('id', String(id));
38
+ }
20
39
  get slot() {
21
- return this.getAttribute('slot') ?? '';
40
+ return this.getAttributeNS(null, 'slot') ?? '';
22
41
  }
23
42
  set slot(slot) {
24
43
  const finalSlot = String(slot);
25
- if (this.getAttribute('slot') !== finalSlot) {
44
+ if (this.getAttributeNS(null, 'slot') !== finalSlot) {
26
45
  this.attributes.setNamedItem(new Attr.Attr('slot', finalSlot));
27
46
  }
28
47
  }
@@ -37,9 +56,15 @@ class Element extends ParentNode.ParentNode {
37
56
  getAttributeNames() {
38
57
  return [...this.attributes].map(attr => attr.name);
39
58
  }
59
+ getElementsByTagName(qualifiedName) {
60
+ return shared.getElementsByTagName(this, qualifiedName);
61
+ }
40
62
  get firstElementChild() {
41
63
  return this.children[0] ?? null;
42
64
  }
65
+ getElementsByClassName(classNames) {
66
+ return shared.getElementsByClassName(this, classNames);
67
+ }
43
68
  get lastElementChild() {
44
69
  return this.children[this.children.length - 1] ?? null;
45
70
  }
@@ -54,10 +79,43 @@ class Element extends ParentNode.ParentNode {
54
79
  return sib;
55
80
  }
56
81
  setAttribute(name, value) {
57
- this.attributes.setNamedItem(new Attr.Attr(name, String(value)));
82
+ const qualifiedName = String(name);
83
+ const normalizedValue = String(value);
84
+ names.validateAttributeLocalName(qualifiedName);
85
+ const normalizedName = this[constants.NS] === constants.HTML_NAMESPACE ? constants.asciiLowercase(qualifiedName) : qualifiedName;
86
+ const attribute = this.attributes.getNamedItemNS(null, normalizedName);
87
+ if (attribute) {
88
+ attribute.value = normalizedValue;
89
+ } else {
90
+ this.attributes.setNamedItem(new Attr.Attr(normalizedName, normalizedValue));
91
+ }
92
+ }
93
+ setAttributeNS(namespace, qualifiedName, value) {
94
+ const normalizedNamespace = names.normalizeNamespace(namespace);
95
+ const normalizedQualifiedName = String(qualifiedName);
96
+ const normalizedValue = String(value);
97
+ const name = names.validateAndExtractQualifiedName(normalizedNamespace, normalizedQualifiedName, 'attribute');
98
+ const attribute = this.attributes.getNamedItemNS(name.namespace, name.localName);
99
+ if (attribute) {
100
+ attribute.value = normalizedValue;
101
+ } else {
102
+ this.attributes.setNamedItemNS(new Attr.Attr(name.qualifiedName, normalizedValue, name.namespace));
103
+ }
58
104
  }
59
- setAttributeNS(namespace, name, value) {
60
- this.attributes.setNamedItemNS(new Attr.Attr(name, String(value), namespace));
105
+ toggleAttribute(name, force) {
106
+ const qualifiedName = String(name);
107
+ names.validateAttributeLocalName(qualifiedName);
108
+ const normalizedName = this[constants.NS] === constants.HTML_NAMESPACE ? constants.asciiLowercase(qualifiedName) : qualifiedName;
109
+ const attribute = this.attributes.getNamedItemNS(null, normalizedName);
110
+ const normalizedForce = force === undefined ? undefined : Boolean(force);
111
+ if (attribute == null) {
112
+ if (normalizedForce === false) return false;
113
+ this.attributes.setNamedItem(new Attr.Attr(normalizedName, ''));
114
+ return true;
115
+ }
116
+ if (normalizedForce === true) return true;
117
+ this.attributes.removeNamedItemNS(null, normalizedName);
118
+ return false;
61
119
  }
62
120
  getAttribute(name) {
63
121
  const attr = this.attributes.getNamedItem(name);
@@ -76,7 +134,9 @@ class Element extends ParentNode.ParentNode {
76
134
  return attr != null;
77
135
  }
78
136
  removeAttribute(name) {
79
- this.attributes.removeNamedItem(name);
137
+ const qualifiedName = String(name);
138
+ const normalizedName = this[constants.NS] === constants.HTML_NAMESPACE ? constants.asciiLowercase(qualifiedName) : qualifiedName;
139
+ this.attributes.removeNamedItemNS(null, normalizedName);
80
140
  }
81
141
  removeAttributeNS(namespace, name) {
82
142
  this.attributes.removeNamedItemNS(namespace, name);
@@ -4,27 +4,23 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const constants = require('./constants.cjs');
6
6
 
7
- let EventPhase = /*#__PURE__*/function (EventPhase) {
8
- EventPhase[EventPhase["NONE"] = 0] = "NONE";
9
- EventPhase[EventPhase["CAPTURING_PHASE"] = 1] = "CAPTURING_PHASE";
10
- EventPhase[EventPhase["AT_TARGET"] = 2] = "AT_TARGET";
11
- EventPhase[EventPhase["BUBBLING_PHASE"] = 3] = "BUBBLING_PHASE";
12
- return EventPhase;
13
- }({});
14
- const CAPTURE_MARKER = '@';
7
+ const EVENT_PHASE_NONE = 0;
8
+ const EVENT_PHASE_CAPTURING = 1;
9
+ const EVENT_PHASE_AT_TARGET = 2;
10
+ const EVENT_PHASE_BUBBLING = 3;
15
11
  const now = typeof performance === 'undefined' ? Date.now : performance.now.bind(performance);
16
12
  class Event {
17
- static NONE = (() => EventPhase.NONE)();
18
- static CAPTURING_PHASE = (() => EventPhase.CAPTURING_PHASE)();
19
- static AT_TARGET = (() => EventPhase.AT_TARGET)();
20
- static BUBBLING_PHASE = (() => EventPhase.BUBBLING_PHASE)();
13
+ static NONE = EVENT_PHASE_NONE;
14
+ static CAPTURING_PHASE = EVENT_PHASE_CAPTURING;
15
+ static AT_TARGET = EVENT_PHASE_AT_TARGET;
16
+ static BUBBLING_PHASE = EVENT_PHASE_BUBBLING;
21
17
 
22
- // NONE = EventPhase.NONE;
23
- // CAPTURING_PHASE = EventPhase.CAPTURING_PHASE;
24
- // AT_TARGET = EventPhase.AT_TARGET;
25
- // BUBBLING_PHASE = EventPhase.BUBBLING_PHASE;
18
+ // NONE = EVENT_PHASE_NONE;
19
+ // CAPTURING_PHASE = EVENT_PHASE_CAPTURING;
20
+ // AT_TARGET = EVENT_PHASE_AT_TARGET;
21
+ // BUBBLING_PHASE = EVENT_PHASE_BUBBLING;
26
22
 
27
- timeStamp = (() => now())();
23
+ timeStamp = now();
28
24
  target = null;
29
25
  currentTarget = null;
30
26
  srcElement = null;
@@ -33,11 +29,12 @@ class Event {
33
29
  composed = false;
34
30
  defaultPrevented = false;
35
31
  cancelBubble = false;
36
- eventPhase = 0;
32
+ eventPhase = EVENT_PHASE_NONE;
37
33
  // private inPassiveListener = false;
38
34
 
39
35
  [constants.PATH] = [];
40
36
  [constants.STOP_IMMEDIATE_PROPAGATION] = false;
37
+ [constants.DISPATCHING] = false;
41
38
  constructor(type, options) {
42
39
  this.type = type;
43
40
  Object.defineProperty(this, constants.IS_TRUSTED, {
@@ -54,7 +51,7 @@ class Event {
54
51
  return this[constants.IS_TRUSTED];
55
52
  }
56
53
  composedPath() {
57
- return this[constants.PATH];
54
+ return [...this[constants.PATH]];
58
55
  }
59
56
  stopPropagation() {
60
57
  this.cancelBubble = true;
@@ -64,13 +61,13 @@ class Event {
64
61
  this.cancelBubble = true;
65
62
  }
66
63
  preventDefault() {
67
- this.defaultPrevented = true;
64
+ if (this.cancelable) this.defaultPrevented = true;
68
65
  }
69
66
  set returnValue(value) {
70
- this.defaultPrevented = value;
67
+ if (!value) this.preventDefault();
71
68
  }
72
69
  get returnValue() {
73
- return this.defaultPrevented;
70
+ return !this.defaultPrevented;
74
71
  }
75
72
 
76
73
  /** @deprecated */
@@ -81,12 +78,15 @@ class Event {
81
78
  }
82
79
  }
83
80
  function fireEvent(event, currentTarget, phase) {
81
+ if (event.cancelBubble) return;
84
82
  const listeners = currentTarget[constants.LISTENERS];
85
- const list = listeners?.get(`${event.type}${phase === EventPhase.CAPTURING_PHASE ? CAPTURE_MARKER : ''}`);
83
+ const list = listeners?.get(event.type)?.[phase === EVENT_PHASE_CAPTURING ? 'capture' : 'bubble'];
86
84
  if (!list) return;
87
- for (const listener of list) {
88
- event.eventPhase = event.target === currentTarget ? EventPhase.AT_TARGET : phase;
85
+ for (const registration of [...list]) {
86
+ if (!list.has(registration) || registration.signal?.aborted) continue;
87
+ event.eventPhase = event.target === currentTarget ? EVENT_PHASE_AT_TARGET : phase;
89
88
  event.currentTarget = currentTarget;
89
+ const listener = registration.normalizedListener;
90
90
  try {
91
91
  if (typeof listener === 'object') {
92
92
  listener.handleEvent(event);
@@ -103,7 +103,9 @@ function thrower(error) {
103
103
  throw error;
104
104
  }
105
105
 
106
- exports.CAPTURE_MARKER = CAPTURE_MARKER;
106
+ exports.EVENT_PHASE_AT_TARGET = EVENT_PHASE_AT_TARGET;
107
+ exports.EVENT_PHASE_BUBBLING = EVENT_PHASE_BUBBLING;
108
+ exports.EVENT_PHASE_CAPTURING = EVENT_PHASE_CAPTURING;
109
+ exports.EVENT_PHASE_NONE = EVENT_PHASE_NONE;
107
110
  exports.Event = Event;
108
- exports.EventPhase = EventPhase;
109
111
  exports.fireEvent = fireEvent;
@@ -3,55 +3,88 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const constants = require('./constants.cjs');
6
+ const domException = require('./dom-exception.cjs');
6
7
  const Event = require('./Event.cjs');
7
8
 
8
- const ONCE_LISTENERS = Symbol('onceListeners');
9
+ const LISTENER_REGISTRATIONS = Symbol('listenerRegistrations');
9
10
  class EventTarget {
10
- [constants.LISTENERS] = (() => undefined)();
11
- [ONCE_LISTENERS] = (() => undefined)();
11
+ [constants.LISTENERS] = undefined;
12
+ [LISTENER_REGISTRATIONS] = undefined;
12
13
 
13
14
  /**
14
15
  * Property set by entities that extend this class that are part of the DOM tree.
15
16
  * @internal
16
17
  */
17
- [constants.OWNER_DOCUMENT] = (() => undefined)();
18
+ [constants.OWNER_DOCUMENT] = undefined;
18
19
  addEventListener(type, listener, options) {
19
20
  if (listener == null) return;
20
- const capture = options === true || options && options.capture === true;
21
+ const capture = options === true || typeof options === 'object' && options.capture === true;
21
22
  const once = typeof options === 'object' && options.once === true;
22
23
  const signal = typeof options === 'object' ? options.signal : undefined;
23
- const key = `${type}${capture ? Event.CAPTURE_MARKER : ''}`;
24
- let normalizedListener = listener;
25
- if (once) {
26
- normalizedListener = function normalizedListener(...args) {
27
- this.removeEventListener(type, listener, options);
28
- return typeof listener === 'object' ? listener.handleEvent(...args) : listener.call(this, ...args);
24
+ if (signal?.aborted) return;
25
+ const phase = listenerPhase(capture);
26
+ let registrations = this[LISTENER_REGISTRATIONS];
27
+ if (!registrations) {
28
+ registrations = new Map();
29
+ this[LISTENER_REGISTRATIONS] = registrations;
30
+ }
31
+ let registrationsForType = registrations.get(type);
32
+ if (!registrationsForType) {
33
+ registrationsForType = {};
34
+ registrations.set(type, registrationsForType);
35
+ }
36
+ let registrationsForPhase = registrationsForType[phase];
37
+ if (!registrationsForPhase) {
38
+ registrationsForPhase = new Map();
39
+ registrationsForType[phase] = registrationsForPhase;
40
+ }
41
+ if (registrationsForPhase.has(listener)) return;
42
+ const target = this;
43
+ const registration = {
44
+ type,
45
+ listener,
46
+ capture,
47
+ once,
48
+ normalizedListener: listener,
49
+ signal
50
+ };
51
+ if (once || signal) {
52
+ registration.normalizedListener = function normalizedListener(...args) {
53
+ if (registration.signal?.aborted) {
54
+ removeListenerRegistration(target, registration);
55
+ return;
56
+ }
57
+ if (registration.once) removeListenerRegistration(target, registration);
58
+ return typeof registration.listener === 'object' ? registration.listener.handleEvent(...args) : registration.listener.call(this, ...args);
29
59
  };
30
- let onceListeners = this[ONCE_LISTENERS];
31
- if (!onceListeners) {
32
- onceListeners = new WeakMap();
33
- this[ONCE_LISTENERS] = onceListeners;
34
- }
35
- onceListeners.set(listener, normalizedListener);
36
60
  }
37
61
  let listeners = this[constants.LISTENERS];
38
62
  if (!listeners) {
39
63
  listeners = new Map();
40
64
  this[constants.LISTENERS] = listeners;
41
65
  }
42
- let list = listeners.get(key);
66
+ let listenersForType = listeners.get(type);
67
+ if (!listenersForType) {
68
+ listenersForType = {};
69
+ listeners.set(type, listenersForType);
70
+ }
71
+ let list = listenersForType[phase];
43
72
  if (!list) {
44
73
  list = new Set();
45
- listeners.set(key, list);
74
+ listenersForType[phase] = list;
46
75
  }
47
- if (list.has(normalizedListener)) return;
48
- signal?.addEventListener('abort', () => {
49
- removeEventListener.call(this, type, listener, options);
50
- }, {
51
- once: true
52
- });
53
- list.add(normalizedListener);
54
- this[constants.OWNER_DOCUMENT]?.defaultView[constants.HOOKS].addEventListener?.(this, type, listener, options);
76
+ registrationsForPhase.set(listener, registration);
77
+ list.add(registration);
78
+ if (signal) {
79
+ const abortListener = () => {
80
+ removeListenerRegistration(target, registration);
81
+ };
82
+ registration.abortListener = abortListener;
83
+ signal.addEventListener('abort', abortListener, {
84
+ once: true
85
+ });
86
+ }
87
+ this[constants.OWNER_DOCUMENT]?.defaultView[constants.HOOKS_DISPATCH].addEventListener?.(this, type, listener, options);
55
88
  }
56
89
  removeEventListener(type, listener, options) {
57
90
  return removeEventListener.call(this, type, listener, options);
@@ -62,45 +95,82 @@ class EventTarget {
62
95
  // }
63
96
 
64
97
  dispatchEvent(event) {
65
- const path = [];
66
- // instanceof here is just to keep TypeScript happy
67
- let target = this;
68
- while (target != null) {
69
- path.push(target);
70
- target = target.parentNode;
98
+ if (event[constants.DISPATCHING]) {
99
+ throw domException.createDOMException(`Failed to execute 'dispatchEvent' on 'EventTarget': The event is already being dispatched.`, 'InvalidStateError');
71
100
  }
72
- // while (target instanceof Node && (target = target.parentNode)) {
73
- // path.push(target);
74
- // }
75
- event.target = this;
76
- event.srcElement = this;
77
- event[constants.PATH] = path;
78
- for (let i = path.length; i--;) {
79
- Event.fireEvent(event, path[i], Event.EventPhase.CAPTURING_PHASE);
80
- if (event.cancelBubble) return event.defaultPrevented;
81
- }
82
- const bubblePath = event.bubbles ? path : path.slice(0, 1);
83
- for (let i = 0; i < bubblePath.length; i++) {
84
- Event.fireEvent(event, bubblePath[i], Event.EventPhase.BUBBLING_PHASE);
85
- if (event.cancelBubble) return event.defaultPrevented;
101
+ event[constants.DISPATCHING] = true;
102
+ try {
103
+ const path = [];
104
+ // instanceof here is just to keep TypeScript happy
105
+ let target = this;
106
+ while (target != null) {
107
+ path.push(target);
108
+ target = target.parentNode;
109
+ }
110
+ // while (target instanceof Node && (target = target.parentNode)) {
111
+ // path.push(target);
112
+ // }
113
+ event.target = this;
114
+ event.srcElement = this;
115
+ event[constants.PATH] = path;
116
+ for (let i = path.length; i--;) {
117
+ Event.fireEvent(event, path[i], Event.EVENT_PHASE_CAPTURING);
118
+ if (event.cancelBubble) return !event.defaultPrevented;
119
+ }
120
+ const bubblePath = event.bubbles ? path : path.slice(0, 1);
121
+ for (let i = 0; i < bubblePath.length; i++) {
122
+ Event.fireEvent(event, bubblePath[i], Event.EVENT_PHASE_BUBBLING);
123
+ if (event.cancelBubble) return !event.defaultPrevented;
124
+ }
125
+ return !event.defaultPrevented;
126
+ } finally {
127
+ event[constants.DISPATCHING] = false;
128
+ event.cancelBubble = false;
129
+ event[constants.STOP_IMMEDIATE_PROPAGATION] = false;
130
+ event.eventPhase = Event.EVENT_PHASE_NONE;
131
+ event.currentTarget = null;
132
+ event[constants.PATH] = [];
86
133
  }
87
- return event.defaultPrevented;
88
134
  }
89
135
  }
90
136
  function removeEventListener(type, listener, options) {
91
137
  if (listener == null) return;
92
- const onceListeners = this[ONCE_LISTENERS];
93
- const normalizedListener = onceListeners?.get(listener) ?? listener;
94
- onceListeners?.delete(listener);
95
138
  const capture = options === true || options && options.capture === true;
96
- const key = `${type}${capture ? Event.CAPTURE_MARKER : ''}`;
97
- const list = this[constants.LISTENERS]?.get(key);
98
- if (list) {
99
- const deleted = list.delete(normalizedListener);
100
- if (deleted) {
101
- this[constants.OWNER_DOCUMENT]?.defaultView[constants.HOOKS].removeEventListener?.(this, type, listener, options);
102
- }
139
+ const phase = listenerPhase(Boolean(capture));
140
+ const registration = this[LISTENER_REGISTRATIONS]?.get(type)?.[phase]?.get(listener);
141
+ if (!registration) return;
142
+ removeListenerRegistration(this, registration);
143
+ }
144
+ function listenerPhase(capture) {
145
+ return capture ? 'capture' : 'bubble';
146
+ }
147
+ function removeListenerRegistration(target, registration) {
148
+ const phase = listenerPhase(registration.capture);
149
+ const registrations = target[LISTENER_REGISTRATIONS];
150
+ const registrationsForType = registrations?.get(registration.type);
151
+ if (!registrationsForType) return;
152
+ const registrationsForPhase = registrationsForType[phase];
153
+ if (!registrationsForPhase || registrationsForPhase.get(registration.listener) !== registration) {
154
+ return;
155
+ }
156
+ registrationsForPhase.delete(registration.listener);
157
+ if (registrationsForPhase.size === 0) delete registrationsForType[phase];
158
+ if (!registrationsForType.bubble && !registrationsForType.capture) {
159
+ registrations?.delete(registration.type);
160
+ }
161
+ if (registration.signal && registration.abortListener) {
162
+ registration.signal.removeEventListener('abort', registration.abortListener);
163
+ }
164
+ const listeners = target[constants.LISTENERS];
165
+ const listenersForType = listeners?.get(registration.type);
166
+ if (!listenersForType) return;
167
+ const list = listenersForType[phase];
168
+ if (!list?.delete(registration)) return;
169
+ if (list.size === 0) delete listenersForType[phase];
170
+ if (!listenersForType.bubble && !listenersForType.capture) {
171
+ listeners?.delete(registration.type);
103
172
  }
173
+ target[constants.OWNER_DOCUMENT]?.defaultView[constants.HOOKS_DISPATCH].removeEventListener?.(target, registration.type, registration.listener, registration.capture);
104
174
  }
105
175
 
106
176
  exports.EventTarget = EventTarget;
@@ -11,6 +11,7 @@ class HTMLTemplateElement extends Element.Element {
11
11
  let content = this[constants.CONTENT];
12
12
  if (!content) {
13
13
  content = this.ownerDocument.createDocumentFragment();
14
+ content[constants.HOST] = this;
14
15
  this[constants.CONTENT] = content;
15
16
  }
16
17
  return content;
@@ -2,8 +2,174 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
+ const NodeList = require('./NodeList.cjs');
6
+
7
+ let registrations;
8
+ let registrationCount = 0;
9
+ let attributeRegistrationCount = 0;
10
+ let characterDataRegistrationCount = 0;
11
+ let childListRegistrationCount = 0;
12
+
13
+ // Mutation sites read these live bindings before capturing old values or
14
+ // allocating record data. Keep them split so observing one mutation type does
15
+ // not add work to unrelated mutations.
16
+ /** @internal */
17
+ exports.attributeObserversActive = false;
18
+ /** @internal */
19
+ exports.characterDataObserversActive = false;
20
+ /** @internal */
21
+ exports.childListObserversActive = false;
5
22
  class MutationObserver {
6
- // stub implementation
23
+ #callback;
24
+ #records = [];
25
+ #targets = new Set();
26
+ #scheduled = false;
27
+ constructor(callback) {
28
+ if (typeof callback !== 'function') {
29
+ throw new TypeError('MutationObserver callback must be a function');
30
+ }
31
+ this.#callback = callback;
32
+ }
33
+ observe(target, options = {}) {
34
+ const normalizedOptions = normalizeOptions(options);
35
+ const currentRegistrations = registrations ??= new WeakMap();
36
+ let targetRegistrations = currentRegistrations.get(target);
37
+ if (targetRegistrations == null) {
38
+ targetRegistrations = new Map();
39
+ currentRegistrations.set(target, targetRegistrations);
40
+ }
41
+ const previousOptions = targetRegistrations.get(this);
42
+ if (previousOptions == null) {
43
+ registrationCount++;
44
+ } else {
45
+ updateRegistrationCounts(previousOptions, -1);
46
+ }
47
+ targetRegistrations.set(this, normalizedOptions);
48
+ updateRegistrationCounts(normalizedOptions, 1);
49
+ this.#targets.add(target);
50
+ }
51
+ disconnect() {
52
+ const currentRegistrations = registrations;
53
+ if (currentRegistrations == null) return;
54
+ for (const target of this.#targets) {
55
+ const targetRegistrations = currentRegistrations.get(target);
56
+ const options = targetRegistrations?.get(this);
57
+ if (options != null) {
58
+ targetRegistrations.delete(this);
59
+ registrationCount--;
60
+ updateRegistrationCounts(options, -1);
61
+ }
62
+ if (targetRegistrations?.size === 0) {
63
+ currentRegistrations.delete(target);
64
+ }
65
+ }
66
+ this.#targets.clear();
67
+ this.#records.length = 0;
68
+ if (registrationCount === 0) {
69
+ registrations = undefined;
70
+ }
71
+ }
72
+ takeRecords() {
73
+ return this.#records.splice(0);
74
+ }
75
+
76
+ /** @internal */
77
+ enqueue(record) {
78
+ this.#records.push(record);
79
+ if (this.#scheduled) return;
80
+ this.#scheduled = true;
81
+ queueMicrotask(() => {
82
+ this.#scheduled = false;
83
+ const records = this.takeRecords();
84
+ if (records.length > 0) {
85
+ this.#callback.call(this, records, this);
86
+ }
87
+ });
88
+ }
89
+ }
90
+
91
+ /** @internal */
92
+ function queueMutationRecord(init) {
93
+ const currentRegistrations = registrations;
94
+ if (currentRegistrations == null) return;
95
+ const interestedObservers = new Map();
96
+ let node = init.target;
97
+ while (node) {
98
+ const targetRegistrations = currentRegistrations.get(node);
99
+ if (targetRegistrations) {
100
+ for (const [observer, options] of targetRegistrations) {
101
+ if (node !== init.target && !options.subtree) continue;
102
+ let includeOldValue = false;
103
+ if (init.type === 'attributes') {
104
+ if (!options.attributes) continue;
105
+ if (options.attributeFilter && !options.attributeFilter.has(init.attributeName ?? '')) {
106
+ continue;
107
+ }
108
+ includeOldValue = options.attributeOldValue;
109
+ } else if (init.type === 'characterData') {
110
+ if (!options.characterData) continue;
111
+ includeOldValue = options.characterDataOldValue;
112
+ } else if (!options.childList) {
113
+ continue;
114
+ }
115
+ interestedObservers.set(observer, interestedObservers.get(observer) === true || includeOldValue);
116
+ }
117
+ }
118
+ node = node.parentNode;
119
+ }
120
+ for (const [observer, includeOldValue] of interestedObservers) {
121
+ observer.enqueue({
122
+ addedNodes: init.addedNodes ?? new NodeList.NodeList(),
123
+ attributeName: init.attributeName ?? null,
124
+ attributeNamespace: init.attributeNamespace ?? null,
125
+ nextSibling: init.nextSibling ?? null,
126
+ oldValue: includeOldValue ? init.oldValue ?? null : null,
127
+ previousSibling: init.previousSibling ?? null,
128
+ removedNodes: init.removedNodes ?? new NodeList.NodeList(),
129
+ target: init.target,
130
+ type: init.type
131
+ });
132
+ }
133
+ }
134
+
135
+ /** @internal */
136
+ function mutationNodeList(...nodes) {
137
+ const list = new NodeList.NodeList();
138
+ list.push(...nodes);
139
+ return list;
140
+ }
141
+ function normalizeOptions(options) {
142
+ if (options.attributes === false && (options.attributeOldValue || options.attributeFilter != null)) {
143
+ throw new TypeError('attributeOldValue and attributeFilter require attributes to be enabled');
144
+ }
145
+ if (options.characterData === false && options.characterDataOldValue) {
146
+ throw new TypeError('characterDataOldValue requires characterData to be enabled');
147
+ }
148
+ const attributes = options.attributes ?? (options.attributeOldValue === true || options.attributeFilter != null);
149
+ const characterData = options.characterData ?? options.characterDataOldValue === true;
150
+ const childList = options.childList === true;
151
+ if (!attributes && !characterData && !childList) {
152
+ throw new TypeError('MutationObserver options must enable childList, attributes, or characterData');
153
+ }
154
+ return {
155
+ attributes,
156
+ attributeFilter: options.attributeFilter == null ? undefined : new Set(options.attributeFilter.map(String)),
157
+ attributeOldValue: options.attributeOldValue === true,
158
+ characterData,
159
+ characterDataOldValue: options.characterDataOldValue === true,
160
+ childList,
161
+ subtree: options.subtree === true
162
+ };
163
+ }
164
+ function updateRegistrationCounts(options, delta) {
165
+ if (options.attributes) attributeRegistrationCount += delta;
166
+ if (options.characterData) characterDataRegistrationCount += delta;
167
+ if (options.childList) childListRegistrationCount += delta;
168
+ exports.attributeObserversActive = attributeRegistrationCount > 0;
169
+ exports.characterDataObserversActive = characterDataRegistrationCount > 0;
170
+ exports.childListObserversActive = childListRegistrationCount > 0;
7
171
  }
8
172
 
9
173
  exports.MutationObserver = MutationObserver;
174
+ exports.mutationNodeList = mutationNodeList;
175
+ exports.queueMutationRecord = queueMutationRecord;