Skip to content

Instantly share code, notes, and snippets.

View gecugamo's full-sized avatar

Gary Cuga-Moylan gecugamo

View GitHub Profile
@heyMP
heyMP / utils.js
Last active June 11, 2024 18:30
Recursively find elements through multiple layers of shadow dom.
/**
* Example usage:
* const hotspots = findAllDeep(element, `[slot*="hotspot"]`, 10);
*/
const findAllDeep = (parent, selectors, depth = null) => {
let nodes = new Set();
let currentDepth = 1;
const recordResult = (nodesArray) => {
for (const node of nodesArray) {
nodes.add(node)