package.src.utils.walk.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alpinejs Show documentation
Show all versions of alpinejs Show documentation
The rugged, minimal JavaScript framework
export function walk(el, callback) {
if (typeof ShadowRoot === 'function' && el instanceof ShadowRoot) {
Array.from(el.children).forEach(el => walk(el, callback))
return
}
let skip = false
callback(el, () => skip = true)
if (skip) return
let node = el.firstElementChild
while (node) {
walk(node, callback, false)
node = node.nextElementSibling
}
}