|
|
|
|
|
by leipert
1801 days ago
|
|
Looks interesting! Kudos on the well documented source, benchmark and website. Are Caldom instances itself always synced with the DOM? e.g. If I create a Caldom instance for all ‘button’ and add an event handler for ‘click’. Now another piece of JavaScript adds a button to the page, will the event handler also trigger for that button or just the buttons when I first instantiated Caldom? |
|
No, it's not synced. When you use CalDOM without its reactive features, it's just a wrapper around the native DOM Element (similar to jQuery).
_("button").elem === document.querySelectorAll("button")[0]
Regarding capturing events of future elements: You can achieve this by setting an event listener to the parent.
Eg:
_("body").on("click", e => { if( e.target.matches("button") ) //Do something });