@chr33s/solarflare 0.0.12 → 0.0.13
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/package.json +1 -1
- package/src/diff-dom-streaming.ts +11 -14
package/package.json
CHANGED
|
@@ -63,7 +63,8 @@ async function updateNode(oldNode: Node, newNode: Node, walker: Walker) {
|
|
|
63
63
|
return walker[APPLY_TRANSITION](() => {
|
|
64
64
|
// oldNode may have been moved/removed by a previous batched mutation
|
|
65
65
|
if (oldNode.parentNode) {
|
|
66
|
-
oldNode.
|
|
66
|
+
const doc = oldNode.ownerDocument ?? document;
|
|
67
|
+
oldNode.parentNode.replaceChild(doc.importNode(newNode, true), oldNode);
|
|
67
68
|
}
|
|
68
69
|
});
|
|
69
70
|
}
|
|
@@ -75,7 +76,8 @@ async function updateNode(oldNode: Node, newNode: Node, walker: Walker) {
|
|
|
75
76
|
if (hasShadowRoot(oldNode as Element) && hasDsdTemplate(newNode as Element)) {
|
|
76
77
|
return walker[APPLY_TRANSITION](() => {
|
|
77
78
|
if (oldNode.parentNode) {
|
|
78
|
-
oldNode.
|
|
79
|
+
const doc = oldNode.ownerDocument ?? document;
|
|
80
|
+
oldNode.parentNode.replaceChild(doc.importNode(newNode, true), oldNode);
|
|
79
81
|
}
|
|
80
82
|
});
|
|
81
83
|
}
|
|
@@ -102,7 +104,8 @@ async function updateNode(oldNode: Node, newNode: Node, walker: Walker) {
|
|
|
102
104
|
}
|
|
103
105
|
} else {
|
|
104
106
|
const hasDocumentFragmentInside = newNode.nodeName === "TEMPLATE";
|
|
105
|
-
const
|
|
107
|
+
const doc = oldNode.ownerDocument ?? document;
|
|
108
|
+
const clonedNewNode = doc.importNode(newNode, hasDocumentFragmentInside);
|
|
106
109
|
while (oldNode.firstChild) clonedNewNode.appendChild(oldNode.firstChild);
|
|
107
110
|
// oldNode may have been moved/removed by a previous batched mutation
|
|
108
111
|
if (oldNode.parentNode) {
|
|
@@ -165,15 +168,9 @@ function setAttributes(oldAttributes: NamedNodeMap, newAttributes: NamedNodeMap)
|
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
|
|
168
|
-
/**
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
*/
|
|
172
|
-
function cloneForDocument(node: Node, targetDoc: Document, walker: Walker): Node {
|
|
173
|
-
if (walker.shouldReplaceNode?.(node)) {
|
|
174
|
-
return targetDoc.importNode(node, true);
|
|
175
|
-
}
|
|
176
|
-
return node.cloneNode(true);
|
|
171
|
+
/** Clone a node into the target document via importNode to avoid cross-document adoption. */
|
|
172
|
+
function cloneForDocument(node: Node, targetDoc: Document): Node {
|
|
173
|
+
return targetDoc.importNode(node, true);
|
|
177
174
|
}
|
|
178
175
|
|
|
179
176
|
/**
|
|
@@ -267,7 +264,7 @@ async function setChildNodes(oldParent: Node, newParent: Node, walker: Walker) {
|
|
|
267
264
|
oldNode = oldNode.nextSibling;
|
|
268
265
|
if (getKey(checkOld)) {
|
|
269
266
|
const targetDoc = oldParent.ownerDocument ?? document;
|
|
270
|
-
insertedNode = cloneForDocument(newNode, targetDoc
|
|
267
|
+
insertedNode = cloneForDocument(newNode, targetDoc);
|
|
271
268
|
if (shouldInsertImmediately(insertedNode!)) {
|
|
272
269
|
flushPendingInsertions();
|
|
273
270
|
walker[APPLY_TRANSITION](() => {
|
|
@@ -289,7 +286,7 @@ async function setChildNodes(oldParent: Node, newParent: Node, walker: Walker) {
|
|
|
289
286
|
}
|
|
290
287
|
} else {
|
|
291
288
|
const targetDoc = oldParent.ownerDocument ?? document;
|
|
292
|
-
insertedNode = cloneForDocument(newNode, targetDoc
|
|
289
|
+
insertedNode = cloneForDocument(newNode, targetDoc);
|
|
293
290
|
if (shouldInsertImmediately(insertedNode!)) {
|
|
294
291
|
flushPendingInsertions();
|
|
295
292
|
walker[APPLY_TRANSITION](() => oldParent.appendChild(insertedNode!));
|