Closed kevinresol closed 3 years ago
class Main extends View { @:state var mystate:Int = 1; function render() ' <div> <p>State: ${mystate}</p> <Menu onClick=${getClick(mystate)}/> <button onclick=${toggle}>Toggle</button> </div> '; function toggle() { mystate++; } inline function getClick(state:Int):Void->Void { trace('compute ${state}'); return state == 1 ? function() trace('clicked') : null; } static function main() { mount(document.getElementById('app'), hxx('<Main/>')); } } class Menu extends View { @:attr var onClick:Void->Void = null; function render() ' <div> <Button onClick=${onClick}/> </div> '; } class Button extends View { @:attr var onClick:Void->Void = null; function render() ' <button onclick=${onClick}>Button</button> '; }
Expected behavior
Actual behavior: At step 4: getClick is never called with state = 2 and clicking "Button" will still trace "clicked"
getClick
Note: I found that the <div> in Menu is critical. Removing it will make it behave as expected.
<div>
Menu
vdom version 35a8d8d88553058151da69af3719a945df55894a dependencies should be at latest git head as at time of writing
Another note: Removing <p>State: ${mystate}</p> fixes it too
<p>State: ${mystate}</p>
Expected behavior
Actual behavior:
At step 4:
getClick
is never called with state = 2 and clicking "Button" will still trace "clicked"Note: I found that the
<div>
inMenu
is critical. Removing it will make it behave as expected.vdom version 35a8d8d88553058151da69af3719a945df55894a dependencies should be at latest git head as at time of writing