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

ngAnimate cause errors after updating to 1.3 (Cannot read property 'parentNode' of undefined) #9953

Closed
clakech opened this issue Nov 7, 2014 · 7 comments

Comments

@clakech
Copy link
Contributor

clakech commented Nov 7, 2014

Hi,

We migrate our codebase from 1.2 to 1.3 and we have a strange error with ngAnimate now.

Everything was working fine before but since we update to 1.3 we have weird errors in console at angular-animate.js:1201:41 in method setClass:

TypeError: Cannot read property 'parentNode' of undefined
    at http://localhost:9000/angular-animate/angular-animate.js:1201:41
    at http://localhost:9000/angular-animate/angular-animate.js:538:22
    at Scope.$digest (http://localhost:9000/angular/angular.js:14002:36)
    at Scope.$apply (http://localhost:9000/angular/angular.js:14214:24)
    at done (http://localhost:9000/angular/angular.js:9474:47)
    at completeRequest (http://localhost:9000/angular/angular.js:9659:7)
    at XMLHttpRequest.requestLoaded (http://localhost:9000/angular/angular.js:9602:9) 

All this stack is inside angularjs and we are not enough confident to explain why we face those errors.

Seems like a breaking change in the 1.3 cause those issues.

If we remove ngAnimate from loaded modules, everything works fine but we don't have fancy animations anymore of course :(

We plan to work on a jsbin/jsfiddle to reproduce the problem on a code base with less than 12000+ loc...

If you have any idea about this issue, please your help is welcome 😃

Regards

@caitp
Copy link
Contributor

caitp commented Nov 7, 2014

if I had to guess, I'd say this is probably somewhere where you've got an ng-if or ng-repeat or other element transclusion directive, probably on the same element as your ng-class (from the stack trace, it looks like it's probably that).

@caitp
Copy link
Contributor

caitp commented Nov 7, 2014

Would you care to submit a patch to make ngAnimate a bit more careful? Also a similar bug may appear in the core ng package too

@clakech
Copy link
Contributor Author

clakech commented Nov 7, 2014

Thx for your help,

removing every ng-class from the code doesn't help and we still have the problem ;)

We just begin a dichotomy method map reduce across the team to find with part of the app/directives is the source of our problem.

If we feel confident to submit a patch, we would love to do so!

@caitp
Copy link
Contributor

caitp commented Nov 7, 2014

ng-class isn't necessarily the problem, there are lots of core directives which will use the $animate.setClass api --- could be ng-show or ng-hide, ng-cloak, ng-model, lots of things.

I believe the issue relates to element transclusion, because it looks like what's happening is the class changes are being registered before the element is being removed from the DOM --- in the case of element transclusion, you'd still have an "element", but it would be a comment node, and the filter-out-comment-nodes routine would fail.

@clakech
Copy link
Contributor Author

clakech commented Nov 7, 2014

It seems like the problem is coming from the presence of a name attribute on an input inside a form.

Removing this input solve the error, but then we can't validate our form properly. Now we can really work on a jsbin since we have isolate the problem.

@clakech
Copy link
Contributor Author

clakech commented Nov 10, 2014

You can reproduce this problem in this jsbin: http://jsbin.com/zamuca/5/edit?html,js,output

Seems like having a input with name 'nodeType' is the source of the problem because nodeType is a reserved word in angularjs world. But it is a functionnal name in our world so we have to find a workaround now.

We are working on a less verbose jsbin to reproduce this problem

@clakech
Copy link
Contributor Author

clakech commented Nov 10, 2014

Here a simple jsbin to reproduce the root of our error: http://jsbin.com/bikaxo/10/edit?html,js,output

Using a directive with require: '^form' that generate an input with name 'nodeType' in a form cause the app to crash forever...

Since the root cause of this issue change a lot and does not depends on ngAnimate, we close can close this one and create a brand new other one.

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

No branches or pull requests

2 participants