@miaskiewicz/turbo-dom 0.1.51 → 0.1.52

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.51",
3
+ "version": "0.1.52",
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",
@@ -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) for (const c of this.__children()) el.appendChild(c.cloneNode(true));
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