Sha256: 95c921098461f66a01ee9a5925e47dc62d0c8f68250fd3015c6d894ef9b99f61
Contents?: true
Size: 527 Bytes
Versions: 135
Compression:
Stored size: 527 Bytes
Contents
export function on(eventName, baseSelector, targetSelector, callback) { document.querySelectorAll(baseSelector).forEach((baseNode) => { baseNode.addEventListener(eventName, (evt) => { const targets = Array.from(baseNode.querySelectorAll(targetSelector)) let currentNode = evt.target while (currentNode !== baseNode) { if (targets.includes(currentNode)) { callback.call(currentNode, evt) return } currentNode = currentNode.parentElement } }) }) }
Version data entries
135 entries across 135 versions & 1 rubygems