@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.
- package/CHANGELOG.md +88 -0
- package/README.md +51 -3
- package/build/cjs/Attr.cjs +33 -4
- package/build/cjs/CharacterData.cjs +10 -0
- package/build/cjs/ChildNode.cjs +79 -13
- package/build/cjs/Comment.cjs +1 -1
- package/build/cjs/CustomElementRegistry.cjs +27 -2
- package/build/cjs/CustomEvent.cjs +2 -2
- package/build/cjs/Document.cjs +56 -32
- package/build/cjs/DocumentFragment.cjs +6 -2
- package/build/cjs/Element.cjs +68 -8
- package/build/cjs/Event.cjs +29 -27
- package/build/cjs/EventTarget.cjs +128 -58
- package/build/cjs/HTMLTemplateElement.cjs +1 -0
- package/build/cjs/MutationObserver.cjs +167 -1
- package/build/cjs/NamedNodeMap.cjs +82 -45
- package/build/cjs/Node.cjs +47 -11
- package/build/cjs/NodeList.cjs +9 -1
- package/build/cjs/ParentNode.cjs +319 -77
- package/build/cjs/SVGElement.cjs +1 -1
- package/build/cjs/Text.cjs +1 -1
- package/build/cjs/Window.cjs +131 -38
- package/build/cjs/attribute-reactions.cjs +20 -0
- package/build/cjs/constants.cjs +48 -24
- package/build/cjs/custom-element-reactions.cjs +52 -0
- package/build/cjs/dom-exception.cjs +15 -0
- package/build/cjs/hook-effects.cjs +51 -0
- package/build/cjs/names.cjs +61 -0
- package/build/cjs/selectors.cjs +213 -122
- package/build/cjs/serialization.cjs +168 -65
- package/build/cjs/shared.cjs +177 -28
- package/build/esm/Attr.mjs +34 -5
- package/build/esm/CharacterData.mjs +10 -0
- package/build/esm/ChildNode.mjs +76 -15
- package/build/esm/Comment.mjs +2 -2
- package/build/esm/CustomElementRegistry.mjs +27 -2
- package/build/esm/CustomEvent.mjs +2 -2
- package/build/esm/Document.mjs +60 -35
- package/build/esm/DocumentFragment.mjs +7 -3
- package/build/esm/Element.mjs +69 -9
- package/build/esm/Event.mjs +27 -27
- package/build/esm/EventTarget.mjs +130 -60
- package/build/esm/HTMLTemplateElement.mjs +2 -1
- package/build/esm/MutationObserver.mjs +166 -2
- package/build/esm/NamedNodeMap.mjs +83 -46
- package/build/esm/Node.mjs +48 -12
- package/build/esm/NodeList.mjs +9 -1
- package/build/esm/ParentNode.mjs +322 -81
- package/build/esm/SVGElement.mjs +2 -2
- package/build/esm/Text.mjs +2 -2
- package/build/esm/Window.mjs +132 -39
- package/build/esm/attribute-reactions.mjs +16 -0
- package/build/esm/constants.mjs +28 -23
- package/build/esm/custom-element-reactions.mjs +47 -0
- package/build/esm/dom-exception.mjs +11 -0
- package/build/esm/hook-effects.mjs +46 -0
- package/build/esm/names.mjs +54 -0
- package/build/esm/selectors.mjs +202 -124
- package/build/esm/serialization.mjs +169 -66
- package/build/esm/shared.mjs +173 -30
- package/build/esnext/Attr.esnext +45 -5
- package/build/esnext/CharacterData.esnext +10 -0
- package/build/esnext/ChildNode.esnext +84 -15
- package/build/esnext/Comment.esnext +2 -2
- package/build/esnext/CustomElementRegistry.esnext +42 -0
- package/build/esnext/CustomEvent.esnext +2 -2
- package/build/esnext/Document.esnext +69 -32
- package/build/esnext/DocumentFragment.esnext +6 -2
- package/build/esnext/Element.esnext +78 -9
- package/build/esnext/Event.esnext +36 -37
- package/build/esnext/EventTarget.esnext +133 -61
- package/build/esnext/HTMLTemplateElement.esnext +3 -1
- package/build/esnext/MutationObserver.esnext +163 -2
- package/build/esnext/NamedNodeMap.esnext +110 -42
- package/build/esnext/Node.esnext +50 -12
- package/build/esnext/NodeList.esnext +1 -1
- package/build/esnext/ParentNode.esnext +352 -79
- package/build/esnext/SVGElement.esnext +2 -2
- package/build/esnext/Text.esnext +2 -2
- package/build/esnext/Window.esnext +120 -16
- package/build/esnext/attribute-reactions.esnext +21 -0
- package/build/esnext/constants.esnext +34 -21
- package/build/esnext/custom-element-reactions.esnext +49 -0
- package/build/esnext/dom-exception.esnext +11 -0
- package/build/esnext/hook-effects.esnext +46 -0
- package/build/esnext/names.esnext +61 -0
- package/build/esnext/selectors.esnext +202 -100
- package/build/esnext/serialization.esnext +171 -48
- package/build/esnext/shared.esnext +181 -34
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/Attr.d.ts +6 -4
- package/build/typescript/Attr.d.ts.map +1 -1
- package/build/typescript/CharacterData.d.ts.map +1 -1
- package/build/typescript/ChildNode.d.ts +5 -0
- package/build/typescript/ChildNode.d.ts.map +1 -1
- package/build/typescript/ClipboardEvent.d.ts.map +1 -1
- package/build/typescript/Comment.d.ts +2 -2
- package/build/typescript/Comment.d.ts.map +1 -1
- package/build/typescript/CustomElementRegistry.d.ts +1 -0
- package/build/typescript/CustomElementRegistry.d.ts.map +1 -1
- package/build/typescript/CustomEvent.d.ts.map +1 -1
- package/build/typescript/Document.d.ts +10 -5
- package/build/typescript/Document.d.ts.map +1 -1
- package/build/typescript/DocumentFragment.d.ts +2 -1
- package/build/typescript/DocumentFragment.d.ts.map +1 -1
- package/build/typescript/Element.d.ts +16 -7
- package/build/typescript/Element.d.ts.map +1 -1
- package/build/typescript/ErrorEvent.d.ts.map +1 -1
- package/build/typescript/Event.d.ts +9 -10
- package/build/typescript/Event.d.ts.map +1 -1
- package/build/typescript/EventTarget.d.ts +20 -3
- package/build/typescript/EventTarget.d.ts.map +1 -1
- package/build/typescript/FocusEvent.d.ts.map +1 -1
- package/build/typescript/HTMLTemplateElement.d.ts.map +1 -1
- package/build/typescript/MutationObserver.d.ts +42 -0
- package/build/typescript/MutationObserver.d.ts.map +1 -1
- package/build/typescript/NamedNodeMap.d.ts +5 -3
- package/build/typescript/NamedNodeMap.d.ts.map +1 -1
- package/build/typescript/Node.d.ts +4 -3
- package/build/typescript/Node.d.ts.map +1 -1
- package/build/typescript/NodeList.d.ts +3 -2
- package/build/typescript/NodeList.d.ts.map +1 -1
- package/build/typescript/ParentNode.d.ts +29 -10
- package/build/typescript/ParentNode.d.ts.map +1 -1
- package/build/typescript/PromiseRejectionEvent.d.ts.map +1 -1
- package/build/typescript/SVGElement.d.ts +1 -1
- package/build/typescript/SVGElement.d.ts.map +1 -1
- package/build/typescript/Text.d.ts +1 -1
- package/build/typescript/Text.d.ts.map +1 -1
- package/build/typescript/ToggleEvent.d.ts.map +1 -1
- package/build/typescript/Window.d.ts +5 -1
- package/build/typescript/Window.d.ts.map +1 -1
- package/build/typescript/attribute-reactions.d.ts +4 -0
- package/build/typescript/attribute-reactions.d.ts.map +1 -0
- package/build/typescript/constants.d.ts +27 -18
- package/build/typescript/constants.d.ts.map +1 -1
- package/build/typescript/custom-element-reactions.d.ts +6 -0
- package/build/typescript/custom-element-reactions.d.ts.map +1 -0
- package/build/typescript/dom-exception.d.ts +2 -0
- package/build/typescript/dom-exception.d.ts.map +1 -0
- package/build/typescript/extensions.d.ts +4 -0
- package/build/typescript/extensions.d.ts.map +1 -0
- package/build/typescript/hook-effects.d.ts +6 -0
- package/build/typescript/hook-effects.d.ts.map +1 -0
- package/build/typescript/hooks.d.ts +3 -3
- package/build/typescript/hooks.d.ts.map +1 -1
- package/build/typescript/index.d.ts +1 -0
- package/build/typescript/index.d.ts.map +1 -1
- package/build/typescript/names.d.ts +11 -0
- package/build/typescript/names.d.ts.map +1 -0
- package/build/typescript/selectors.d.ts +21 -22
- package/build/typescript/selectors.d.ts.map +1 -1
- package/build/typescript/serialization.d.ts.map +1 -1
- package/build/typescript/shared.d.ts +10 -0
- package/build/typescript/shared.d.ts.map +1 -1
- package/build/typescript/tests/ChildNode.test.d.ts +2 -0
- package/build/typescript/tests/ChildNode.test.d.ts.map +1 -0
- package/build/typescript/tests/MutationObserver.test.d.ts +2 -0
- package/build/typescript/tests/MutationObserver.test.d.ts.map +1 -0
- package/build/typescript/tests/adopt-inserted-subtrees.test.d.ts +2 -0
- package/build/typescript/tests/adopt-inserted-subtrees.test.d.ts.map +1 -0
- package/build/typescript/tests/attr-mutation.test.d.ts +2 -0
- package/build/typescript/tests/attr-mutation.test.d.ts.map +1 -0
- package/build/typescript/tests/child-node-before-after.test.d.ts +2 -0
- package/build/typescript/tests/child-node-before-after.test.d.ts.map +1 -0
- package/build/typescript/tests/child-node-replace-with.test.d.ts +2 -0
- package/build/typescript/tests/child-node-replace-with.test.d.ts.map +1 -0
- package/build/typescript/tests/clone-import-namespaces.test.d.ts +2 -0
- package/build/typescript/tests/clone-import-namespaces.test.d.ts.map +1 -0
- package/build/typescript/tests/constants.test.d.ts +2 -0
- package/build/typescript/tests/constants.test.d.ts.map +1 -0
- package/build/typescript/tests/create-element-namespaces.test.d.ts +2 -0
- package/build/typescript/tests/create-element-namespaces.test.d.ts.map +1 -0
- package/build/typescript/tests/create-text-node.test.d.ts +2 -0
- package/build/typescript/tests/create-text-node.test.d.ts.map +1 -0
- package/build/typescript/tests/custom-element-reactions.test.d.ts +2 -0
- package/build/typescript/tests/custom-element-reactions.test.d.ts.map +1 -0
- package/build/typescript/tests/custom-element-registry.test.d.ts +2 -0
- package/build/typescript/tests/custom-element-registry.test.d.ts.map +1 -0
- package/build/typescript/tests/custom-event.test.d.ts +2 -0
- package/build/typescript/tests/custom-event.test.d.ts.map +1 -0
- package/build/typescript/tests/document-clone-import-contract.test.d.ts +2 -0
- package/build/typescript/tests/document-clone-import-contract.test.d.ts.map +1 -0
- package/build/typescript/tests/document.test.d.ts +2 -0
- package/build/typescript/tests/document.test.d.ts.map +1 -0
- package/build/typescript/tests/dom-mutation-selector-errors.test.d.ts +2 -0
- package/build/typescript/tests/dom-mutation-selector-errors.test.d.ts.map +1 -0
- package/build/typescript/tests/event-dispatch.test.d.ts +2 -0
- package/build/typescript/tests/event-dispatch.test.d.ts.map +1 -0
- package/build/typescript/tests/event-target.test.d.ts +2 -0
- package/build/typescript/tests/event-target.test.d.ts.map +1 -0
- package/build/typescript/tests/event.test.d.ts +2 -0
- package/build/typescript/tests/event.test.d.ts.map +1 -0
- package/build/typescript/tests/extensions.test.d.ts +2 -0
- package/build/typescript/tests/extensions.test.d.ts.map +1 -0
- package/build/typescript/tests/get-elements-by-tag-name.test.d.ts +2 -0
- package/build/typescript/tests/get-elements-by-tag-name.test.d.ts.map +1 -0
- package/build/typescript/tests/getElementsByClassName.test.d.ts +2 -0
- package/build/typescript/tests/getElementsByClassName.test.d.ts.map +1 -0
- package/build/typescript/tests/hooks.test.d.ts +2 -0
- package/build/typescript/tests/hooks.test.d.ts.map +1 -0
- package/build/typescript/tests/inner-html-parsing.test.d.ts +2 -0
- package/build/typescript/tests/inner-html-parsing.test.d.ts.map +1 -0
- package/build/typescript/tests/is-default-namespace.test.d.ts +2 -0
- package/build/typescript/tests/is-default-namespace.test.d.ts.map +1 -0
- package/build/typescript/tests/name-and-namespace-normalization.test.d.ts +2 -0
- package/build/typescript/tests/name-and-namespace-normalization.test.d.ts.map +1 -0
- package/build/typescript/tests/named-node-map.test.d.ts +2 -0
- package/build/typescript/tests/named-node-map.test.d.ts.map +1 -0
- package/build/typescript/tests/namespaced-attribute-reactions.test.d.ts +2 -0
- package/build/typescript/tests/namespaced-attribute-reactions.test.d.ts.map +1 -0
- package/build/typescript/tests/node.test.d.ts +2 -0
- package/build/typescript/tests/node.test.d.ts.map +1 -0
- package/build/typescript/tests/parent-node-mutation-return-values.test.d.ts +2 -0
- package/build/typescript/tests/parent-node-mutation-return-values.test.d.ts.map +1 -0
- package/build/typescript/tests/parent-node-mutation-validation.test.d.ts +2 -0
- package/build/typescript/tests/parent-node-mutation-validation.test.d.ts.map +1 -0
- package/build/typescript/tests/parent-node.test.d.ts +2 -0
- package/build/typescript/tests/parent-node.test.d.ts.map +1 -0
- package/build/typescript/tests/serialization-template.test.d.ts +2 -0
- package/build/typescript/tests/serialization-template.test.d.ts.map +1 -0
- package/build/typescript/tests/slot-attribute.test.d.ts +2 -0
- package/build/typescript/tests/slot-attribute.test.d.ts.map +1 -0
- package/build/typescript/tests/text-content.test.d.ts +2 -0
- package/build/typescript/tests/text-content.test.d.ts.map +1 -0
- package/build/typescript/tests/toggle-attribute.test.d.ts +2 -0
- package/build/typescript/tests/toggle-attribute.test.d.ts.map +1 -0
- package/build/typescript/tests/wide-tree-traversal.test.d.ts +2 -0
- package/build/typescript/tests/wide-tree-traversal.test.d.ts.map +1 -0
- package/build/typescript/tests/window-set-global.test.d.ts +2 -0
- package/build/typescript/tests/window-set-global.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/source/Attr.ts +60 -8
- package/source/CharacterData.ts +13 -0
- package/source/ChildNode.ts +107 -14
- package/source/Comment.ts +2 -2
- package/source/CustomElementRegistry.ts +56 -0
- package/source/CustomEvent.ts +2 -2
- package/source/Document.ts +104 -38
- package/source/DocumentFragment.ts +12 -2
- package/source/Element.ts +129 -14
- package/source/Event.ts +34 -32
- package/source/EventTarget.ts +203 -79
- package/source/HTMLTemplateElement.ts +2 -1
- package/source/MutationObserver.ts +279 -1
- package/source/NamedNodeMap.ts +141 -60
- package/source/Node.ts +70 -14
- package/source/NodeList.ts +13 -3
- package/source/ParentNode.ts +500 -88
- package/source/SVGElement.ts +2 -2
- package/source/Text.ts +2 -2
- package/source/Window.ts +156 -17
- package/source/attribute-reactions.ts +32 -0
- package/source/constants.ts +40 -17
- package/source/custom-element-reactions.ts +64 -0
- package/source/dom-exception.ts +14 -0
- package/source/extensions.ts +4 -0
- package/source/hook-effects.ts +56 -0
- package/source/hooks.ts +11 -3
- package/source/index.ts +1 -0
- package/source/names.ts +94 -0
- package/source/selectors.ts +301 -138
- package/source/serialization.ts +224 -66
- package/source/shared.ts +269 -40
- package/source/tests/ChildNode.test.ts +178 -0
- package/source/tests/MutationObserver.test.ts +303 -0
- package/source/tests/adopt-inserted-subtrees.test.ts +584 -0
- package/source/tests/attr-mutation.test.ts +112 -0
- package/source/tests/child-node-before-after.test.ts +421 -0
- package/source/tests/child-node-replace-with.test.ts +251 -0
- package/source/tests/clone-import-namespaces.test.ts +365 -0
- package/source/tests/constants.test.ts +46 -0
- package/source/tests/create-element-namespaces.test.ts +142 -0
- package/source/tests/create-text-node.test.ts +38 -0
- package/source/tests/custom-element-reactions.test.ts +600 -0
- package/source/tests/custom-element-registry.test.ts +137 -0
- package/source/tests/custom-event.test.ts +26 -0
- package/source/tests/document-clone-import-contract.test.ts +77 -0
- package/source/tests/document.test.ts +122 -0
- package/source/tests/dom-mutation-selector-errors.test.ts +484 -0
- package/source/tests/event-dispatch.test.ts +270 -0
- package/source/tests/event-target.test.ts +208 -0
- package/source/tests/event.test.ts +98 -0
- package/source/tests/extensions.test.ts +159 -0
- package/source/tests/get-elements-by-tag-name.test.ts +79 -0
- package/source/tests/getElementsByClassName.test.ts +109 -0
- package/source/tests/hooks.test.ts +43 -0
- package/source/tests/inner-html-parsing.test.ts +461 -0
- package/source/tests/is-default-namespace.test.ts +111 -0
- package/source/tests/name-and-namespace-normalization.test.ts +319 -0
- package/source/tests/named-node-map.test.ts +122 -0
- package/source/tests/namespaced-attribute-reactions.test.ts +141 -0
- package/source/tests/node.test.ts +56 -0
- package/source/tests/parent-node-mutation-return-values.test.ts +63 -0
- package/source/tests/parent-node-mutation-validation.test.ts +362 -0
- package/source/tests/parent-node.test.ts +169 -0
- package/source/tests/selectors.test.ts +533 -22
- package/source/tests/serialization-template.test.ts +232 -0
- package/source/tests/slot-attribute.test.ts +133 -0
- package/source/tests/text-content.test.ts +440 -0
- package/source/tests/toggle-attribute.test.ts +113 -0
- package/source/tests/wide-tree-traversal.test.ts +699 -0
- package/source/tests/window-set-global.test.ts +321 -0
- package/tsconfig.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { LISTENERS, OWNER_DOCUMENT,
|
|
2
|
-
import {
|
|
1
|
+
import { LISTENERS, OWNER_DOCUMENT, HOOKS_DISPATCH, DISPATCHING, PATH, STOP_IMMEDIATE_PROPAGATION } from './constants.esnext';
|
|
2
|
+
import { createDOMException } from './dom-exception.esnext';
|
|
3
|
+
import { fireEvent, EVENT_PHASE_CAPTURING, EVENT_PHASE_BUBBLING, EVENT_PHASE_NONE } from './Event.esnext';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
+
const LISTENER_REGISTRATIONS = Symbol("listenerRegistrations");
|
|
5
6
|
class EventTarget {
|
|
6
7
|
[LISTENERS] = void 0;
|
|
7
|
-
[
|
|
8
|
+
[LISTENER_REGISTRATIONS] = void 0;
|
|
8
9
|
/**
|
|
9
10
|
* Property set by entities that extend this class that are part of the DOM tree.
|
|
10
11
|
* @internal
|
|
@@ -12,43 +13,71 @@ class EventTarget {
|
|
|
12
13
|
[OWNER_DOCUMENT] = void 0;
|
|
13
14
|
addEventListener(type, listener, options) {
|
|
14
15
|
if (listener == null) return;
|
|
15
|
-
const capture = options === true || options && options.capture === true;
|
|
16
|
+
const capture = options === true || typeof options === "object" && options.capture === true;
|
|
16
17
|
const once = typeof options === "object" && options.once === true;
|
|
17
18
|
const signal = typeof options === "object" ? options.signal : void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
if (signal?.aborted) return;
|
|
20
|
+
const phase = listenerPhase(capture);
|
|
21
|
+
let registrations = this[LISTENER_REGISTRATIONS];
|
|
22
|
+
if (!registrations) {
|
|
23
|
+
registrations = /* @__PURE__ */ new Map();
|
|
24
|
+
this[LISTENER_REGISTRATIONS] = registrations;
|
|
25
|
+
}
|
|
26
|
+
let registrationsForType = registrations.get(type);
|
|
27
|
+
if (!registrationsForType) {
|
|
28
|
+
registrationsForType = {};
|
|
29
|
+
registrations.set(type, registrationsForType);
|
|
30
|
+
}
|
|
31
|
+
let registrationsForPhase = registrationsForType[phase];
|
|
32
|
+
if (!registrationsForPhase) {
|
|
33
|
+
registrationsForPhase = /* @__PURE__ */ new Map();
|
|
34
|
+
registrationsForType[phase] = registrationsForPhase;
|
|
35
|
+
}
|
|
36
|
+
if (registrationsForPhase.has(listener)) return;
|
|
37
|
+
const target = this;
|
|
38
|
+
const registration = {
|
|
39
|
+
type,
|
|
40
|
+
listener,
|
|
41
|
+
capture,
|
|
42
|
+
once,
|
|
43
|
+
normalizedListener: listener,
|
|
44
|
+
signal
|
|
45
|
+
};
|
|
46
|
+
if (once || signal) {
|
|
47
|
+
registration.normalizedListener = function normalizedListener(...args) {
|
|
48
|
+
if (registration.signal?.aborted) {
|
|
49
|
+
removeListenerRegistration(target, registration);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (registration.once) removeListenerRegistration(target, registration);
|
|
53
|
+
return typeof registration.listener === "object" ? registration.listener.handleEvent(...args) : registration.listener.call(this, ...args);
|
|
24
54
|
};
|
|
25
|
-
let onceListeners = this[ONCE_LISTENERS];
|
|
26
|
-
if (!onceListeners) {
|
|
27
|
-
onceListeners = /* @__PURE__ */ new WeakMap();
|
|
28
|
-
this[ONCE_LISTENERS] = onceListeners;
|
|
29
|
-
}
|
|
30
|
-
onceListeners.set(listener, normalizedListener);
|
|
31
55
|
}
|
|
32
56
|
let listeners = this[LISTENERS];
|
|
33
57
|
if (!listeners) {
|
|
34
58
|
listeners = /* @__PURE__ */ new Map();
|
|
35
59
|
this[LISTENERS] = listeners;
|
|
36
60
|
}
|
|
37
|
-
let
|
|
61
|
+
let listenersForType = listeners.get(type);
|
|
62
|
+
if (!listenersForType) {
|
|
63
|
+
listenersForType = {};
|
|
64
|
+
listeners.set(type, listenersForType);
|
|
65
|
+
}
|
|
66
|
+
let list = listenersForType[phase];
|
|
38
67
|
if (!list) {
|
|
39
68
|
list = /* @__PURE__ */ new Set();
|
|
40
|
-
|
|
69
|
+
listenersForType[phase] = list;
|
|
41
70
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
() => {
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this[OWNER_DOCUMENT]?.defaultView[
|
|
71
|
+
registrationsForPhase.set(listener, registration);
|
|
72
|
+
list.add(registration);
|
|
73
|
+
if (signal) {
|
|
74
|
+
const abortListener = () => {
|
|
75
|
+
removeListenerRegistration(target, registration);
|
|
76
|
+
};
|
|
77
|
+
registration.abortListener = abortListener;
|
|
78
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
79
|
+
}
|
|
80
|
+
this[OWNER_DOCUMENT]?.defaultView[HOOKS_DISPATCH].addEventListener?.(
|
|
52
81
|
this,
|
|
53
82
|
type,
|
|
54
83
|
listener,
|
|
@@ -62,46 +91,89 @@ class EventTarget {
|
|
|
62
91
|
// return PARENT in node;
|
|
63
92
|
// }
|
|
64
93
|
dispatchEvent(event) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
event.target = this;
|
|
72
|
-
event.srcElement = this;
|
|
73
|
-
event[PATH] = path;
|
|
74
|
-
for (let i = path.length; i--; ) {
|
|
75
|
-
fireEvent(event, path[i], EventPhase.CAPTURING_PHASE);
|
|
76
|
-
if (event.cancelBubble) return event.defaultPrevented;
|
|
94
|
+
if (event[DISPATCHING]) {
|
|
95
|
+
throw createDOMException(
|
|
96
|
+
`Failed to execute 'dispatchEvent' on 'EventTarget': The event is already being dispatched.`,
|
|
97
|
+
"InvalidStateError"
|
|
98
|
+
);
|
|
77
99
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
event[DISPATCHING] = true;
|
|
101
|
+
try {
|
|
102
|
+
const path = [];
|
|
103
|
+
let target = this;
|
|
104
|
+
while (target != null) {
|
|
105
|
+
path.push(target);
|
|
106
|
+
target = target.parentNode;
|
|
107
|
+
}
|
|
108
|
+
event.target = this;
|
|
109
|
+
event.srcElement = this;
|
|
110
|
+
event[PATH] = path;
|
|
111
|
+
for (let i = path.length; i--; ) {
|
|
112
|
+
fireEvent(event, path[i], EVENT_PHASE_CAPTURING);
|
|
113
|
+
if (event.cancelBubble) return !event.defaultPrevented;
|
|
114
|
+
}
|
|
115
|
+
const bubblePath = event.bubbles ? path : path.slice(0, 1);
|
|
116
|
+
for (let i = 0; i < bubblePath.length; i++) {
|
|
117
|
+
fireEvent(event, bubblePath[i], EVENT_PHASE_BUBBLING);
|
|
118
|
+
if (event.cancelBubble) return !event.defaultPrevented;
|
|
119
|
+
}
|
|
120
|
+
return !event.defaultPrevented;
|
|
121
|
+
} finally {
|
|
122
|
+
event[DISPATCHING] = false;
|
|
123
|
+
event.cancelBubble = false;
|
|
124
|
+
event[STOP_IMMEDIATE_PROPAGATION] = false;
|
|
125
|
+
event.eventPhase = EVENT_PHASE_NONE;
|
|
126
|
+
event.currentTarget = null;
|
|
127
|
+
event[PATH] = [];
|
|
82
128
|
}
|
|
83
|
-
return event.defaultPrevented;
|
|
84
129
|
}
|
|
85
130
|
}
|
|
86
131
|
function removeEventListener(type, listener, options) {
|
|
87
132
|
if (listener == null) return;
|
|
88
|
-
const onceListeners = this[ONCE_LISTENERS];
|
|
89
|
-
const normalizedListener = onceListeners?.get(listener) ?? listener;
|
|
90
|
-
onceListeners?.delete(listener);
|
|
91
133
|
const capture = options === true || options && options.capture === true;
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
134
|
+
const phase = listenerPhase(Boolean(capture));
|
|
135
|
+
const registration = this[LISTENER_REGISTRATIONS]?.get(type)?.[phase]?.get(listener);
|
|
136
|
+
if (!registration) return;
|
|
137
|
+
removeListenerRegistration(this, registration);
|
|
138
|
+
}
|
|
139
|
+
function listenerPhase(capture) {
|
|
140
|
+
return capture ? "capture" : "bubble";
|
|
141
|
+
}
|
|
142
|
+
function removeListenerRegistration(target, registration) {
|
|
143
|
+
const phase = listenerPhase(registration.capture);
|
|
144
|
+
const registrations = target[LISTENER_REGISTRATIONS];
|
|
145
|
+
const registrationsForType = registrations?.get(registration.type);
|
|
146
|
+
if (!registrationsForType) return;
|
|
147
|
+
const registrationsForPhase = registrationsForType[phase];
|
|
148
|
+
if (!registrationsForPhase || registrationsForPhase.get(registration.listener) !== registration) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
registrationsForPhase.delete(registration.listener);
|
|
152
|
+
if (registrationsForPhase.size === 0) delete registrationsForType[phase];
|
|
153
|
+
if (!registrationsForType.bubble && !registrationsForType.capture) {
|
|
154
|
+
registrations?.delete(registration.type);
|
|
155
|
+
}
|
|
156
|
+
if (registration.signal && registration.abortListener) {
|
|
157
|
+
registration.signal.removeEventListener(
|
|
158
|
+
"abort",
|
|
159
|
+
registration.abortListener
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
const listeners = target[LISTENERS];
|
|
163
|
+
const listenersForType = listeners?.get(registration.type);
|
|
164
|
+
if (!listenersForType) return;
|
|
165
|
+
const list = listenersForType[phase];
|
|
166
|
+
if (!list?.delete(registration)) return;
|
|
167
|
+
if (list.size === 0) delete listenersForType[phase];
|
|
168
|
+
if (!listenersForType.bubble && !listenersForType.capture) {
|
|
169
|
+
listeners?.delete(registration.type);
|
|
104
170
|
}
|
|
171
|
+
target[OWNER_DOCUMENT]?.defaultView[HOOKS_DISPATCH].removeEventListener?.(
|
|
172
|
+
target,
|
|
173
|
+
registration.type,
|
|
174
|
+
registration.listener,
|
|
175
|
+
registration.capture
|
|
176
|
+
);
|
|
105
177
|
}
|
|
106
178
|
|
|
107
179
|
export { EventTarget };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CONTENT } from './constants.esnext';
|
|
1
|
+
import { CONTENT, HOST } from './constants.esnext';
|
|
2
|
+
import './Event.esnext';
|
|
2
3
|
import { Element } from './Element.esnext';
|
|
3
4
|
import { parseHtml, serializeChildren } from './serialization.esnext';
|
|
4
5
|
|
|
@@ -8,6 +9,7 @@ class HTMLTemplateElement extends Element {
|
|
|
8
9
|
let content = this[CONTENT];
|
|
9
10
|
if (!content) {
|
|
10
11
|
content = this.ownerDocument.createDocumentFragment();
|
|
12
|
+
content[HOST] = this;
|
|
11
13
|
this[CONTENT] = content;
|
|
12
14
|
}
|
|
13
15
|
return content;
|
|
@@ -1,5 +1,166 @@
|
|
|
1
|
+
import { NodeList } from './NodeList.esnext';
|
|
2
|
+
|
|
3
|
+
let registrations;
|
|
4
|
+
let registrationCount = 0;
|
|
5
|
+
let attributeRegistrationCount = 0;
|
|
6
|
+
let characterDataRegistrationCount = 0;
|
|
7
|
+
let childListRegistrationCount = 0;
|
|
8
|
+
let attributeObserversActive = false;
|
|
9
|
+
let characterDataObserversActive = false;
|
|
10
|
+
let childListObserversActive = false;
|
|
1
11
|
class MutationObserver {
|
|
2
|
-
|
|
12
|
+
#callback;
|
|
13
|
+
#records = [];
|
|
14
|
+
#targets = /* @__PURE__ */ new Set();
|
|
15
|
+
#scheduled = false;
|
|
16
|
+
constructor(callback) {
|
|
17
|
+
if (typeof callback !== "function") {
|
|
18
|
+
throw new TypeError("MutationObserver callback must be a function");
|
|
19
|
+
}
|
|
20
|
+
this.#callback = callback;
|
|
21
|
+
}
|
|
22
|
+
observe(target, options = {}) {
|
|
23
|
+
const normalizedOptions = normalizeOptions(options);
|
|
24
|
+
const currentRegistrations = registrations ??= /* @__PURE__ */ new WeakMap();
|
|
25
|
+
let targetRegistrations = currentRegistrations.get(target);
|
|
26
|
+
if (targetRegistrations == null) {
|
|
27
|
+
targetRegistrations = /* @__PURE__ */ new Map();
|
|
28
|
+
currentRegistrations.set(target, targetRegistrations);
|
|
29
|
+
}
|
|
30
|
+
const previousOptions = targetRegistrations.get(this);
|
|
31
|
+
if (previousOptions == null) {
|
|
32
|
+
registrationCount++;
|
|
33
|
+
} else {
|
|
34
|
+
updateRegistrationCounts(previousOptions, -1);
|
|
35
|
+
}
|
|
36
|
+
targetRegistrations.set(this, normalizedOptions);
|
|
37
|
+
updateRegistrationCounts(normalizedOptions, 1);
|
|
38
|
+
this.#targets.add(target);
|
|
39
|
+
}
|
|
40
|
+
disconnect() {
|
|
41
|
+
const currentRegistrations = registrations;
|
|
42
|
+
if (currentRegistrations == null) return;
|
|
43
|
+
for (const target of this.#targets) {
|
|
44
|
+
const targetRegistrations = currentRegistrations.get(target);
|
|
45
|
+
const options = targetRegistrations?.get(this);
|
|
46
|
+
if (options != null) {
|
|
47
|
+
targetRegistrations.delete(this);
|
|
48
|
+
registrationCount--;
|
|
49
|
+
updateRegistrationCounts(options, -1);
|
|
50
|
+
}
|
|
51
|
+
if (targetRegistrations?.size === 0) {
|
|
52
|
+
currentRegistrations.delete(target);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.#targets.clear();
|
|
56
|
+
this.#records.length = 0;
|
|
57
|
+
if (registrationCount === 0) {
|
|
58
|
+
registrations = void 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
takeRecords() {
|
|
62
|
+
return this.#records.splice(0);
|
|
63
|
+
}
|
|
64
|
+
/** @internal */
|
|
65
|
+
enqueue(record) {
|
|
66
|
+
this.#records.push(record);
|
|
67
|
+
if (this.#scheduled) return;
|
|
68
|
+
this.#scheduled = true;
|
|
69
|
+
queueMicrotask(() => {
|
|
70
|
+
this.#scheduled = false;
|
|
71
|
+
const records = this.takeRecords();
|
|
72
|
+
if (records.length > 0) {
|
|
73
|
+
this.#callback.call(this, records, this);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function queueMutationRecord(init) {
|
|
79
|
+
const currentRegistrations = registrations;
|
|
80
|
+
if (currentRegistrations == null) return;
|
|
81
|
+
const interestedObservers = /* @__PURE__ */ new Map();
|
|
82
|
+
let node = init.target;
|
|
83
|
+
while (node) {
|
|
84
|
+
const targetRegistrations = currentRegistrations.get(node);
|
|
85
|
+
if (targetRegistrations) {
|
|
86
|
+
for (const [observer, options] of targetRegistrations) {
|
|
87
|
+
if (node !== init.target && !options.subtree) continue;
|
|
88
|
+
let includeOldValue = false;
|
|
89
|
+
if (init.type === "attributes") {
|
|
90
|
+
if (!options.attributes) continue;
|
|
91
|
+
if (options.attributeFilter && !options.attributeFilter.has(init.attributeName ?? "")) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
includeOldValue = options.attributeOldValue;
|
|
95
|
+
} else if (init.type === "characterData") {
|
|
96
|
+
if (!options.characterData) continue;
|
|
97
|
+
includeOldValue = options.characterDataOldValue;
|
|
98
|
+
} else if (!options.childList) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
interestedObservers.set(
|
|
102
|
+
observer,
|
|
103
|
+
interestedObservers.get(observer) === true || includeOldValue
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
node = node.parentNode;
|
|
108
|
+
}
|
|
109
|
+
for (const [observer, includeOldValue] of interestedObservers) {
|
|
110
|
+
observer.enqueue({
|
|
111
|
+
addedNodes: init.addedNodes ?? new NodeList(),
|
|
112
|
+
attributeName: init.attributeName ?? null,
|
|
113
|
+
attributeNamespace: init.attributeNamespace ?? null,
|
|
114
|
+
nextSibling: init.nextSibling ?? null,
|
|
115
|
+
oldValue: includeOldValue ? init.oldValue ?? null : null,
|
|
116
|
+
previousSibling: init.previousSibling ?? null,
|
|
117
|
+
removedNodes: init.removedNodes ?? new NodeList(),
|
|
118
|
+
target: init.target,
|
|
119
|
+
type: init.type
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function mutationNodeList(...nodes) {
|
|
124
|
+
const list = new NodeList();
|
|
125
|
+
list.push(...nodes);
|
|
126
|
+
return list;
|
|
127
|
+
}
|
|
128
|
+
function normalizeOptions(options) {
|
|
129
|
+
if (options.attributes === false && (options.attributeOldValue || options.attributeFilter != null)) {
|
|
130
|
+
throw new TypeError(
|
|
131
|
+
"attributeOldValue and attributeFilter require attributes to be enabled"
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
if (options.characterData === false && options.characterDataOldValue) {
|
|
135
|
+
throw new TypeError(
|
|
136
|
+
"characterDataOldValue requires characterData to be enabled"
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
const attributes = options.attributes ?? (options.attributeOldValue === true || options.attributeFilter != null);
|
|
140
|
+
const characterData = options.characterData ?? options.characterDataOldValue === true;
|
|
141
|
+
const childList = options.childList === true;
|
|
142
|
+
if (!attributes && !characterData && !childList) {
|
|
143
|
+
throw new TypeError(
|
|
144
|
+
"MutationObserver options must enable childList, attributes, or characterData"
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
attributes,
|
|
149
|
+
attributeFilter: options.attributeFilter == null ? void 0 : new Set(options.attributeFilter.map(String)),
|
|
150
|
+
attributeOldValue: options.attributeOldValue === true,
|
|
151
|
+
characterData,
|
|
152
|
+
characterDataOldValue: options.characterDataOldValue === true,
|
|
153
|
+
childList,
|
|
154
|
+
subtree: options.subtree === true
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function updateRegistrationCounts(options, delta) {
|
|
158
|
+
if (options.attributes) attributeRegistrationCount += delta;
|
|
159
|
+
if (options.characterData) characterDataRegistrationCount += delta;
|
|
160
|
+
if (options.childList) childListRegistrationCount += delta;
|
|
161
|
+
attributeObserversActive = attributeRegistrationCount > 0;
|
|
162
|
+
characterDataObserversActive = characterDataRegistrationCount > 0;
|
|
163
|
+
childListObserversActive = childListRegistrationCount > 0;
|
|
3
164
|
}
|
|
4
165
|
|
|
5
|
-
export { MutationObserver };
|
|
166
|
+
export { MutationObserver, attributeObserversActive, characterDataObserversActive, childListObserversActive, mutationNodeList, queueMutationRecord };
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { CHILD, OWNER_ELEMENT, NS, NEXT, HOOKS } from './constants.esnext';
|
|
1
|
+
import { CHILD, OWNER_ELEMENT, NS, HTML_NAMESPACE, asciiLowercase, NEXT, HOOKS, OWNER_DOCUMENT } from './constants.esnext';
|
|
2
|
+
import { normalizeNamespace } from './names.esnext';
|
|
3
|
+
import { attributeObserversActive, queueMutationRecord } from './MutationObserver.esnext';
|
|
4
|
+
import { performWithCustomElementReactions } from './custom-element-reactions.esnext';
|
|
5
|
+
import { enqueueAttributeReaction } from './attribute-reactions.esnext';
|
|
6
|
+
import { createDOMException } from './dom-exception.esnext';
|
|
2
7
|
|
|
3
8
|
class NamedNodeMap {
|
|
4
9
|
[CHILD] = null;
|
|
@@ -7,12 +12,21 @@ class NamedNodeMap {
|
|
|
7
12
|
this[OWNER_ELEMENT] = ownerElement;
|
|
8
13
|
}
|
|
9
14
|
getNamedItem(name) {
|
|
10
|
-
|
|
15
|
+
const qualifiedName = String(name);
|
|
16
|
+
const normalizedName = this[OWNER_ELEMENT][NS] === HTML_NAMESPACE ? asciiLowercase(qualifiedName) : qualifiedName;
|
|
17
|
+
let attr = this[CHILD];
|
|
18
|
+
while (attr) {
|
|
19
|
+
if (attr.name === normalizedName) return attr;
|
|
20
|
+
attr = attr[NEXT];
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
11
23
|
}
|
|
12
|
-
getNamedItemNS(namespaceURI,
|
|
24
|
+
getNamedItemNS(namespaceURI, localName) {
|
|
25
|
+
const namespace = normalizeNamespace(namespaceURI);
|
|
26
|
+
const normalizedLocalName = String(localName);
|
|
13
27
|
let attr = this[CHILD];
|
|
14
28
|
while (attr) {
|
|
15
|
-
if (attr.
|
|
29
|
+
if (attr.localName === normalizedLocalName && attr[NS] === namespace) {
|
|
16
30
|
return attr;
|
|
17
31
|
}
|
|
18
32
|
attr = attr[NEXT];
|
|
@@ -38,21 +52,52 @@ class NamedNodeMap {
|
|
|
38
52
|
return index;
|
|
39
53
|
}
|
|
40
54
|
removeNamedItem(name) {
|
|
41
|
-
|
|
55
|
+
const qualifiedName = String(name);
|
|
56
|
+
const normalizedName = this[OWNER_ELEMENT][NS] === HTML_NAMESPACE ? asciiLowercase(qualifiedName) : qualifiedName;
|
|
57
|
+
return performWithCustomElementReactions(
|
|
58
|
+
() => this.removeNamedItemImmediately((attr) => attr.name === normalizedName)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
removeNamedItemNS(namespaceURI, localName) {
|
|
62
|
+
const namespace = normalizeNamespace(namespaceURI);
|
|
63
|
+
const normalizedLocalName = String(localName);
|
|
64
|
+
return performWithCustomElementReactions(
|
|
65
|
+
() => this.removeNamedItemImmediately(
|
|
66
|
+
(attr) => attr.localName === normalizedLocalName && attr[NS] === namespace
|
|
67
|
+
)
|
|
68
|
+
);
|
|
42
69
|
}
|
|
43
|
-
|
|
70
|
+
removeNamedItemImmediately(matches) {
|
|
44
71
|
const ownerElement = this[OWNER_ELEMENT];
|
|
45
72
|
let attr = this[CHILD];
|
|
46
73
|
let prev = null;
|
|
47
74
|
while (attr != null) {
|
|
48
|
-
if (attr
|
|
75
|
+
if (matches(attr)) {
|
|
49
76
|
if (prev) prev[NEXT] = attr[NEXT];
|
|
50
77
|
if (this[CHILD] === attr) this[CHILD] = attr[NEXT];
|
|
51
|
-
|
|
78
|
+
const oldValue = attr.value;
|
|
79
|
+
attr[NEXT] = null;
|
|
80
|
+
attr[OWNER_ELEMENT] = null;
|
|
81
|
+
if (attributeObserversActive) {
|
|
82
|
+
queueMutationRecord({
|
|
83
|
+
type: "attributes",
|
|
84
|
+
target: ownerElement,
|
|
85
|
+
attributeName: attr.name,
|
|
86
|
+
attributeNamespace: attr[NS],
|
|
87
|
+
oldValue
|
|
88
|
+
});
|
|
89
|
+
}
|
|
52
90
|
ownerElement[HOOKS].removeAttribute?.(
|
|
53
91
|
ownerElement,
|
|
54
|
-
name,
|
|
55
|
-
|
|
92
|
+
attr.name,
|
|
93
|
+
attr[NS]
|
|
94
|
+
);
|
|
95
|
+
enqueueAttributeReaction(
|
|
96
|
+
ownerElement,
|
|
97
|
+
attr.localName,
|
|
98
|
+
oldValue,
|
|
99
|
+
null,
|
|
100
|
+
attr[NS]
|
|
56
101
|
);
|
|
57
102
|
return attr;
|
|
58
103
|
}
|
|
@@ -62,36 +107,61 @@ class NamedNodeMap {
|
|
|
62
107
|
return null;
|
|
63
108
|
}
|
|
64
109
|
setNamedItem(attr) {
|
|
110
|
+
return performWithCustomElementReactions(
|
|
111
|
+
() => this.setNamedItemImmediately(attr)
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
setNamedItemImmediately(attr) {
|
|
65
115
|
const ownerElement = this[OWNER_ELEMENT];
|
|
116
|
+
const currentOwner = attr[OWNER_ELEMENT];
|
|
117
|
+
if (currentOwner != null && currentOwner !== ownerElement) {
|
|
118
|
+
throw createDOMException(
|
|
119
|
+
"The attribute is already in use by another element.",
|
|
120
|
+
"InUseAttributeError"
|
|
121
|
+
);
|
|
122
|
+
}
|
|
66
123
|
let old = null;
|
|
67
124
|
let child = this[CHILD];
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
child[NEXT] = null;
|
|
79
|
-
old = child;
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
prev = child;
|
|
83
|
-
child = child[NEXT];
|
|
125
|
+
let prev = null;
|
|
126
|
+
while (child) {
|
|
127
|
+
if (child.localName === attr.localName && child[NS] === attr[NS]) {
|
|
128
|
+
if (child === attr) return child;
|
|
129
|
+
if (prev) prev[NEXT] = attr;
|
|
130
|
+
else this[CHILD] = attr;
|
|
131
|
+
attr[NEXT] = child[NEXT];
|
|
132
|
+
child[NEXT] = null;
|
|
133
|
+
old = child;
|
|
134
|
+
break;
|
|
84
135
|
}
|
|
136
|
+
prev = child;
|
|
137
|
+
child = child[NEXT];
|
|
138
|
+
}
|
|
139
|
+
if (old == null) {
|
|
85
140
|
if (prev) prev[NEXT] = attr;
|
|
86
141
|
else this[CHILD] = attr;
|
|
87
142
|
}
|
|
88
|
-
|
|
89
|
-
|
|
143
|
+
attr[OWNER_ELEMENT] = ownerElement;
|
|
144
|
+
attr[OWNER_DOCUMENT] = ownerElement[OWNER_DOCUMENT];
|
|
145
|
+
if (old) old[OWNER_ELEMENT] = null;
|
|
146
|
+
const valueChanged = old == null || old.value !== attr.value;
|
|
147
|
+
const qualifiedNameChanged = old != null && old.name !== attr.name;
|
|
148
|
+
if (valueChanged && attributeObserversActive) {
|
|
149
|
+
queueMutationRecord({
|
|
150
|
+
type: "attributes",
|
|
151
|
+
target: ownerElement,
|
|
152
|
+
attributeName: attr.name,
|
|
153
|
+
attributeNamespace: attr[NS],
|
|
154
|
+
oldValue: old?.value ?? null
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (qualifiedNameChanged) {
|
|
158
|
+
ownerElement[HOOKS].removeAttribute?.(
|
|
90
159
|
ownerElement,
|
|
91
|
-
|
|
92
|
-
old
|
|
93
|
-
attr.value
|
|
160
|
+
old.name,
|
|
161
|
+
old[NS]
|
|
94
162
|
);
|
|
163
|
+
}
|
|
164
|
+
if (valueChanged || qualifiedNameChanged) {
|
|
95
165
|
ownerElement[HOOKS].setAttribute?.(
|
|
96
166
|
ownerElement,
|
|
97
167
|
attr.name,
|
|
@@ -99,6 +169,15 @@ class NamedNodeMap {
|
|
|
99
169
|
attr[NS]
|
|
100
170
|
);
|
|
101
171
|
}
|
|
172
|
+
if (valueChanged) {
|
|
173
|
+
enqueueAttributeReaction(
|
|
174
|
+
ownerElement,
|
|
175
|
+
attr.localName,
|
|
176
|
+
old?.value ?? null,
|
|
177
|
+
attr.value,
|
|
178
|
+
attr[NS]
|
|
179
|
+
);
|
|
180
|
+
}
|
|
102
181
|
return old;
|
|
103
182
|
}
|
|
104
183
|
setNamedItemNS(attr) {
|
|
@@ -112,16 +191,5 @@ class NamedNodeMap {
|
|
|
112
191
|
}
|
|
113
192
|
}
|
|
114
193
|
}
|
|
115
|
-
function updateElementAttribute(element, name, oldValue, newValue) {
|
|
116
|
-
const { observedAttributes } = element.constructor;
|
|
117
|
-
const { attributeChangedCallback } = element;
|
|
118
|
-
if (name === "slot") {
|
|
119
|
-
element.slot = newValue ?? "";
|
|
120
|
-
}
|
|
121
|
-
if (attributeChangedCallback == null || observedAttributes == null || !observedAttributes.includes(name)) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
return attributeChangedCallback.call(element, name, oldValue, newValue);
|
|
125
|
-
}
|
|
126
194
|
|
|
127
195
|
export { NamedNodeMap };
|