Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ngAnimate: lookUpAnimations function breaks if CSS class is an Array.prototype function name. #11619

Closed
rvignacio opened this issue Apr 16, 2015 · 3 comments

Comments

@rvignacio
Copy link

Hello, I'm having a problem with the lookUpAnimations function in src/ngAnimate/animateJs.js. It iterates over the CSS classes of the element and gets the registered animation provider:

// Extract from src/ngAnimate/animateJs.js#L241
var klass = classes[i],
    animationFactory = $animateProvider.$$registeredAnimations[klass];
if (animationFactory && !flagMap[klass]) {
  matches.push($injector.get(animationFactory));
  flagMap[klass] = true;
}

My element has a CSS class named "filter" so, when doing:
animationFactory = $animateProvider.$$registeredAnimations[klass];
the animationFactory variable ends up being a reference to Array.prototype.filter (because $$registeredAnimations is of type Array). After that, I got an unknown provider exception because it calls $injector.get() with the filter function.

I already changed the CSS class, but shouldn't $$registeredAnimations be just a plain object (like Object.create(null)) instead of an Array if it's going to be used that way?

Thoughts?

@nicoabie
Copy link
Contributor

@matsko is the guru of the animations, he will help us out!

matsko added a commit to matsko/angular.js that referenced this issue Apr 17, 2015
The lookup type was an array before, but it should be an empty object.

Closes angular#11619
matsko added a commit to matsko/angular.js that referenced this issue Apr 17, 2015
The lookup type was an array before, but it should be an empty object.

Closes angular#11619
matsko added a commit to matsko/angular.js that referenced this issue Apr 17, 2015
The lookup type was an array before, but it should be an empty object.

Closes angular#11619
@matsko matsko closed this as completed in 103a39c Apr 17, 2015
@matsko
Copy link
Contributor

matsko commented Apr 17, 2015

This is fixed now. Thank you for pointing this out.

@rvignacio
Copy link
Author

You're welcome, thanks for the quick fix!

netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
The lookup type was an array before, but it should be an empty object.

Closes angular#11619
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants