Open Comandeer opened 5 years ago
This behaviour is quite confusing IMHO. But it kind of works as described in the docs:
Fires an specific event in the object, releasing all listeners registered to that event. The same listeners are not called again on successive calls of it or of fire.
so listeners are released as @Comandeer described. And in the given example above, new listeners are attached every time so the same listeners are not called again. So for me it somehow seems that it was intended to work like this, but then it should not be called fireOnce
. The method fireOnce
should work as @Comandeer described above (firing same event only once for the given object).
Type of report
Bug
Provide detailed reproduction steps (if any)
Expected result
myEvent listener #1
.Actual result
Every click logs
myEvent listener #<n>
.Other details
CKEDITOR.event#fireOnce
was introducedIn fact current implementation of
CKEDITOR.event#fireOnce
is just incorrect. Instead of preventing the subsequent firing of the event, it just removes all listeners. So basically event is fired, yet there are no listeners to do any action. Adding new listener afterfireOnce
adds new array of listeners, allowing to omit whole mechanism.