D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
forge
/
ebrokers.online
/
node_modules
/
sweetalert2
/
src
/
staticMethods
/
Filename :
bindClickHandler.js
back
Copy
let bodyClickListenerAdded = false const clickHandlers = {} /** * @param {string} attr */ export function bindClickHandler(attr = 'data-swal-template') { clickHandlers[attr] = this if (!bodyClickListenerAdded) { document.body.addEventListener('click', bodyClickListener) bodyClickListenerAdded = true } } const bodyClickListener = (event) => { for (let el = event.target; el && el !== document; el = el.parentNode) { for (const attr in clickHandlers) { const template = el.getAttribute(attr) if (template) { clickHandlers[attr].fire({ template }) return } } } }