patrick-steele-idem / morphdom

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

Simulating `onNodeMoved` handler? #120

Open hrb90 opened 6 years ago

hrb90 commented 6 years ago

Hi,

We're trying to build a micro-framework on top of morphdom, but we're having trouble keeping track of our components' children when a component moves from one part of the DOM to another. If we discard or add nodes things are working fine, but since our elements are keyed, just moving around the DOM doesn't trigger an onNodeDiscarded or onNodeAdded callback. Is there a way we can use the onBeforeElUpdated or onBeforeElChildrenUpdated options to simulate an onNodeMoved handler?

Thanks!

AutoSponge commented 6 years ago

onNodeAdded should fire regardless unless you're trying to track a child of an element that moved in which case the parent and all children move and only the parent will trigger. Can you provide a demo of the problem you're seeing?

hrb90 commented 6 years ago

That may be what's happening; I'll try to put together a simple self-contained example at some point this weekend or early next week and get back to you.