Skip to content

Commit 84fd412

Browse files
Revert "fix(viewDirective): $destroy event is triggered before animation ends"
This reverts commit 1be1379.
1 parent 9698ec4 commit 84fd412

File tree

2 files changed

+9
-35
lines changed

2 files changed

+9
-35
lines changed

src/viewDirective.js

+8-21
Original file line numberDiff line numberDiff line change
@@ -207,45 +207,32 @@ function $ViewDirective( $state, $injector, $uiViewScroll, $interpolate)
207207
updateView(true);
208208

209209
function cleanupLastView() {
210-
var _previousEl = previousEl;
211-
var _currentScope = currentScope;
212-
213-
if (_currentScope) {
214-
_currentScope._willBeDestroyed = true;
210+
if (previousEl) {
211+
previousEl.remove();
212+
previousEl = null;
215213
}
216214

217-
function cleanOld() {
218-
if (_previousEl) {
219-
_previousEl.remove();
220-
}
221-
222-
if (_currentScope) {
223-
_currentScope.$destroy();
224-
}
215+
if (currentScope) {
216+
currentScope.$destroy();
217+
currentScope = null;
225218
}
226219

227220
if (currentEl) {
228221
renderer.leave(currentEl, function() {
229-
cleanOld();
230222
previousEl = null;
231223
});
232224

233225
previousEl = currentEl;
234-
} else {
235-
cleanOld();
236-
previousEl = null;
226+
currentEl = null;
237227
}
238-
239-
currentEl = null;
240-
currentScope = null;
241228
}
242229

243230
function updateView(firstTime) {
244231
var newScope,
245232
name = getUiViewName(scope, attrs, $element, $interpolate),
246233
previousLocals = name && $state.$current && $state.$current.locals[name];
247234

248-
if (!firstTime && previousLocals === latestLocals || scope._willBeDestroyed) return; // nothing to do
235+
if (!firstTime && previousLocals === latestLocals) return; // nothing to do
249236
newScope = scope.$new();
250237
latestLocals = $state.$current.locals[name];
251238

test/viewDirectiveSpec.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function animateFlush($animate) {
99
describe('uiView', function () {
1010
'use strict';
1111

12-
var log, scope, $compile, elem;
12+
var scope, $compile, elem;
1313

1414
beforeEach(function() {
1515
var depends = ['ui.router'];
@@ -32,10 +32,6 @@ describe('uiView', function () {
3232
});
3333
}));
3434

35-
beforeEach(function() {
36-
log = '';
37-
});
38-
3935
var aState = {
4036
template: 'aState template'
4137
},
@@ -121,15 +117,6 @@ describe('uiView', function () {
121117
.state('j', jState)
122118
.state('k', kState)
123119
.state('l', lState)
124-
.state('m', {
125-
controller: function($scope) {
126-
log += 'ctrl(m);';
127-
$scope.$on('$destroy', function() { log += '$destroy(m);'; });
128-
}
129-
})
130-
.state('n', {
131-
controller: function($scope) { log += 'ctrl(n);'; }
132-
});
133120
}));
134121

135122
beforeEach(inject(function ($rootScope, _$compile_) {

0 commit comments

Comments
 (0)