Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release] Ensure Engine Routes are deactivated before destruction #14237

Merged
merged 1 commit into from
Sep 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,27 @@ moduleFor('Application test: engine rendering', class extends ApplicationTest {
], 'the expected hooks were fired');
});
}

['@test deactivate should be called on Engine Routes before destruction'](assert) {
assert.expect(3);

this.setupAppAndRoutableEngine();

this.registerEngine('blog', Engine.extend({
init() {
this._super(...arguments);
this.register('template:application', compile('Engine{{outlet}}'));
this.register('route:application', Route.extend({
deactivate() {
assert.notOk(this.isDestroyed, 'Route is not destroyed');
assert.notOk(this.isDestroying, 'Route is not being destroyed');
}
}));
}
}));

return this.visit('/blog').then(() => {
this.assertText('ApplicationEngine');
});
}
});
15 changes: 8 additions & 7 deletions packages/ember-routing/lib/system/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,20 +452,21 @@ const EmberRouter = EmberObject.extend(Evented, {
},

willDestroy() {
let instances = this._engineInstances;
for (let name in instances) {
for (let id in instances[name]) {
run(instances[name][id], 'destroy');
}
}

if (this._toplevelView) {
this._toplevelView.destroy();
this._toplevelView = null;
}

this._super(...arguments);

this.reset();

let instances = this._engineInstances;
for (let name in instances) {
for (let id in instances[name]) {
run(instances[name][id], 'destroy');
}
}
},

/*
Expand Down