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

Strange behavior with siblings with onClick #358

Closed thriqon closed 8 years ago

thriqon commented 8 years ago

I have this example: http://jsbin.com/famezem/3/edit?html,js Basically, it uses 2.0.0-rc8 to render two buttons, and overall clicks are counted.

However, it a) only updates the left button, and the click count does not increase by one, but doubles! This is caused by additional event listeners registered on that button.They are not removed during a render, because the previousValue passed to setAttribute is the handler for the right button , which is not removable from the left...

Am I doing something wrong here or is this a bug?

rstacruz commented 8 years ago

is this the behavior you're expecting? https://jsfiddle.net/rstacruz/uqtqhq55/

thriqon commented 8 years ago

Yes,exactly :)

rstacruz commented 8 years ago

jsbin wasn't working for me, so I pasted your example into jsfiddle. https://jsfiddle.net/rstacruz/dzc9gcyt/ @anthonyshort? :)

thriqon commented 8 years ago

FYI, if I change the definition of MyButton to the new function-only components introduced in rc8, it works as designed, compare https://jsfiddle.net/b6gk44kq/1/ and https://jsfiddle.net/b6gk44kq/3/

anthonyshort commented 8 years ago

I'll have a look at this issue soon, sorry about the delay!

thriqon commented 8 years ago

No worries, thanks anyways!

thriqon commented 8 years ago

Apparently also fixed in rc9 with https://github.com/dekujs/deku/commit/922634f9edf9383d6b1f6231797b5ad585f8a7f3 (in response to #366), now behaving as expected. Thanks!

anthonyshort commented 8 years ago

Great! Thanks for updating the issue