Skip to content

Commit 81d00ea

Browse files
Revert "cherry-pick 2523bbd from 0.2.17"
This reverts commit e7a3481.
1 parent 2a20a96 commit 81d00ea

File tree

2 files changed

+29
-71
lines changed

2 files changed

+29
-71
lines changed

src/ng1/viewDirective.ts

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var ngMajorVer = angular.version.major;
2-
var ngMinorVer = angular.version.minor;
31
/** @module view */ /** for typedoc */
42
import {extend} from "../common/common";
53
import {isDefined} from "../common/predicates";
@@ -31,9 +29,6 @@ import {UIViewData} from "../view/interface";
3129
* service, {@link ui.router.state.$uiViewScroll}. This custom service let's you
3230
* scroll ui-view elements into view when they are populated during a state activation.
3331
*
34-
* @param {string=} noanimation If truthy, the non-animated renderer will be selected (no animations
35-
* will be applied to the ui-view)
36-
*
3732
* *Note: To revert back to old [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll)
3833
* functionality, call `$uiViewScrollProvider.useAnchorScroll()`.*
3934
*
@@ -127,26 +122,16 @@ $ViewDirective.$inject = ['$view', '$animate', '$uiViewScroll', '$interpolate',
127122
function $ViewDirective( $view, $animate, $uiViewScroll, $interpolate, $q) {
128123

129124
function getRenderer(attrs, scope) {
130-
131-
function animEnabled(element) {
132-
if (!!attrs.noanimation) return false;
133-
return (ngMajorVer === 1 && ngMinorVer >= 4) ? !!$animate.enabled(element) : !!$animate.enabled();
134-
}
135-
136125
return {
137126
enter: function(element, target, cb) {
138-
if (!animEnabled(element)) {
139-
target.after(element); cb();
140-
} else if (angular.version.minor > 2) {
127+
if (angular.version.minor > 2) {
141128
$animate.enter(element, null, target).then(cb);
142129
} else {
143130
$animate.enter(element, null, target, cb);
144131
}
145132
},
146133
leave: function(element, cb) {
147-
if (!animEnabled(element)) {
148-
element.remove(); cb();
149-
} else if (angular.version.minor > 2) {
134+
if (angular.version.minor > 2) {
150135
$animate.leave(element).then(cb);
151136
} else {
152137
$animate.leave(element, cb);

test/viewDirectiveSpec.js

+27-54
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('uiView', function () {
1717
var log, scope, $compile, elem;
1818

1919
beforeEach(function() {
20-
var depends = ['ui.router', 'ui.router.state.events'];
20+
var depends = ['ui.router'];
2121

2222
try {
2323
angular.module('ngAnimate');
@@ -31,8 +31,7 @@ describe('uiView', function () {
3131
module('ui.router.test');
3232
});
3333

34-
beforeEach(module(function ($provide, $stateEventsProvider) {
35-
$stateEventsProvider.enable();
34+
beforeEach(module(function ($provide) {
3635
$provide.decorator('$uiViewScroll', function () {
3736
return jasmine.createSpy('$uiViewScroll');
3837
});
@@ -138,13 +137,17 @@ describe('uiView', function () {
138137
.state('m', {
139138
template: 'mState',
140139
controller: function($scope) {
141-
log += 'ctrl(m);';
142-
$scope.$on('$destroy', function() { log += '$destroy(m);'; });
143-
}
140+
log += 'm;';
141+
$scope.$on('$destroy', function() {
142+
log += '$destroy(m);';
143+
});
144+
},
144145
})
145146
.state('n', {
146147
template: 'nState',
147-
controller: function($scope) { log += 'ctrl(n);'; }
148+
controller: function($scope) {
149+
log += 'n;';
150+
},
148151
})
149152
.state('o', oState)
150153
}));
@@ -157,6 +160,23 @@ describe('uiView', function () {
157160

158161
describe('linking ui-directive', function () {
159162

163+
it('$destroy event is triggered after animation ends', inject(function($state, $q, $animate) {
164+
elem.append($compile('<div><ui-view></ui-view></div>')(scope));
165+
166+
$state.transitionTo('m');
167+
$q.flush();
168+
expect(log).toBe('m;');
169+
$state.transitionTo('n');
170+
$q.flush();
171+
if ($animate) {
172+
expect(log).toBe('m;n;');
173+
animateFlush($animate);
174+
expect(log).toBe('m;n;$destroy(m);');
175+
} else {
176+
expect(log).toBe('m;$destroy(m);n;');
177+
}
178+
}));
179+
160180
it('anonymous ui-view should be replaced with the template of the current $state', inject(function ($state, $q) {
161181
elem.append($compile('<div><ui-view></ui-view></div>')(scope));
162182

@@ -595,53 +615,6 @@ describe('uiView', function () {
595615
// No more animations
596616
expect($animate.queue.length).toBe(0);
597617
}));
598-
599-
it ('should disable animations if noanimation="true" is present', inject(function($state, $q, $compile, $animate) {
600-
var content = 'Initial Content', animation;
601-
elem.append($compile('<div><ui-view noanimation="true">' + content + '</ui-view></div>')(scope));
602-
603-
animation = $animate.queue.shift();
604-
expect(animation).toBeUndefined();
605-
606-
$state.transitionTo(aState);
607-
$q.flush();
608-
animation = $animate.queue.shift();
609-
expect(animation).toBeUndefined();
610-
expect(elem.text()).toBe(aState.template);
611-
612-
$state.transitionTo(bState);
613-
$q.flush();
614-
animation = $animate.queue.shift();
615-
expect(animation).toBeUndefined();
616-
expect(elem.text()).toBe(bState.template);
617-
}));
618-
619-
describe('$destroy event', function() {
620-
it('is triggered after animation ends', inject(function($state, $q, $animate, $rootScope) {
621-
elem.append($compile('<div><ui-view></ui-view></div>')(scope));
622-
623-
$state.transitionTo('m');
624-
$q.flush();
625-
expect(log).toBe('ctrl(m);');
626-
$state.transitionTo('n');
627-
$q.flush();
628-
629-
expect(log).toBe('ctrl(m);ctrl(n);');
630-
animateFlush($animate);
631-
expect(log).toBe('ctrl(m);ctrl(n);$destroy(m);');
632-
}));
633-
634-
it('is triggered before $stateChangeSuccess if noanimation is present', inject(function($state, $q, $animate, $rootScope) {
635-
elem.append($compile('<div><ui-view noanimation="true"></ui-view></div>')(scope));
636-
637-
$state.transitionTo('m');
638-
$q.flush();
639-
expect(log).toBe('ctrl(m);');
640-
$state.transitionTo('n');
641-
$q.flush();
642-
expect(log).toBe('ctrl(m);$destroy(m);ctrl(n);');
643-
}));
644-
});
645618
});
646619
});
647620

0 commit comments

Comments
 (0)