In the old code, Observable.fireEvent used fireDirect which looked like this:
See that if the handler does not explicitly return false the event firing code returns true, and if you write your Observable subclass so that handlers may veto the operation by explicitly returning false - your code will still execute if no return statement is executed.
The new code is:
It just needs "return true;" adding to the end!
YAHOO.util.CustomEvent.prototype.fireDirect = function(){ var len=this.subscribers.length; for (var i=0; i<len; ++i) { var s = this.subscribers[i]; if(s){ var scope = (s.override) ? s.obj : this.scope; if(s.fn.apply(scope, arguments) === false){ return false; } } } return true; };
The new code is:
fire : function(){ var args = Array.prototype.slice.call(arguments, 0); var ls = this.listeners, scope; for(var i = 0, len = ls.length; i < len; i++){ var l = ls[i]; if(l.fireFn.apply(l.scope, arguments) === false){ return false; } } }

#2
![]() |
![]() I added it. Personally, I always check === or !== but I am paranoid.
![]() ![]() |