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

Commit c966876

Browse files
dchermanlgalfaso
authored andcommitted
perf(ngAnimate): avoid jqLite/jQuery for upward DOM traversal
The `parentNode` property is well supported between all browsers. Since no other functionality was required here other than traversing upwards using `.parent()`, we can use the DOM API directly. Closes: #13879
1 parent bfce067 commit c966876

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/ngAnimate/animateQueue.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -590,25 +590,26 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
590590
parentElement = parentHost;
591591
}
592592

593-
while (parentElement && parentElement.length) {
593+
parentElement = getDomNode(parentElement);
594+
595+
while (parentElement) {
594596
if (!rootElementDetected) {
595597
// angular doesn't want to attempt to animate elements outside of the application
596598
// therefore we need to ensure that the rootElement is an ancestor of the current element
597599
rootElementDetected = isMatchingElement(parentElement, $rootElement);
598600
}
599601

600-
var parentNode = parentElement[0];
601-
if (parentNode.nodeType !== ELEMENT_NODE) {
602+
if (parentElement.nodeType !== ELEMENT_NODE) {
602603
// no point in inspecting the #document element
603604
break;
604605
}
605606

606-
var details = activeAnimationsLookup.get(parentNode) || {};
607+
var details = activeAnimationsLookup.get(parentElement) || {};
607608
// either an enter, leave or move animation will commence
608609
// therefore we can't allow any animations to take place
609610
// but if a parent animation is class-based then that's ok
610611
if (!parentAnimationDetected) {
611-
var parentElementDisabled = disabledElementsLookup.get(parentNode);
612+
var parentElementDisabled = disabledElementsLookup.get(parentElement);
612613

613614
if (parentElementDisabled === true && elementDisabled !== false) {
614615
// disable animations if the user hasn't explicitly enabled animations on the
@@ -623,7 +624,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
623624
}
624625

625626
if (isUndefined(animateChildren) || animateChildren === true) {
626-
var value = jqLite.data(parentElement[0], NG_ANIMATE_CHILDREN_DATA);
627+
var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);
627628
if (isDefined(value)) {
628629
animateChildren = value;
629630
}
@@ -646,15 +647,15 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
646647

647648
if (!rootElementDetected) {
648649
// If no rootElement is detected, check if the parentElement is pinned to another element
649-
parentHost = jqLite.data(parentElement[0], NG_ANIMATE_PIN_DATA);
650+
parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA);
650651
if (parentHost) {
651652
// The pin target element becomes the next parent element
652-
parentElement = parentHost;
653+
parentElement = getDomNode(parentHost);
653654
continue;
654655
}
655656
}
656657

657-
parentElement = parentElement.parent();
658+
parentElement = parentElement.parentNode;
658659
}
659660

660661
var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;

0 commit comments

Comments
 (0)