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

Commit 15915e6

Browse files
dchermanNarretz
authored andcommitted
perf(ngAnimate): avoid $.fn.data overhead with jQuery
Unlike jqLite, jquery scrapes the attributes of an element looking for data- keys that match the requested property. When many elements are being animated due to something like `ngRepeat` unrolling within one digest cycle, the amount of time spent in that one function quickly adds up. By changing our API to use the lower level data API, we can cut the time spent in this function by half when jQuery is loaded.
1 parent 632e15a commit 15915e6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ngAnimate/animateQueue.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
585585
var animateChildren;
586586
var elementDisabled = disabledElementsLookup.get(getDomNode(element));
587587

588-
var parentHost = element.data(NG_ANIMATE_PIN_DATA);
588+
var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);
589589
if (parentHost) {
590590
parentElement = parentHost;
591591
}
@@ -623,7 +623,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
623623
}
624624

625625
if (isUndefined(animateChildren) || animateChildren === true) {
626-
var value = parentElement.data(NG_ANIMATE_CHILDREN_DATA);
626+
var value = jqLite.data(parentElement[0], NG_ANIMATE_CHILDREN_DATA);
627627
if (isDefined(value)) {
628628
animateChildren = value;
629629
}
@@ -646,7 +646,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
646646

647647
if (!rootElementDetected) {
648648
// If no rootElement is detected, check if the parentElement is pinned to another element
649-
parentHost = parentElement.data(NG_ANIMATE_PIN_DATA);
649+
parentHost = jqLite.data(parentElement[0], NG_ANIMATE_PIN_DATA);
650650
if (parentHost) {
651651
// The pin target element becomes the next parent element
652652
parentElement = parentHost;

0 commit comments

Comments
 (0)