natemoo-re / micromorph

A very tiny library for diffing DOM nodes

Home Page:https://stackblitz.com/edit/micromorph-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong element is getting event listeners.

necat1 opened this issue · comments

When I have div with click event listener:
<div id="1"></div>
And I construct new document with added div above previous one, so new document looks like:

<div></div>
<div id="1"></div>

So when i replace current document with new document, event listener is now on div without id, and div with id 1 has no event listener:

diff(document, newDoc);

But when div with id is above the newly added element, than the div keeps the event listener like expected:

<div id="1"></div>
<div></div>