anthonyshort / deku

Render interfaces using pure functions and virtual DOM
https://github.com/anthonyshort/deku/tree/master/docs
3.41k stars 130 forks source link

Recursion problem #344

Closed rstacruz closed 8 years ago

rstacruz commented 8 years ago

I tried making a test case of #343 here. It fails with "too much recursion" (v2.0.0-rc7).

https://jsfiddle.net/wuc48347/

Here's how it should work: https://jsfiddle.net/q7hsuqmp/1/ (using decca@1.0.0)

Yomguithereal commented 8 years ago

The problem here is due to the lowercase onclick rather than onClick. The causes are rather obscure but I am gonna investigate.

anthonyshort commented 8 years ago

I think it's because when we see a function as a value for an attribute, we call the function to get the attribute value. This functionality really isn't needed now and should be removed. The idea was that you'd get given the real DOM element when it was called.

I didn't notice the lowercase, that would be the issue. As soon as it sets the attribute, it's calling the rerender. So it'll be an infinite loop.

Yomguithereal commented 8 years ago

Yup, this seems to be the case here.

anthonyshort commented 8 years ago

This is fixed in rc10

rstacruz commented 8 years ago

FYI: I updated onclick to onClick, yet the problem still persists. This is v2.0.0-rc7. https://jsfiddle.net/rstacruz/wuc48347/1/

Here it is using v2.0.0-rc10, which now works properly. https://jsfiddle.net/rstacruz/wuc48347/3/