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

Commit 3f568b2

Browse files
matskomhevery
authored andcommitted
fix(ngView): ensure the new view element is placed after the old view element
Closes #4362
1 parent 2623de1 commit 3f568b2

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/ngRoute/directive/ngView.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ function ngViewFactory( $route, $anchorScroll, $compile, $controller,
207207
if (template) {
208208
var newScope = scope.$new();
209209
linker(newScope, function(clone) {
210-
cleanupLastView();
211-
212210
clone.html(template);
213-
$animate.enter(clone, null, $element);
211+
$animate.enter(clone, null, currentElement || $element);
212+
213+
cleanupLastView();
214214

215215
var link = $compile(clone.contents()),
216216
current = $route.current;

test/ngRoute/directive/ngViewSpec.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,9 @@ describe('ngView animations', function() {
599599
$location.path('/bar');
600600
$rootScope.$digest();
601601

602-
var itemA = $animate.flushNext('leave').element;
602+
var itemA = $animate.flushNext('enter').element;
603603
expect(itemA).not.toEqual(itemB);
604-
var itemB = $animate.flushNext('enter').element;
604+
var itemB = $animate.flushNext('leave').element;
605605
}));
606606

607607
it('should render ngClass on ngView',
@@ -635,8 +635,8 @@ describe('ngView animations', function() {
635635
$location.path('/bar');
636636
$rootScope.$digest();
637637

638-
$animate.flushNext('leave').element;
639-
item = $animate.flushNext('enter').element;
638+
$animate.flushNext('enter').element;
639+
item = $animate.flushNext('leave').element;
640640

641641
$animate.flushNext('addClass').element;
642642
$animate.flushNext('addClass').element;
@@ -679,12 +679,11 @@ describe('ngView animations', function() {
679679
$location.path('/bar');
680680
$rootScope.$digest();
681681

682+
$animate.flushNext('enter'); //ngView new
682683
$animate.flushNext('leave'); //ngView old
683684

684685
$rootScope.$digest();
685686

686-
$animate.flushNext('enter'); //ngView new
687-
688687
expect(n(element.text())).toEqual(''); //this is midway during the animation
689688

690689
$animate.flushNext('enter'); //ngRepeat 3

0 commit comments

Comments
 (0)