From 404d85e0c6a3fc18bfcf0960509d4219e16df8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Fri, 17 Apr 2015 14:25:21 -0700 Subject: [PATCH] fix($animate): make sure the JS animation lookup is an object lookup The lookup type was an array before, but it should be an empty object. Closes #11619 --- src/ng/animate.js | 2 +- test/ng/animateSpec.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ng/animate.js b/src/ng/animate.js index 2a9b6e0d549b..e105de1ab28f 100644 --- a/src/ng/animate.js +++ b/src/ng/animate.js @@ -163,7 +163,7 @@ var $$CoreAnimateQueueProvider = function() { var $AnimateProvider = ['$provide', function($provide) { var provider = this; - this.$$registeredAnimations = []; + this.$$registeredAnimations = Object.create(null); /** * @ngdoc method diff --git a/test/ng/animateSpec.js b/test/ng/animateSpec.js index f1ae31686f82..0211bb44ae17 100644 --- a/test/ng/animateSpec.js +++ b/test/ng/animateSpec.js @@ -115,6 +115,21 @@ describe("$animate", function() { inject(); }); + it("should register the animation and be available for lookup", function() { + var provider; + module(function($animateProvider) { + provider = $animateProvider; + }); + inject(function() { + // by using hasOwnProperty we know for sure that the lookup object is an empty object + // instead of inhertiting properties from its original prototype. + expect(provider.$$registeredAnimations.hasOwnProperty).toBeFalsy(); + + provider.register('.filter', noop); + expect(provider.$$registeredAnimations['filter']).toBe('.filter-animation'); + }); + }); + it("should apply and retain inline styles on the element that is animated", inject(function($animate, $rootScope) { var element = jqLite('
'); var parent = jqLite('
');