In Observable.js lines 287 (Ext.util.Event.addListener) and 315 (Ext.util.Event.removeListener) if this.firing is true, the following line is executed:
Code:
this.listeners = this.listeners.slice(0);
The above line appears to make a copy of an array and assign it to itself. Is there some subtle reason why that needs to be done?
The two examples in their entirety are:
inside addListener:
Code:
if(!this.firing){ // if we are currently firing this event, don't disturb the listener loop
this.listeners.push(l);
}else{
this.listeners = this.listeners.slice(0);
this.listeners.push(l);
}
and
inside removeListener:
Code:
if(!this.firing){
this.listeners.splice(index, 1);
}else{
this.listeners = this.listeners.slice(0);
this.listeners.splice(index, 1);
}
As an aside, the copying of arguments to variable args at line 331 appears to be redundant because args is never used:
Code:
var args = Array.prototype.slice.call(arguments, 0);
Regards,
Patrick