component / reactive

Tiny reactive template engine
382 stars 48 forks source link

Dont process removed nodes #157

Closed yanatan16 closed 10 years ago

yanatan16 commented 10 years ago

In IE9, the following template will error:

<div data-html="some_state_var">text to be overwritten</div>

The reason is, in walk.js, var nodes = [].slice.call(el.childNodes) BEFORE process(el, next), which causes the nodes array to contain [TextNode('text to be overwritten')]. Once next() is called, however, that TextNode is now an orphan, having been removed through the data-html binding. On most browsers, this causes no problems. On IE9 however, it causes an Invalid Argument error when accessing el.data from index.js:270.

There is a larger problem here: the reactive bindings processing of deleted nodes, via data-html or otherwise. Two solutions exist:

reactive('<div data-html="testhtml"></div>', { testhtml: '<div data-html="testhtml"></div>' })

Thus, its clear that the right answer (to me anyway) is to not process deleted nodes.

yanatan16 commented 10 years ago

This doesn't work. I'll try again.

defunctzombie commented 10 years ago

haha ok :D