@miaskiewicz/turbo-dom 0.1.51 → 0.1.53
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miaskiewicz/turbo-dom",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.53",
|
|
4
4
|
"description": "Faster, more spec-correct DOM for test runners — native html5ever (Rust/WASM) parser + lazy copy-on-write DOM. A drop-in-style alternative to jsdom/happy-dom for vitest & jest.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
package/src/runtime/dom.mjs
CHANGED
|
@@ -717,7 +717,12 @@ export class Element extends Node {
|
|
|
717
717
|
cloneNode(deep = false) {
|
|
718
718
|
const el = new Element(this.ownerDocument, this.localName, this.__ns);
|
|
719
719
|
el.__attrs = (this.__attrs ?? (this.__attrs = this.__buildAttrs())).map((a) => ({ ...a }));
|
|
720
|
-
if (deep)
|
|
720
|
+
if (deep) {
|
|
721
|
+
// build the cloned child array directly — the clone is detached, so per-child
|
|
722
|
+
// appendChild's notifyMutation (version bump) + reparent check are pure waste.
|
|
723
|
+
const src = this.__children(), od = el.ownerDocument, kids = el.__kids = new Array(src.length);
|
|
724
|
+
for (let i = 0; i < src.length; i++) { const cl = src[i].cloneNode(true); cl.parentNode = el; cl.ownerDocument = od; kids[i] = cl; }
|
|
725
|
+
}
|
|
721
726
|
return el;
|
|
722
727
|
}
|
|
723
728
|
|
|
@@ -929,7 +934,14 @@ export class DocumentFragment extends Node {
|
|
|
929
934
|
querySelectorAll(sel) { return cachedQSA(this, sel); }
|
|
930
935
|
get children() { if (this.__childrenList) return this.__childrenList; const self = this; return (this.__childrenList = liveHTMLCollection(() => self.__children().filter((n) => n.nodeType === ELEMENT_NODE))); }
|
|
931
936
|
append(...nodes) { for (const n of nodes) this.appendChild(toNode(this.ownerDocument, n)); }
|
|
932
|
-
cloneNode(deep = false) {
|
|
937
|
+
cloneNode(deep = false) {
|
|
938
|
+
const f = new DocumentFragment(this.ownerDocument);
|
|
939
|
+
if (deep) { // direct __kids build — detached clone, per-child appendChild bookkeeping is waste (see Element.cloneNode)
|
|
940
|
+
const src = this.__children(), od = f.ownerDocument, kids = f.__kids = new Array(src.length);
|
|
941
|
+
for (let i = 0; i < src.length; i++) { const cl = src[i].cloneNode(true); cl.parentNode = f; cl.ownerDocument = od; kids[i] = cl; }
|
|
942
|
+
}
|
|
943
|
+
return f;
|
|
944
|
+
}
|
|
933
945
|
}
|
|
934
946
|
|
|
935
947
|
// A real shadow root: a detached document-fragment subtree with a back-reference
|
|
Binary file
|