Skip to content

Instantly share code, notes, and snippets.

@nblackburn nblackburn/walkDom.js
Last active Nov 5, 2017

Embed
What would you like to do?
module.exports = (node, callback) => {
if (node.childNodes) {
for (let index = 0; index < node.childNodes.length; index++) {
const child = node.childNodes[index]
const next = callback(child)
if (!next) {
walk(child, callback)
}
}
}
if (node.shadowRoot) {
walk(node.shadowRoot, callback)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.