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

Commit 288351b

Browse files
committed
refactor(ngAnimate): simplify findCallbacks() and remove redundant calls
1 parent 21ca2ee commit 288351b

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/ngAnimate/animateQueue.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,7 @@ var $$AnimateQueueProvider = ['$animateProvider', /** @this */ function($animate
181181
return this === arg || !!(this.compareDocumentPosition(arg) & 16);
182182
};
183183

184-
function findCallbacks(parent, element, event) {
185-
var targetNode = getDomNode(element);
186-
var targetParentNode = getDomNode(parent);
187-
184+
function findCallbacks(targetParentNode, targetNode, event) {
188185
var matches = [];
189186
var entries = callbackRegistry[event];
190187
if (entries) {
@@ -311,12 +308,9 @@ var $$AnimateQueueProvider = ['$animateProvider', /** @this */ function($animate
311308
// the input data when running `$animateCss`.
312309
var options = copy(initialOptions);
313310

314-
var node, parent;
315311
element = stripCommentsFromElement(element);
316-
if (element) {
317-
node = getDomNode(element);
318-
parent = element.parent();
319-
}
312+
var node = getDomNode(element);
313+
var parentNode = node && node.parentNode;
320314

321315
options = prepareAnimationOptions(options);
322316

@@ -381,7 +375,7 @@ var $$AnimateQueueProvider = ['$animateProvider', /** @this */ function($animate
381375
// there is no point in traversing the same collection of parent ancestors if a followup
382376
// animation will be run on the same element that already did all that checking work
383377
if (!skipAnimations && (!hasExistingAnimation || existingAnimation.state !== PRE_DIGEST_STATE)) {
384-
skipAnimations = !areAnimationsAllowed(node, getDomNode(parent), event);
378+
skipAnimations = !areAnimationsAllowed(node, parentNode, event);
385379
}
386380

387381
if (skipAnimations) {
@@ -557,7 +551,7 @@ var $$AnimateQueueProvider = ['$animateProvider', /** @this */ function($animate
557551

558552
function notifyProgress(runner, event, phase, data) {
559553
runInNextPostDigestOrNow(function() {
560-
var callbacks = findCallbacks(parent, element, event);
554+
var callbacks = findCallbacks(parentNode, node, event);
561555
if (callbacks.length) {
562556
// do not optimize this call here to RAF because
563557
// we don't know how heavy the callback code here will

0 commit comments

Comments
 (0)