This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix(ngAnimate): remove prepare classes with multiple structural anima… #16681
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ describe('ngAnimate integration tests', function() { | |
ss.destroy(); | ||
}); | ||
|
||
|
||
it('should cancel a running and started removeClass animation when a follow-up addClass animation adds the same class', | ||
inject(function($animate, $rootScope, $$rAF, $document, $rootElement) { | ||
|
||
|
@@ -362,6 +363,7 @@ describe('ngAnimate integration tests', function() { | |
}); | ||
}); | ||
|
||
|
||
it('should add the preparation class for an enter animation before a parent class-based animation is applied', function() { | ||
module('ngAnimateMock'); | ||
inject(function($animate, $compile, $rootScope, $rootElement, $document) { | ||
|
@@ -397,6 +399,7 @@ describe('ngAnimate integration tests', function() { | |
}); | ||
}); | ||
|
||
|
||
it('should avoid adding the ng-enter-prepare method to a parent structural animation that contains child animations', function() { | ||
module('ngAnimateMock'); | ||
inject(function($animate, $compile, $rootScope, $rootElement, $document, $$rAF) { | ||
|
@@ -468,6 +471,84 @@ describe('ngAnimate integration tests', function() { | |
}); | ||
}); | ||
|
||
|
||
it('should remove the prepare classes when different structural animations happen in the same digest', function() { | ||
module('ngAnimateMock'); | ||
inject(function($animate, $compile, $rootScope, $rootElement, $document, $$animateCache) { | ||
element = jqLite( | ||
// Class animation pn parent element is neeeded so the child elements get the prepare class | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pn --> on (?) |
||
'<div id="outer" ng-class="{blue: cond}" ng-switch="cond">' + | ||
'<div id="default" ng-switch-default></div>' + | ||
'<div id="truthy" ng-switch-when="true"></div>' + | ||
'</div>' | ||
); | ||
|
||
$rootElement.append(element); | ||
jqLite($document[0].body).append($rootElement); | ||
|
||
$compile(element)($rootScope); | ||
$rootScope.cond = false; | ||
$rootScope.$digest(); | ||
|
||
$rootScope.cond = true; | ||
$rootScope.$digest(); | ||
|
||
var parent = element; | ||
var truthySwitch = jqLite(parent[0].querySelector('#truthy')); | ||
var defaultSwitch = jqLite(parent[0].querySelector('#default')); | ||
|
||
expect(parent).not.toHaveClass('blue'); | ||
expect(parent).toHaveClass('blue-add'); | ||
expect(truthySwitch).toHaveClass('ng-enter-prepare'); | ||
expect(defaultSwitch).toHaveClass('ng-leave-prepare'); | ||
|
||
$animate.flush(); | ||
|
||
expect(parent).toHaveClass('blue'); | ||
expect(parent).not.toHaveClass('blue-add'); | ||
expect(truthySwitch).not.toHaveClass('ng-enter-prepare'); | ||
expect(defaultSwitch).not.toHaveClass('ng-leave-prepare'); | ||
}); | ||
}); | ||
|
||
it('should respect the element node for caching when animations with the same type happen in the same digest', function() { | ||
module('ngAnimateMock'); | ||
inject(function($animate, $compile, $rootScope, $rootElement, $document, $$animateCache) { | ||
ss.addRule('.animate.ng-enter', 'transition:2s linear all;'); | ||
|
||
element = jqLite( | ||
'<div>' + | ||
'<div>' + | ||
'<div id="noanimate" ng-if="cond"></div>' + | ||
'</div>' + | ||
'<div>' + | ||
'<div id="animate" class="animate" ng-if="cond"></div>' + | ||
'</div>' + | ||
'</div>' | ||
); | ||
|
||
$rootElement.append(element); | ||
jqLite($document[0].body).append($rootElement); | ||
|
||
$compile(element)($rootScope); | ||
// $rootScope.cond = false; | ||
// $rootScope.$digest(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cough, cough |
||
|
||
$rootScope.cond = true; | ||
$rootScope.$digest(); | ||
|
||
var parent = element; | ||
var noanimate = jqLite(parent[0].querySelector('#noanimate')); | ||
var animate = jqLite(parent[0].querySelector('#animate')); | ||
|
||
expect(noanimate).not.toHaveClass('ng-enter'); | ||
expect(animate).toHaveClass('ng-enter'); | ||
|
||
$animate.flush(); | ||
}); | ||
}); | ||
|
||
|
||
it('should pack level elements into their own RAF flush', function() { | ||
module('ngAnimateMock'); | ||
inject(function($animate, $compile, $rootScope, $rootElement, $document) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT,
element
could also be a DOM node (in which caseelement[0]
will be undefined), no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, at this point it's already normalized to be a DOM node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, looking at it again, it seems that
element
is treated as a jqLite/jQuery element. So, it's fine.