patrick-steele-idem / morphdom

Fast and lightweight DOM diffing/patching (no virtual DOM needed)
MIT License
3.14k stars 128 forks source link

onBeforeAttribute Removed/Added/Changed hooks ? #193

Open kapouer opened 4 years ago

kapouer commented 4 years ago

Hi, it'd be nice to be able to control those actions !

Typically i want to merge two nodes but keep original 'custom-*' attributes.

snewcomer commented 4 years ago

👋 It is possible that this might detract from performance if we have to add a lot of function calls to the stack. What are your thoughts?

kapouer commented 4 years ago

Well, do not call these hooks if they're not defined ? Besides i'm not sure function calls have a huge impact on performance.

semmel commented 4 years ago

If such a hook doesn't perform heavy lifting I don't see how it would impact the performance. It would typically just compare node ids or attribute names to a list and return true or false.

Perhaps such a hook would benefit me in excluding some updates to the class attribute of my Responsive Components. If you'd glance over the linked article you'd find that theses components style themselves using ResizeObserver and dynamically updating their class attribute. IMO this is not a task for morphdom, therefore I have to prevent it from interfering with the class attribute of such components.