@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
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const constants = require('./constants.cjs');
|
|
6
|
+
const names = require('./names.cjs');
|
|
7
|
+
const MutationObserver = require('./MutationObserver.cjs');
|
|
8
|
+
const customElementReactions = require('./custom-element-reactions.cjs');
|
|
9
|
+
const attributeReactions = require('./attribute-reactions.cjs');
|
|
10
|
+
const domException = require('./dom-exception.cjs');
|
|
6
11
|
|
|
7
12
|
class NamedNodeMap {
|
|
8
13
|
[constants.CHILD] = null;
|
|
@@ -10,12 +15,21 @@ class NamedNodeMap {
|
|
|
10
15
|
this[constants.OWNER_ELEMENT] = ownerElement;
|
|
11
16
|
}
|
|
12
17
|
getNamedItem(name) {
|
|
13
|
-
|
|
18
|
+
const qualifiedName = String(name);
|
|
19
|
+
const normalizedName = this[constants.OWNER_ELEMENT][constants.NS] === constants.HTML_NAMESPACE ? constants.asciiLowercase(qualifiedName) : qualifiedName;
|
|
20
|
+
let attr = this[constants.CHILD];
|
|
21
|
+
while (attr) {
|
|
22
|
+
if (attr.name === normalizedName) return attr;
|
|
23
|
+
attr = attr[constants.NEXT];
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
14
26
|
}
|
|
15
|
-
getNamedItemNS(namespaceURI,
|
|
27
|
+
getNamedItemNS(namespaceURI, localName) {
|
|
28
|
+
const namespace = names.normalizeNamespace(namespaceURI);
|
|
29
|
+
const normalizedLocalName = String(localName);
|
|
16
30
|
let attr = this[constants.CHILD];
|
|
17
31
|
while (attr) {
|
|
18
|
-
if (attr.
|
|
32
|
+
if (attr.localName === normalizedLocalName && attr[constants.NS] === namespace) {
|
|
19
33
|
return attr;
|
|
20
34
|
}
|
|
21
35
|
attr = attr[constants.NEXT];
|
|
@@ -41,18 +55,37 @@ class NamedNodeMap {
|
|
|
41
55
|
return index;
|
|
42
56
|
}
|
|
43
57
|
removeNamedItem(name) {
|
|
44
|
-
|
|
58
|
+
const qualifiedName = String(name);
|
|
59
|
+
const normalizedName = this[constants.OWNER_ELEMENT][constants.NS] === constants.HTML_NAMESPACE ? constants.asciiLowercase(qualifiedName) : qualifiedName;
|
|
60
|
+
return customElementReactions.performWithCustomElementReactions(() => this.removeNamedItemImmediately(attr => attr.name === normalizedName));
|
|
61
|
+
}
|
|
62
|
+
removeNamedItemNS(namespaceURI, localName) {
|
|
63
|
+
const namespace = names.normalizeNamespace(namespaceURI);
|
|
64
|
+
const normalizedLocalName = String(localName);
|
|
65
|
+
return customElementReactions.performWithCustomElementReactions(() => this.removeNamedItemImmediately(attr => attr.localName === normalizedLocalName && attr[constants.NS] === namespace));
|
|
45
66
|
}
|
|
46
|
-
|
|
67
|
+
removeNamedItemImmediately(matches) {
|
|
47
68
|
const ownerElement = this[constants.OWNER_ELEMENT];
|
|
48
69
|
let attr = this[constants.CHILD];
|
|
49
70
|
let prev = null;
|
|
50
71
|
while (attr != null) {
|
|
51
|
-
if (attr
|
|
72
|
+
if (matches(attr)) {
|
|
52
73
|
if (prev) prev[constants.NEXT] = attr[constants.NEXT];
|
|
53
74
|
if (this[constants.CHILD] === attr) this[constants.CHILD] = attr[constants.NEXT];
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
const oldValue = attr.value;
|
|
76
|
+
attr[constants.NEXT] = null;
|
|
77
|
+
attr[constants.OWNER_ELEMENT] = null;
|
|
78
|
+
if (MutationObserver.attributeObserversActive) {
|
|
79
|
+
MutationObserver.queueMutationRecord({
|
|
80
|
+
type: 'attributes',
|
|
81
|
+
target: ownerElement,
|
|
82
|
+
attributeName: attr.name,
|
|
83
|
+
attributeNamespace: attr[constants.NS],
|
|
84
|
+
oldValue
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
ownerElement[constants.HOOKS].removeAttribute?.(ownerElement, attr.name, attr[constants.NS]);
|
|
88
|
+
attributeReactions.enqueueAttributeReaction(ownerElement, attr.localName, oldValue, null, attr[constants.NS]);
|
|
56
89
|
return attr;
|
|
57
90
|
}
|
|
58
91
|
prev = attr;
|
|
@@ -61,36 +94,55 @@ class NamedNodeMap {
|
|
|
61
94
|
return null;
|
|
62
95
|
}
|
|
63
96
|
setNamedItem(attr) {
|
|
97
|
+
return customElementReactions.performWithCustomElementReactions(() => this.setNamedItemImmediately(attr));
|
|
98
|
+
}
|
|
99
|
+
setNamedItemImmediately(attr) {
|
|
64
100
|
const ownerElement = this[constants.OWNER_ELEMENT];
|
|
101
|
+
const currentOwner = attr[constants.OWNER_ELEMENT];
|
|
102
|
+
if (currentOwner != null && currentOwner !== ownerElement) {
|
|
103
|
+
throw domException.createDOMException('The attribute is already in use by another element.', 'InUseAttributeError');
|
|
104
|
+
}
|
|
65
105
|
let old = null;
|
|
66
106
|
let child = this[constants.CHILD];
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
attr[constants.NEXT] = child[constants.NEXT];
|
|
77
|
-
child[constants.NEXT] = null;
|
|
78
|
-
old = child;
|
|
79
|
-
break;
|
|
80
|
-
// return child;
|
|
81
|
-
}
|
|
82
|
-
prev = child;
|
|
83
|
-
child = child[constants.NEXT];
|
|
107
|
+
let prev = null;
|
|
108
|
+
while (child) {
|
|
109
|
+
if (child.localName === attr.localName && child[constants.NS] === attr[constants.NS]) {
|
|
110
|
+
if (child === attr) return child;
|
|
111
|
+
if (prev) prev[constants.NEXT] = attr;else this[constants.CHILD] = attr;
|
|
112
|
+
attr[constants.NEXT] = child[constants.NEXT];
|
|
113
|
+
child[constants.NEXT] = null;
|
|
114
|
+
old = child;
|
|
115
|
+
break;
|
|
84
116
|
}
|
|
117
|
+
prev = child;
|
|
118
|
+
child = child[constants.NEXT];
|
|
119
|
+
}
|
|
120
|
+
if (old == null) {
|
|
85
121
|
if (prev) prev[constants.NEXT] = attr;else this[constants.CHILD] = attr;
|
|
86
|
-
// return null;
|
|
87
122
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
123
|
+
attr[constants.OWNER_ELEMENT] = ownerElement;
|
|
124
|
+
attr[constants.OWNER_DOCUMENT] = ownerElement[constants.OWNER_DOCUMENT];
|
|
125
|
+
if (old) old[constants.OWNER_ELEMENT] = null;
|
|
126
|
+
const valueChanged = old == null || old.value !== attr.value;
|
|
127
|
+
const qualifiedNameChanged = old != null && old.name !== attr.name;
|
|
128
|
+
if (valueChanged && MutationObserver.attributeObserversActive) {
|
|
129
|
+
MutationObserver.queueMutationRecord({
|
|
130
|
+
type: 'attributes',
|
|
131
|
+
target: ownerElement,
|
|
132
|
+
attributeName: attr.name,
|
|
133
|
+
attributeNamespace: attr[constants.NS],
|
|
134
|
+
oldValue: old?.value ?? null
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (qualifiedNameChanged) {
|
|
138
|
+
ownerElement[constants.HOOKS].removeAttribute?.(ownerElement, old.name, old[constants.NS]);
|
|
139
|
+
}
|
|
140
|
+
if (valueChanged || qualifiedNameChanged) {
|
|
92
141
|
ownerElement[constants.HOOKS].setAttribute?.(ownerElement, attr.name, attr.value, attr[constants.NS]);
|
|
93
142
|
}
|
|
143
|
+
if (valueChanged) {
|
|
144
|
+
attributeReactions.enqueueAttributeReaction(ownerElement, attr.localName, old?.value ?? null, attr.value, attr[constants.NS]);
|
|
145
|
+
}
|
|
94
146
|
return old;
|
|
95
147
|
}
|
|
96
148
|
setNamedItemNS(attr) {
|
|
@@ -104,20 +156,5 @@ class NamedNodeMap {
|
|
|
104
156
|
}
|
|
105
157
|
}
|
|
106
158
|
}
|
|
107
|
-
function updateElementAttribute(element, name, oldValue, newValue) {
|
|
108
|
-
const {
|
|
109
|
-
observedAttributes
|
|
110
|
-
} = element.constructor;
|
|
111
|
-
const {
|
|
112
|
-
attributeChangedCallback
|
|
113
|
-
} = element;
|
|
114
|
-
if (name === 'slot') {
|
|
115
|
-
element.slot = newValue ?? '';
|
|
116
|
-
}
|
|
117
|
-
if (attributeChangedCallback == null || observedAttributes == null || !observedAttributes.includes(name)) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
return attributeChangedCallback.call(element, name, oldValue, newValue);
|
|
121
|
-
}
|
|
122
159
|
|
|
123
160
|
exports.NamedNodeMap = NamedNodeMap;
|
package/build/cjs/Node.cjs
CHANGED
|
@@ -4,24 +4,26 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4
4
|
|
|
5
5
|
const constants = require('./constants.cjs');
|
|
6
6
|
const EventTarget = require('./EventTarget.cjs');
|
|
7
|
+
const names = require('./names.cjs');
|
|
7
8
|
const shared = require('./shared.cjs');
|
|
8
9
|
|
|
9
10
|
class Node extends EventTarget.EventTarget {
|
|
10
|
-
nodeType =
|
|
11
|
+
nodeType = constants.NODE_TYPE_NODE;
|
|
11
12
|
[constants.NAME] = '';
|
|
12
13
|
[constants.PARENT] = null;
|
|
14
|
+
[constants.HOST] = null;
|
|
13
15
|
[constants.CHILD] = null;
|
|
14
16
|
[constants.PREV] = null;
|
|
15
17
|
[constants.NEXT] = null;
|
|
16
18
|
[constants.IS_CONNECTED] = false;
|
|
17
19
|
get [constants.HOOKS]() {
|
|
18
|
-
return this[constants.OWNER_DOCUMENT].defaultView[constants.
|
|
20
|
+
return this[constants.OWNER_DOCUMENT].defaultView[constants.HOOKS_DISPATCH];
|
|
19
21
|
}
|
|
20
22
|
get localName() {
|
|
21
23
|
return this[constants.NAME];
|
|
22
24
|
}
|
|
23
25
|
get nodeName() {
|
|
24
|
-
return this[constants.NAME]
|
|
26
|
+
return this[constants.NAME];
|
|
25
27
|
}
|
|
26
28
|
get ownerDocument() {
|
|
27
29
|
return this[constants.OWNER_DOCUMENT];
|
|
@@ -30,7 +32,8 @@ class Node extends EventTarget.EventTarget {
|
|
|
30
32
|
return this[constants.IS_CONNECTED];
|
|
31
33
|
}
|
|
32
34
|
isDefaultNamespace(namespace) {
|
|
33
|
-
|
|
35
|
+
const normalizedNamespace = names.normalizeNamespace(namespace);
|
|
36
|
+
return locateNamespace(this) === normalizedNamespace;
|
|
34
37
|
}
|
|
35
38
|
get parentNode() {
|
|
36
39
|
return this[constants.PARENT];
|
|
@@ -97,11 +100,12 @@ class Node extends EventTarget.EventTarget {
|
|
|
97
100
|
if (shared.isCharacterData(this)) {
|
|
98
101
|
this.data = data;
|
|
99
102
|
} else if (shared.isParentNode(this)) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.
|
|
103
|
+
const text = data == null ? '' : String(data);
|
|
104
|
+
if (text === '') {
|
|
105
|
+
this.replaceChildren();
|
|
106
|
+
} else {
|
|
107
|
+
this.replaceChildren(text);
|
|
103
108
|
}
|
|
104
|
-
this.append(data);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
cloneNode(deep) {
|
|
@@ -109,12 +113,44 @@ class Node extends EventTarget.EventTarget {
|
|
|
109
113
|
}
|
|
110
114
|
contains(node) {
|
|
111
115
|
let currentNode = node;
|
|
112
|
-
while (
|
|
113
|
-
if (currentNode == null) return false;
|
|
116
|
+
while (currentNode != null) {
|
|
114
117
|
if (currentNode === this) return true;
|
|
115
|
-
currentNode =
|
|
118
|
+
currentNode = currentNode.parentNode;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function locateNamespace(node) {
|
|
124
|
+
let current = node;
|
|
125
|
+
while (current) {
|
|
126
|
+
switch (current.nodeType) {
|
|
127
|
+
case constants.NODE_TYPE_ELEMENT:
|
|
128
|
+
{
|
|
129
|
+
const element = current;
|
|
130
|
+
if (element.prefix == null && element.namespaceURI != null) {
|
|
131
|
+
return element.namespaceURI;
|
|
132
|
+
}
|
|
133
|
+
const namespace = element.attributes.getNamedItemNS(constants.XMLNS_NAMESPACE, 'xmlns');
|
|
134
|
+
if (namespace != null && namespace.prefix == null) {
|
|
135
|
+
return names.normalizeNamespace(namespace.value);
|
|
136
|
+
}
|
|
137
|
+
current = element.parentElement;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case constants.NODE_TYPE_DOCUMENT:
|
|
141
|
+
current = current.documentElement;
|
|
142
|
+
break;
|
|
143
|
+
case constants.NODE_TYPE_DOCUMENT_TYPE:
|
|
144
|
+
case constants.NODE_TYPE_DOCUMENT_FRAGMENT:
|
|
145
|
+
return null;
|
|
146
|
+
case constants.NODE_TYPE_ATTRIBUTE:
|
|
147
|
+
current = current.ownerElement;
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
current = current.parentElement;
|
|
116
151
|
}
|
|
117
152
|
}
|
|
153
|
+
return null;
|
|
118
154
|
}
|
|
119
155
|
|
|
120
156
|
exports.Node = Node;
|
package/build/cjs/NodeList.cjs
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
+
// Performance note (2026-09-02): Benchmarks on an Apple M4 Pro with Node.js
|
|
6
|
+
// 24.19.0 (V8 13.6.233.17-node.51) and Chromium 152 showed indexed access and
|
|
7
|
+
// `for...of` iteration at parity with Array. Construction, `push()`, and some
|
|
8
|
+
// inherited methods (`forEach()`, `includes()`, `map()`, `filter()`, and
|
|
9
|
+
// `slice()`) were slower, but the measured end-to-end `querySelectorAll()`
|
|
10
|
+
// overhead was 0–12% (up to about 1 µs in the tested 100–1,000-element trees)
|
|
11
|
+
// and decreased as selector traversal dominated. Keep this direct subclass
|
|
12
|
+
// while indexed access and iteration remain the primary usage patterns.
|
|
5
13
|
class NodeList extends Array {
|
|
6
14
|
item(index) {
|
|
7
|
-
return this[index];
|
|
15
|
+
return this[index] ?? null;
|
|
8
16
|
}
|
|
9
17
|
}
|
|
10
18
|
|