Clone DOM elements without reparsing

This commit is contained in:
SGavrl committed 2026-07-31 00:54:22 +00:00
1 parent 393bac9895
commit 90ed9afcad
4 files changed
+160 -9

No files matched your search

+4
View File
@@ -1233,6 +1233,10 @@ class Node {
contains(o) { return o ? _dom("contains", this._nid, o._nid) === "true" : false; }
hasChildNodes() { return _dom("has_child_nodes", this._nid) === "true"; }
cloneNode(deep) {
const t = this.nodeType;
if (t === 1) {
return _wrap(+_dom("clone_node", this._nid, deep ? "true" : "false"));
}
// Clone structurally via real DOM nodes rather than round-tripping through a
// throwaway <div>.innerHTML: the fragment parser discards elements that are
// not valid children of <div> (<tr>, <td>, <option>, …), so the old path