-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngAnimateSwap is not compatible with ngIf #16616
Comments
The problem is that both I can't be sure, but it seems like an oversight to me. angular.
module('myApp', ['ngAnimate']).
...
decorator('ngAnimateSwapDirective', $delegate => {
// Give `ngAnimateSwap` a lower priority than `ngIf`'s 600.
$delegate[0].priority = 599;
return $delegate;
}); Ideally, we should add this fix into |
Is there any reason the team has decided this will not get a fix? Would you accept a community PR? |
We haven't made our final decision yet (we'll do this week). My main concern is the possibly breaking change (as mentioned in #16616 (comment)). |
The reason that this has been moved to |
Previously, both `ngAnimateSwap` and `ngIf` had a priority of 600, which meant that (while both are [terminal directives][1]) they were executed on top of each other (essentially messing each other's comment node). This commit fixes it, by giving `ngAnimateSwap` a priority of 550, which is lower than `ngIf` but still higher than other directives. For reference, here is a list of built-in directive per priority: ``` -400: ngInclude, ngView -1: ngRef 1: ngMessage, ngMessageDefault, ngMessageExp, ngModel, select 10: ngModelOptions 99: ngHref, ngSrc, ngSrcset 100: attr interpolation, ngChecked, ngDisabled, ngList, ngMax, ngMaxlength, ngMin, ngMinlength, ngModel (aria), ngMultiple, ngOpen, ngPattern, ngProp*, ngReadonly, ngRequired, ngSelected, ngStep, ngValue, option 400: ngInclude, ngView 450: ngInit 500: ngController 600: ngAnimateSwap, ngIf 1000: ngNonBindable, ngRepeat 1200: ngSwitchDefault, ngSwitchWhen ``` [1]: https://docs.angularjs.org/api/ng/service/$compile#-terminal- Fixes angular#16616
Previously, both `ngAnimateSwap` and `ngIf` had a priority of 600, which meant that (while both are [terminal directives][1]) they were executed on top of each other (essentially messing each other's comment node). This commit fixes it, by giving `ngAnimateSwap` a priority of 550, which is lower than `ngIf` but still higher than other directives. For reference, here is a list of built-in directive per priority: ``` -400: ngInclude, ngView -1: ngRef 1: ngMessage, ngMessageDefault, ngMessageExp, ngModel, select 10: ngModelOptions 99: ngHref, ngSrc, ngSrcset 100: attr interpolation, ngChecked, ngDisabled, ngList, ngMax, ngMaxlength, ngMin, ngMinlength, ngModel (aria), ngMultiple, ngOpen, ngPattern, ngProp*, ngReadonly, ngRequired, ngSelected, ngStep, ngValue, option 400: ngInclude, ngView 450: ngInit 500: ngController 600: ngAnimateSwap, ngIf 1000: ngNonBindable, ngRepeat 1200: ngSwitchDefault, ngSwitchWhen ``` [1]: https://docs.angularjs.org/api/ng/service/$compile#-terminal- Fixes angular#16616
Previously, both `ngAnimateSwap` and `ngIf` had a priority of 600, which meant that (while both are [terminal directives][1]) they were executed on top of each other (essentially messing each other's comment node). This commit fixes it, by giving `ngAnimateSwap` a priority of 550, which is lower than `ngIf` but still higher than other directives. For reference, here is a list of built-in directive per priority: ``` -400: ngInclude, ngView -1: ngRef 1: ngMessage, ngMessageDefault, ngMessageExp, ngModel, select 10: ngModelOptions 99: ngHref, ngSrc, ngSrcset 100: attr interpolation, ngChecked, ngDisabled, ngList, ngMax, ngMaxlength, ngMin, ngMinlength, ngModel (aria), ngMultiple, ngOpen, ngPattern, ngProp*, ngReadonly, ngRequired, ngSelected, ngStep, ngValue, option 400: ngInclude, ngView 450: ngInit 500: ngController 600: ngAnimateSwap, ngIf 1000: ngNonBindable, ngRepeat 1200: ngSwitchDefault, ngSwitchWhen ``` [1]: https://docs.angularjs.org/api/ng/service/$compile#-terminal- Fixes angular#16616
Previously, both `ngAnimateSwap` and `ngIf` had a priority of 600, which meant that (while both are [terminal directives][1]) they were executed on top of each other (essentially messing each other's comment node). This commit fixes it, by giving `ngAnimateSwap` a priority of 550, which is lower than `ngIf` but still higher than other directives. For reference, here is a list of built-in directive per priority: ``` -400: ngInclude, ngView -1: ngRef 1: ngMessage, ngMessageDefault, ngMessageExp, ngModel, select 10: ngModelOptions 99: ngHref, ngSrc, ngSrcset 100: attr interpolation, ngChecked, ngDisabled, ngList, ngMax, ngMaxlength, ngMin, ngMinlength, ngModel (aria), ngMultiple, ngOpen, ngPattern, ngProp*, ngReadonly, ngRequired, ngSelected, ngStep, ngValue, option 400: ngInclude, ngView 450: ngInit 500: ngController 600: ngAnimateSwap, ngIf 1000: ngNonBindable, ngRepeat 1200: ngSwitchDefault, ngSwitchWhen ``` [1]: https://docs.angularjs.org/api/ng/service/$compile#-terminal- Fixes #16616 Closes #16729
Thanks @gkalpak 🐔 💯 |
I'm submitting a ...
Current behavior:
ngAnimateSwap registers a comment of the element, not the element itself, so if an element contains the
ng-if
attribute,ng-animate-swap
will not work.Expected / new behavior:
Having a conditional element also be animated if it's visible.
Minimal reproduction of the problem with instructions:
ng-animate-swap
andng-if
https://codepen.io/anon/pen/LrgBwY
AngularJS version: 1.7.2
Browser: [all]
(tested on FF 62, OSX High Seirra )
The text was updated successfully, but these errors were encountered: