MCPcopy
hub / github.com/bubkoo/html-to-image / cloneSingleNode

Function cloneSingleNode

src/clone-node.ts:53–70  ·  view source on GitHub ↗
(
  node: T,
  options: Options,
)

Source from the content-addressed store, hash-verified

51}
52
53async function cloneSingleNode<T extends HTMLElement>(
54 node: T,
55 options: Options,
56): Promise<HTMLElement> {
57 if (isInstanceOfElement(node, HTMLCanvasElement)) {
58 return cloneCanvasElement(node)
59 }
60
61 if (isInstanceOfElement(node, HTMLVideoElement)) {
62 return cloneVideoElement(node, options)
63 }
64
65 if (isInstanceOfElement(node, HTMLIFrameElement)) {
66 return cloneIFrameElement(node, options)
67 }
68
69 return node.cloneNode(isSVGElement(node)) as T
70}
71
72const isSlotElement = (node: HTMLElement): node is HTMLSlotElement =>
73 node.tagName != null && node.tagName.toUpperCase() === 'SLOT'

Callers 1

cloneNodeFunction · 0.85

Calls 5

isInstanceOfElementFunction · 0.90
cloneCanvasElementFunction · 0.85
cloneVideoElementFunction · 0.85
cloneIFrameElementFunction · 0.85
isSVGElementFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…