From 452607fc64b2b0ba5ee9a8745746e652ae21b6db Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 24 Aug 2011 18:36:35 -0700 Subject: [PATCH] fix(events): fixing IE specific issues IE doesn't have Array#indexOf and [].splice.call doesn't work there either. --- src/Scope.js | 7 ++++--- test/ScopeSpec.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Scope.js b/src/Scope.js index 12ac2833e59f..badfc3f55951 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -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); } }, diff --git a/test/ScopeSpec.js b/test/ScopeSpec.js index b3bdf9353299..4f6293d06245 100644 --- a/test/ScopeSpec.js +++ b/test/ScopeSpec.js @@ -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']); }); }); });