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

(bug) ngAnimate element.parent is not a function #11703

Closed
crisbeto opened this issue Apr 23, 2015 · 2 comments
Closed

(bug) ngAnimate element.parent is not a function #11703

crisbeto opened this issue Apr 23, 2015 · 2 comments

Comments

@crisbeto
Copy link
Member

I'm using version 1.4.0-rc.0 of ngAnimate and there's an issue when $animate.leave is called with a TextNode as an argument. Here's the stack trace:

TypeError: element.parent is not a function
    at queueAnimation (https://code.angularjs.org/1.4.0-rc.0/angular-animate.js:1991:28)
    at Object.push (https://code.angularjs.org/1.4.0-rc.0/angular-animate.js:1943:16)
    at Object.leave (https://code.angularjs.org/1.4.0-rc.0/angular.js:5017:31)
    at update (https://rawgit.com/rubenv/angular-gettext/master/dist/angular-gettext.js:198:34)
    at post (https://rawgit.com/rubenv/angular-gettext/master/dist/angular-gettext.js:207:21)
    at invokeLinkFn (https://code.angularjs.org/1.4.0-rc.0/angular.js:8416:9)
    at nodeLinkFn (https://code.angularjs.org/1.4.0-rc.0/angular.js:7925:11)
    at compositeLinkFn (https://code.angularjs.org/1.4.0-rc.0/angular.js:7326:13)
    at nodeLinkFn (https://code.angularjs.org/1.4.0-rc.0/angular.js:7920:24)
    at compositeLinkFn (https://code.angularjs.org/1.4.0-rc.0/angular.js:7326:13)

I've managed to isolate the issue in a Plunker and it appears to be caused by this line which returns a boolean (usually false) to the queueAnimation function. It then tries to call the parent method and throws the error.

In the Plunker posted above, the H1's text gets passed to the leave method by the translate directive. If the text is wrapped in another element, the error is gone. For example:

<h1 translate>hi</h1> <!-- breaks -->
<h1 translate> <!-- works -->
  <span>hi</span>
</h1> 

EDIT: Here's a better isolated example of the same issue: https://jsfiddle.net/pLvmf9qg/

@crisbeto crisbeto changed the title ngAnimate element.parent is not a function (bug) ngAnimate element.parent is not a function Apr 24, 2015
@circlingthesun
Copy link

@matsko, the issue appears to be that the ng-animate rewrite does not take into account text nodes. I've taken a stab at fixing it in my PR, but it appears I've not completely wrapped my head around ng-animate internals. Care to comment?

@Narretz Narretz added this to the 1.4.0-rc.2 milestone Apr 27, 2015
matsko added a commit to matsko/angular.js that referenced this issue May 4, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
With the large refactor in 1.4.0-rc.0, the detection code failed to
filter out text nodes from animating. This fix ensures that now properly
happens.

Closes angular#11703
matsko added a commit to matsko/angular.js that referenced this issue May 5, 2015
With the large refactor in 1.4.0-rc.0, the detection code failed to
filter out text nodes from animating. This fix ensures that now properly
happens.

Closes angular#11703
@matsko matsko closed this as completed in 2aacc2d May 5, 2015
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
With the large refactor in 1.4.0-rc.0, the detection code failed to
filter out text nodes from animating. This fix ensures that now properly
happens.

Closes angular#11703
@azachar
Copy link

azachar commented Apr 28, 2016

Hello, I am having a similar problem, with this stacktrace:

angular.js:12783 TypeError: element.parent is not a function
at queueAnimation (http://localhost:3000/bower_components/angular-animate/angular-animate.js:2425:26)
at Object.push (http://localhost:3000/bower_components/angular-animate/angular-animate.js:2377:16)
at Object.enter (http://localhost:3000/bower_components/angular/angular.js:5282:31)
at update (http://localhost:3000/bower_components/angular-gettext/dist/angular-gettext.js:156:34)
at post (http://localhost:3000/bower_components/angular-gettext/dist/angular-gettext.js:166:21)
at invokeLinkFn (http://localhost:3000/bower_components/angular/angular.js:9079:9)
at nodeLinkFn (http://localhost:3000/bower_components/angular/angular.js:8566:11)
at compositeLinkFn (http://localhost:3000/bower_components/angular/angular.js:7965:13)
at nodeLinkFn (http://localhost:3000/bower_components/angular/angular.js:8561:24)
at compositeLinkFn (http://localhost:3000/bower_components/angular/angular.js:7965:13)

Do you have any idea what might be wrong? I am not using any animations, perhaps ionic internally does.

Thanks for any advice!

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