fix(events): fixing IE specific issues

IE doesn't have Array#indexOf and [].splice.call doesn't work there
either.
This commit is contained in:
Igor Minar 2011-08-24 18:36:35 -07:00
parent 19401280ae
commit 452607fc64
2 changed files with 5 additions and 4 deletions

View file

@ -569,10 +569,11 @@ Scope.prototype = {
* @param {function} listener Function to remove.
*/
$removeListener: function(name, listener) {
var namedListeners = this.$$listeners[name];
var i;
var namedListeners = this.$$listeners[name],
i;
if (namedListeners) {
i = namedListeners.indexOf(listener);
i = indexOf(namedListeners, listener);
namedListeners.splice(i, 1);
}
},

View file

@ -596,7 +596,7 @@ describe('Scope', function() {
scope.$broadcast('fooEvent', 'do', 're', 'me', 'fa');
expect(args.length).toBe(5);
expect([].splice.call(args, 1)).toEqual(['do', 're', 'me', 'fa']);
expect(sliceArgs(args, 1)).toEqual(['do', 're', 'me', 'fa']);
});
});
});