MCPcopy
hub / github.com/Rich-Harris/ramjet / cloneNode

Function cloneNode

src/utils/node.js:4–33  ·  view source on GitHub ↗
( node, depth, overrideClone )

Source from the content-addressed store, hash-verified

2import { svg, svgns } from './svg';
3
4export function cloneNode ( node, depth, overrideClone ) {
5 const clone = overrideClone ? overrideClone(node, depth) : node.cloneNode();
6
7 if (typeof clone === "undefined"){
8 return;
9 }
10
11 let style;
12 let len;
13 let i;
14 let clonedNode;
15
16 if ( node.nodeType === 1 ) {
17 style = window.getComputedStyle( node );
18
19 styleKeys.forEach( function ( prop ) {
20 clone.style[ prop ] = style[ prop ];
21 });
22
23 len = node.childNodes.length;
24 for ( i = 0; i < len; i += 1 ) {
25 clonedNode = cloneNode( node.childNodes[i], depth + 1, overrideClone );
26 if (clonedNode) {
27 clone.appendChild( clonedNode );
28 }
29 }
30 }
31
32 return clone;
33}
34
35export function wrapNode ( node, destinationIsFixed, overrideClone, appendToBody ) {
36 const isSvg = node.namespaceURI === svgns;

Callers 1

wrapNodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected