-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transferrable Events #2
Comments
This sounds perfect ❤️ |
Sounds great to me, though I'll admit it's a bit over my head. Reading it, though, reminded me of two things: (1) this comment in morphdom, and (2) fairly certain throw-down uses unique IDs on its elements as well. Perhaps both those points are irrelevant, but thought I'd share them just in case. Thanks for working on this, @shama. |
@timwis Thanks! The idea is this:
I have the basic idea implemented here: https://github.com/shama/on-load/blob/transferrable-events/index.js and it seems to work great so far. I have some more optimization ideas to try though. |
Published as It simplified shama/modal-element@8f54783 quite a bit. :D |
this is awesome @shama ! |
w00t! 🎉 |
Woah, you're done already?! Nice! Thanks for breaking it down. Just threw it into my choo app in 30 seconds and it seems to be working great. |
Currently it fires events based on if the element registered matches. Element references can get lost, fairly easily in complex DOM changes.
So instead, what if we generate a unique id, set with
el.dataset['onloadid'] = uniqid
then match elements based on that id. This way, it doesn't matter what happens to the element reference, if it has a matching event id the event is triggered./cc @yoshuawuyts @freeman-lab
The text was updated successfully, but these errors were encountered: