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

ng-animate breaks with ngMaterial #11658

Closed
borgdylan opened this issue Apr 20, 2015 · 26 comments
Closed

ng-animate breaks with ngMaterial #11658

borgdylan opened this issue Apr 20, 2015 · 26 comments

Comments

@borgdylan
Copy link

AN exception in angular-animate.js is allowing the creation of more than one ng-view instance in teh pnge.:

"Error: animationDetails.runner is undefined
closeChildAnimations/<@http://192.168.1.24:8087/angular-animate.js:2202:13
n@http://192.168.1.24:8087/angular.min.js:7:300
closeChildAnimations@http://192.168.1.24:8087/angular-animate.js:2197:7
queueAnimation@http://192.168.1.24:8087/angular-animate.js:2042:9
$$AnimateQueueProvider</this.$get</<.push@http://192.168.1.24:8087/angular-animate.js:1937:16
Ne</this.$get</<.leave@http://192.168.1.24:8087/angular.min.js:186:468
z@http://192.168.1.24:8087/angular-route.min.js:6:210
x/n<@http://192.168.1.24:8087/angular-route.min.js:6:456
T/<@http://192.168.1.24:8087/angular.min.js:52:320
S/<@http://192.168.1.24:8087/angular.min.js:54:282
m@http://192.168.1.24:8087/angular.min.js:58:484
x@http://192.168.1.24:8087/angular-route.min.js:6:364
df/this.$get</m.prototype.$broadcast@http://192.168.1.24:8087/angular.min.js:135:43
n/<@http://192.168.1.24:8087/angular-route.min.js:11:426
f/<@http://192.168.1.24:8087/angular.min.js:118:182
df/this.$get</m.prototype.$eval@http://192.168.1.24:8087/angular.min.js:132:217
df/this.$get</m.prototype.$digest@http://192.168.1.24:8087/angular.min.js:129:225
df/this.$get</m.prototype.$apply@http://192.168.1.24:8087/angular.min.js:132:497
@http://192.168.1.24:8087/angular-touch.min.js:12:106
n.event.dispatch@http://192.168.1.24:8087/jquery-2.1.1.min.js:3:6352
n.event.add/r.handle@http://192.168.1.24:8087/jquery-2.1.1.min.js:3:3162
"
@Narretz
Copy link
Contributor

Narretz commented Apr 20, 2015

Can you please provide more info, such as a runnable example that shows the problem?

@epixa
Copy link

epixa commented Apr 20, 2015

I encountered this exception today as well on 1.4.0-rc.0. We don't use ng-messages yet, so it's not necessarily related to that. I'm attempting an upgrade from 1.2, and the workflow that this is happening in is pretty complex, so I don't have a dumbed down enough example to make any sense of it, but I'll update this if/when I do.

@Narretz
Copy link
Contributor

Narretz commented Apr 20, 2015

You could try with the latest snapshot of 1.4 or wait for rc.1 that is coming later today. It includes quite a few animation fixes.

@epixa
Copy link

epixa commented Apr 20, 2015

I just checked it on build.3984, and it's still an issue there. I'll check out rc.1 when that is released.

@epixa
Copy link

epixa commented Apr 20, 2015

I just realized the original post included a trace from a minified angular, so here's one without minification:

Error: animationDetails.runner is undefined
closeChildAnimations/<@http://localhost/static/vendor/angular-animate/angular-animate.js:2202:13
forEach@http://localhost/static/vendor/angular/angular.js:332:11
closeChildAnimations@http://localhost/static/vendor/angular-animate/angular-animate.js:2197:7
queueAnimation@http://localhost/static/vendor/angular-animate/angular-animate.js:2042:9
$$AnimateQueueProvider</this.$get</<.push@http://localhost/static/vendor/angular-animate/angular-animate.js:1937:16
$AnimateProvider</this.$get</<.leave@http://localhost/static/vendor/angular/angular.js:5126:1
cleanupLastView@http://localhost/static/vendor/angular-route/angular-route.js:913:38
update/clone<@http://localhost/static/vendor/angular-route/angular-route.js:942:15
publicLinkFn@http://localhost/static/vendor/angular/angular.js:7308:29
createBoundTranscludeFn/boundTranscludeFn@http://localhost/static/vendor/angular/angular.js:7454:1
controllersBoundTransclude@http://localhost/static/vendor/angular/angular.js:8061:18
update@http://localhost/static/vendor/angular-route/angular-route.js:935:25
$RootScopeProvider/this.$get</Scope.prototype.$broadcast@http://localhost/static/vendor/angular/angular.js:15893:15
commitRoute/<@http://localhost/static/vendor/angular-route/angular-route.js:618:15
processQueue@http://localhost/static/vendor/angular/angular.js:14347:28
scheduleProcessQueue/<@http://localhost/static/vendor/angular/angular.js:14363:27
$RootScopeProvider/this.$get</Scope.prototype.$eval@http://localhost/static/vendor/angular/angular.js:15574:16
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://localhost/static/vendor/angular/angular.js:15385:15
$RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost/static/vendor/angular/angular.js:15679:13
done@http://localhost/static/vendor/angular/angular.js:10166:36
completeRequest@http://localhost/static/vendor/angular/angular.js:10338:7
requestLoaded@http://localhost/static/vendor/angular/angular.js:10279:1

@matsko
Copy link
Contributor

matsko commented Apr 20, 2015

Are you guys by chance using bower? Sometimes there's a version mismatch where the core version of Angular differs from the animate version. Can you double check on that please?

@epixa
Copy link

epixa commented Apr 20, 2015

I am using bower, and I have both angular-animate and angular (and all of the angular modules, in fact) set explicitly as 1.4.0-rc.0

@matsko
Copy link
Contributor

matsko commented Apr 20, 2015

OK. Can you post a plnkr example? Maybe we can get this out the door in time for RC1.

@matsko
Copy link
Contributor

matsko commented Apr 20, 2015

Actually @borgdylan can you test this out on master using the snapshot build of angular: https://code.angularjs.org/snapshot/angular.js and https://code.angularjs.org/snapshot/angular-animate.js. #11620 did fix something similar here.

@epixa
Copy link

epixa commented Apr 20, 2015

Having a hell of a time reproducing this with a simpler example on plnkr, so I'm kind of hoping @borgdylan has more luck.

If it helps, feel free to use my plnkr as a jumping off point: http://plnkr.co/edit/Tw8aKVY1PRD90qjp7KLt

@borgdylan
Copy link
Author

I found the issue using the latest git masters of both angular and angular-material. I do not have a small example to reproduce it (this happened in a large project). However I did manage to patch the angular-animate.js file to make the problem go away.

@philBrown
Copy link
Contributor

This doesn't seem to be related to ngMaterial. Here's a very simple example using only ngAnimate and ngRoute ~ http://plnkr.co/edit/mAqeERAPox7uyypYceFG?p=preview

Steps: Focus in the text box, type something, hit enter.

This produces the following error

Cannot read property 'end' of undefined

for this line in closeChildAnimations

case RUNNING_STATE:
        animationDetails.runner.end(); // <- this line

The runner that appears to have been removed is for Bootstrap's border transition on .form-control.

I also get the same error using ui-router so it's not ngRoute specific either.

@Narretz
Copy link
Contributor

Narretz commented Apr 23, 2015

@philBrown I can't reproduce this error in FF or Chrome

@epixa
Copy link

epixa commented Apr 23, 2015

@philBrown That does indeed recreate the exact error stack I had listed earlier. In firefox, the message is animationDetails.runner is undefined, but it's the same error. Thanks for figuring out how to reproduce it.

@Narretz I was able to reproduce the issue consistently using @philBrown's plnkr and following his exact steps (focus, type some characters, hit enter) in Firefox 37.

@philBrown
Copy link
Contributor

Seems to be related to ngModel somehow; without the model, the issue doesn't arise.

I guess having the model adds it to the list of children with animations to close (those with the data-ng-animate attribute). The form is in that list too which I guess means it's all child elements with a controller?

@Narretz I get the issue on Linux in both Firefox 37.0.1 and Chrome 42.0.2311.90 (64-bit)

@philBrown
Copy link
Contributor

Testing further, it's got nothing to do with transitions on the form control (I figured that was the problem because it's an $animate issue).

I've removed the Bootstrap CSS and it still occurs.

If you don't type anything in to the text field and hit Enter, it works correctly. If you click the submit button, it works correctly.

The only thing that causes the issue is typing into the text field (thus toggling the model controller $dirty / $pristine flags) and hitting Enter to trigger the form submission which in turn triggers the animation for route transition.

I've updated the Plunker to reflect this - http://plnkr.co/edit/mAqeERAPox7uyypYceFG?p=preview

@TroelsL
Copy link

TroelsL commented Apr 24, 2015

I've been having a similar issue. I've posted on StackOverflow on it here:

http://stackoverflow.com/questions/29740618/angular-animate-runner-is-undefined

My stack trace is:

TypeError: Cannot read property 'end' of undefined 
at VM2885 angular-animate.js:2209
at forEach (angular.js:332)
at closeChildAnimations (VM2885 angular-animate.js:2202)
at queueAnimation (VM2885 angular-animate.js:2048)
at Object.$$AnimateQueueProvider.$get.push (VM2885 angular-animate.js:1943)
at Object.$AnimateProvider.$get.leave (angular.js:5017)
at cleanupLastView (angular-route.js:913)
at angular-route.js:942
at publicLinkFn (angular.js:7199)
at $get.boundTranscludeFn (angular.js:7345)

@petebacondarwin
Copy link
Contributor

I think that this might be related to another bug I found:
http://plnkr.co/edit/uPSFDPhLQ4CIDWpxGCG6?p=preview

If you click on the Home link when it is already active then $animate fails to remove the data-ng-animate="1" attribute.

In the plunker provided by @philBrown it seems a similar thing is happening. If you look the input still has data-ng-animate="2" attached, even though I believe $animate has already "completed" this animation.

@matsko
Copy link
Contributor

matsko commented Apr 25, 2015

Looking at it now. Thanks guys.

@borgdylan
Copy link
Author

The bug is still present in the latest master. Simply checking if animationDetails.runner is defined before accessing patches the issue.

matsko added a commit to matsko/angular.js that referenced this issue Apr 29, 2015
…perly

Prior to this fix if a form DOM element was fed into parts of the
ngAnimate queuing code it would attempt to detect if it is a jqLite
object in an unstable way which would allow a form element to return an
inner input element by index. This patch ensures that jqLite instances
are properly detected using a helper method.

Closes angular#11658
matsko added a commit to matsko/angular.js that referenced this issue Apr 29, 2015
…perly

Prior to this fix if a form DOM element was fed into parts of the
ngAnimate queuing code it would attempt to detect if it is a jqLite
object in an unstable way which would allow a form element to return an
inner input element by index. This patch ensures that jqLite instances
are properly detected using a helper method.

Closes angular#11658
@matsko
Copy link
Contributor

matsko commented Apr 29, 2015

Here's a PR for the fix: #11760

Turns it that <form> elements are to blame. If you access a form DOM node with an array index (like form[0]) then it returns the input element based on the index. We were using the element[index] trick to break out of jqLite/jQuery. This has now been fixed.

@philBrown
Copy link
Contributor

Ah, good old document.forms.

@matsko nice work!

@TroelsL
Copy link

TroelsL commented Apr 30, 2015

Brilliant and speedy resolution, thanks!

Now that I come to think of it, it did start happening as I added a form to my page. I apologize for neglecting to mention this detail earlier.

@matsko
Copy link
Contributor

matsko commented Apr 30, 2015

No worries. I didn't want to patch it with just an if statement and I knew that there was something fishy going on. I learned a lot from this issue.

@petebacondarwin
Copy link
Contributor

Nice work @matsko !!

@epixa
Copy link

epixa commented Apr 30, 2015

Most excellent, thanks @matsko

matsko added a commit to matsko/angular.js that referenced this issue May 5, 2015
…perly

Prior to this fix if a form DOM element was fed into parts of the
ngAnimate queuing code it would attempt to detect if it is a jqLite
object in an unstable way which would allow a form element to return an
inner input element by index. This patch ensures that jqLite instances
are properly detected using a helper method.

Closes angular#11658
matsko added a commit to matsko/angular.js that referenced this issue May 5, 2015
…perly

Prior to this fix if a form DOM element was fed into parts of the
ngAnimate queuing code it would attempt to detect if it is a jqLite
object in an unstable way which would allow a form element to return an
inner input element by index. This patch ensures that jqLite instances
are properly detected using a helper method.

Closes angular#11658
@matsko matsko closed this as completed in 64d0518 May 5, 2015
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
…perly

Prior to this fix if a form DOM element was fed into parts of the
ngAnimate queuing code it would attempt to detect if it is a jqLite
object in an unstable way which would allow a form element to return an
inner input element by index. This patch ensures that jqLite instances
are properly detected using a helper method.

Closes angular#11658
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.