DylanPiercey / set-dom

📑 Lightweight dom diffing with plain old html.
MIT License
185 stars 20 forks source link

Ability to copy events handlers #13

Closed devmondo closed 8 years ago

devmondo commented 8 years ago

hi again,

can we copy the events handlers? morphdom does it automatically somehow!

DylanPiercey commented 8 years ago

@devmondo, curious what are you using to set the event handlers in the first place?

devmondo commented 8 years ago

simple

let b1 = document.createElement(`button`);
b1.innerHTML = `click me`;
b1.addEventListener(`click`, (e) => {

    console.log(`i am clicked`);
})
DylanPiercey commented 8 years ago

Currently this is out of scope for this module. As stated before I recommend that you use event delegation for all events since it is more predictable and typically more performant.

Check out https://github.com/component/delegate, https://github.com/zenorocha/delegate or event jquery for good event delegation.

devmondo commented 8 years ago

thanks