cferdinandi / reef

A lightweight library for creating reactive, state-based components and UI.

Home Page:https://reefjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Second event handler not correctly registered

stephanebisson opened this issue · comments

It appears that on an element having more than one event handlers (on* attributes), the second one is not correctly registered but the first and third ones are. I haven't tried with more than 3.

Test case: https://codepen.io/stephanebisson/pen/yLrWgzL?editors=1010

The issue causing the second item to be skipped is that the previous attributes are being removed while the loop is still running. To fix this, we should wait until after the loop has finished to remove the attributes.

for (let {name, value} of elem.attributes) {
// If the attribute should be skipped, remove it
if (skipAttribute(name, value)) {
removeAttribute(elem, name);
listen(elem, name, value, events);
continue;
}