-
Bug
-
Resolution: Fixed
-
Normal
-
9.6.0, 9.6.0.1
-
Security Level: Jimmy
-
None
Steps to Reproduce
<zk> <button id="btn"/> </zk>
execute in the console
var b = zk.$('$btn'); b.detach(); b.fire('onCustomEvent', null, {toServer: true});
Current Result
browser tab gets stuck at 100% CPU in an infinite loop
Expected Result
fail with a (meaningful) error instead due to incorrect usage
Debug Information
the infinite loop happens here:
https://github.com/zkoss/zk/blob/v9.6.0/zk/src/archive/web/js/zk/au.ts#L139-L142
In the latest 9.6.1-FL-2021-09-28 the infinite loop code is not reached, instead NOTHING happens, no indication of an error (maybe also not the best outcome)
the potential infinite loop code is still there and needs to fail if called incorrectly
Workaround
don't fire events on detached components.
e.g. check manually whether the current widget is detached before firing the event
var b = zk.$('$btn'); b.detach(); if(b.parent && b.desktop) { b.fire('onCustomEvent', null, {toServer: true}); }