Skip to content

Commit 021f124

Browse files
committed
feat(custom-elements): ✨ obtain children of shadow node for custom elements
Inspired by tsayen/dom-to-image#370 If element has `shadowRoot` property it is custom (and the shadow node is open) so fetch it's children. Closes bubkoo#128
1 parent ffc70d1 commit 021f124

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cloneNode.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ async function cloneChildren(
2727
clonedNode: HTMLElement,
2828
filter?: Function,
2929
): Promise<HTMLElement> {
30-
const children = toArray<HTMLElement>(nativeNode.childNodes)
30+
const children = toArray<HTMLElement>(
31+
(nativeNode.shadowRoot ?? nativeNode).childNodes,
32+
)
3133
if (children.length === 0) {
3234
return Promise.resolve(clonedNode)
3335
}

0 commit comments

Comments
 (0)