diff --git a/src/clone-node.ts b/src/clone-node.ts index 500ce332..6214ebd5 100644 --- a/src/clone-node.ts +++ b/src/clone-node.ts @@ -61,17 +61,24 @@ async function cloneSingleNode( return cloneIFrameElement(node) } - return node.cloneNode(false) as T + return node.cloneNode(isSVGElement(node)) as T } const isSlotElement = (node: HTMLElement): node is HTMLSlotElement => node.tagName != null && node.tagName.toUpperCase() === 'SLOT' +const isSVGElement = (node: HTMLElement): node is HTMLSlotElement => + node.tagName != null && node.tagName.toUpperCase() === 'SVG' + async function cloneChildren( nativeNode: T, clonedNode: T, options: Options, ): Promise { + if (isSVGElement(clonedNode)) { + return clonedNode + } + let children: T[] = [] if (isSlotElement(nativeNode) && nativeNode.assignedNodes) { @@ -133,11 +140,11 @@ function cloneCSSStyle(nativeNode: T, clonedNode: T) { ) { value = 'block' } - + if (name === 'd' && clonedNode.getAttribute('d')) { value = `path(${clonedNode.getAttribute('d')})` } - + targetStyle.setProperty( name, value,