@@ -381,7 +381,7 @@ var $$AnimateQueueProvider = ['$animateProvider', /** @this */ function($animate
381
381
// there is no point in traversing the same collection of parent ancestors if a followup
382
382
// animation will be run on the same element that already did all that checking work
383
383
if ( ! skipAnimations && ( ! hasExistingAnimation || existingAnimation . state !== PRE_DIGEST_STATE ) ) {
384
- skipAnimations = ! areAnimationsAllowed ( element , parent , event ) ;
384
+ skipAnimations = ! areAnimationsAllowed ( node , getDomNode ( parent ) , event ) ;
385
385
}
386
386
387
387
if ( skipAnimations ) {
@@ -610,65 +610,61 @@ var $$AnimateQueueProvider = ['$animateProvider', /** @this */ function($animate
610
610
activeAnimationsLookup . remove ( node ) ;
611
611
}
612
612
613
- function isMatchingElement ( nodeOrElmA , nodeOrElmB ) {
614
- return getDomNode ( nodeOrElmA ) === getDomNode ( nodeOrElmB ) ;
615
- }
616
-
617
613
/**
618
614
* This fn returns false if any of the following is true:
619
615
* a) animations on any parent element are disabled, and animations on the element aren't explicitly allowed
620
616
* b) a parent element has an ongoing structural animation, and animateChildren is false
621
617
* c) the element is not a child of the body
622
618
* d) the element is not a child of the $rootElement
623
619
*/
624
- function areAnimationsAllowed ( element , parentElement , event ) {
625
- var bodyElement = jqLite ( $document [ 0 ] . body ) ;
626
- var bodyElementDetected = isMatchingElement ( element , bodyElement ) || element [ 0 ] . nodeName === 'HTML' ;
627
- var rootElementDetected = isMatchingElement ( element , $rootElement ) ;
620
+ function areAnimationsAllowed ( node , parentNode , event ) {
621
+ var bodyNode = $document [ 0 ] . body ;
622
+ var rootNode = getDomNode ( $rootElement ) ;
623
+
624
+ var bodyNodeDetected = ( node === bodyNode ) || node . nodeName === 'HTML' ;
625
+ var rootNodeDetected = ( node === rootNode ) ;
628
626
var parentAnimationDetected = false ;
627
+ var elementDisabled = disabledElementsLookup . get ( node ) ;
629
628
var animateChildren ;
630
- var elementDisabled = disabledElementsLookup . get ( getDomNode ( element ) ) ;
631
629
632
- var parentHost = jqLite . data ( element [ 0 ] , NG_ANIMATE_PIN_DATA ) ;
630
+ var parentHost = jqLite . data ( node , NG_ANIMATE_PIN_DATA ) ;
633
631
if ( parentHost ) {
634
- parentElement = parentHost ;
632
+ parentNode = getDomNode ( parentHost ) ;
635
633
}
636
634
637
- parentElement = getDomNode ( parentElement ) ;
638
-
639
- while ( parentElement ) {
640
- if ( ! rootElementDetected ) {
635
+ while ( parentNode ) {
636
+ if ( ! rootNodeDetected ) {
641
637
// angular doesn't want to attempt to animate elements outside of the application
642
638
// therefore we need to ensure that the rootElement is an ancestor of the current element
643
- rootElementDetected = isMatchingElement ( parentElement , $rootElement ) ;
639
+ rootNodeDetected = ( parentNode === rootNode ) ;
644
640
}
645
641
646
- if ( parentElement . nodeType !== ELEMENT_NODE ) {
642
+ if ( parentNode . nodeType !== ELEMENT_NODE ) {
647
643
// no point in inspecting the #document element
648
644
break ;
649
645
}
650
646
651
- var details = activeAnimationsLookup . get ( parentElement ) || { } ;
647
+ var details = activeAnimationsLookup . get ( parentNode ) || { } ;
652
648
// either an enter, leave or move animation will commence
653
649
// therefore we can't allow any animations to take place
654
650
// but if a parent animation is class-based then that's ok
655
651
if ( ! parentAnimationDetected ) {
656
- var parentElementDisabled = disabledElementsLookup . get ( parentElement ) ;
652
+ var parentNodeDisabled = disabledElementsLookup . get ( parentNode ) ;
657
653
658
- if ( parentElementDisabled === true && elementDisabled !== false ) {
654
+ if ( parentNodeDisabled === true && elementDisabled !== false ) {
659
655
// disable animations if the user hasn't explicitly enabled animations on the
660
656
// current element
661
657
elementDisabled = true ;
662
658
// element is disabled via parent element, no need to check anything else
663
659
break ;
664
- } else if ( parentElementDisabled === false ) {
660
+ } else if ( parentNodeDisabled === false ) {
665
661
elementDisabled = false ;
666
662
}
667
663
parentAnimationDetected = details . structural ;
668
664
}
669
665
670
666
if ( isUndefined ( animateChildren ) || animateChildren === true ) {
671
- var value = jqLite . data ( parentElement , NG_ANIMATE_CHILDREN_DATA ) ;
667
+ var value = jqLite . data ( parentNode , NG_ANIMATE_CHILDREN_DATA ) ;
672
668
if ( isDefined ( value ) ) {
673
669
animateChildren = value ;
674
670
}
@@ -677,33 +673,33 @@ var $$AnimateQueueProvider = ['$animateProvider', /** @this */ function($animate
677
673
// there is no need to continue traversing at this point
678
674
if ( parentAnimationDetected && animateChildren === false ) break ;
679
675
680
- if ( ! bodyElementDetected ) {
676
+ if ( ! bodyNodeDetected ) {
681
677
// we also need to ensure that the element is or will be a part of the body element
682
678
// otherwise it is pointless to even issue an animation to be rendered
683
- bodyElementDetected = isMatchingElement ( parentElement , bodyElement ) ;
679
+ bodyNodeDetected = ( parentNode === bodyNode ) ;
684
680
}
685
681
686
- if ( bodyElementDetected && rootElementDetected ) {
682
+ if ( bodyNodeDetected && rootNodeDetected ) {
687
683
// If both body and root have been found, any other checks are pointless,
688
684
// as no animation data should live outside the application
689
685
break ;
690
686
}
691
687
692
- if ( ! rootElementDetected ) {
693
- // If no rootElement is detected, check if the parentElement is pinned to another element
694
- parentHost = jqLite . data ( parentElement , NG_ANIMATE_PIN_DATA ) ;
688
+ if ( ! rootNodeDetected ) {
689
+ // If `rootNode` is not detected, check if `parentNode` is pinned to another element
690
+ parentHost = jqLite . data ( parentNode , NG_ANIMATE_PIN_DATA ) ;
695
691
if ( parentHost ) {
696
692
// The pin target element becomes the next parent element
697
- parentElement = getDomNode ( parentHost ) ;
693
+ parentNode = getDomNode ( parentHost ) ;
698
694
continue ;
699
695
}
700
696
}
701
697
702
- parentElement = parentElement . parentNode ;
698
+ parentNode = parentNode . parentNode ;
703
699
}
704
700
705
701
var allowAnimation = ( ! parentAnimationDetected || animateChildren ) && elementDisabled !== true ;
706
- return allowAnimation && rootElementDetected && bodyElementDetected ;
702
+ return allowAnimation && rootNodeDetected && bodyNodeDetected ;
707
703
}
708
704
709
705
function markElementAnimationState ( element , state , details ) {
0 commit comments