From de082c453fe5b1a3635b518fefb2aa22a37ecbab Mon Sep 17 00:00:00 2001 From: Georgios Kalpakas Date: Sun, 26 Jun 2016 21:07:58 +0300 Subject: [PATCH] fix($animate): do not get affected by custom, enumerable properties on `Object.prototype` Fixes #14804 --- src/ngAnimate/animateQueue.js | 2 +- test/ngAnimate/animateSpec.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ngAnimate/animateQueue.js b/src/ngAnimate/animateQueue.js index 344f2b5d278b..385de478a920 100644 --- a/src/ngAnimate/animateQueue.js +++ b/src/ngAnimate/animateQueue.js @@ -158,7 +158,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { } ); - var callbackRegistry = {}; + var callbackRegistry = Object.create(null); // remember that the classNameFilter is set during the provider/config // stage therefore we can optimize here and setup a helper function diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index c1de17ebbdd0..844bfdb02a0c 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1989,6 +1989,17 @@ describe("animations", function() { expect(count).toBe(5); })); + it('should not get affected by custom, enumerable properties on `Object.prototype`', + inject(function($animate) { + Object.prototype.foo = 'ENUMARABLE_AND_NOT_AN_ARRAY'; + + element = jqLite('
'); + expect(function() { $animate.off(element); }).not.toThrow(); + + delete Object.prototype.foo; + }) + ); + it('should fire a `start` callback when the animation starts with the matching element', inject(function($animate, $rootScope, $rootElement, $document) {