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

Commit 9f5c437

Browse files
Andrew Kulinichmatsko
Andrew Kulinich
authored andcommitted
fix(ngAnimate): fix property name that is used to calculate cache key
Fix property name that introduced a bug that occurs when there are 2 animations per page with similar signature. Due to mistype they were assigned same cache key so second animation was processed incorrectly Closes #7566
1 parent 440be33 commit 9f5c437

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/ngAnimate/animate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ angular.module('ngAnimate', ['ng'])
13861386
});
13871387

13881388
element.addClass(activeClassName);
1389-
var eventCacheKey = elementData.eventCacheKey + ' ' + activeClassName;
1389+
var eventCacheKey = elementData.cacheKey + ' ' + activeClassName;
13901390
var timings = getElementAnimationDetails(element, eventCacheKey);
13911391

13921392
var maxDuration = Math.max(timings.transitionDuration, timings.animationDuration);

test/ngAnimate/animateSpec.js

+36
Original file line numberDiff line numberDiff line change
@@ -3080,6 +3080,42 @@ describe("ngAnimate", function() {
30803080
});
30813081
});
30823082

3083+
it("should cache getComputedStyle with similar className values but with respect to the parent node",
3084+
inject(function($compile, $rootScope, $animate, $sniffer) {
3085+
3086+
if (!$sniffer.transitions) return;
3087+
3088+
$animate.enabled();
3089+
3090+
var html = '<div ng-class="{on:one}">first</div>' +
3091+
'<div class="second">' +
3092+
' <div ng-class="{on:two}">second</div>' +
3093+
'</div>';
3094+
3095+
ss.addRule('.second .on', '-webkit-transition:1s linear all;' +
3096+
'transition:1s linear all;');
3097+
3098+
var element = $compile(html)($rootScope);
3099+
$rootElement.append(element);
3100+
jqLite($document[0].body).append($rootElement);
3101+
3102+
$rootScope.$apply(function() {
3103+
$rootScope.one = true;
3104+
$rootScope.two = true;
3105+
});
3106+
3107+
$animate.triggerReflow();
3108+
3109+
var inner = jqLite(jqLite(element[1]).find('div'));
3110+
3111+
expect(inner.hasClass('on-add')).toBe(true);
3112+
expect(inner.hasClass('on-add-active')).toBe(true);
3113+
3114+
browserTrigger(inner, 'animationend', { timeStamp: Date.now() + 1000, elapsedTime: 1 });
3115+
3116+
expect(inner.hasClass('on-add')).toBe(false);
3117+
expect(inner.hasClass('on-add-active')).toBe(false);
3118+
}));
30833119

30843120

30853121
it("should cancel and perform the dom operation only after the reflow has run",

0 commit comments

Comments
 (0)