Skip to content

Commit

Permalink
[BUGFIX beta] Fix top-level non-default outlet disconnection
Browse files Browse the repository at this point in the history
This resolves the secondary issue reported in [a
comment](emberjs#10416 (comment))
on issue emberjs#10416.
  • Loading branch information
ef4 committed Feb 12, 2015
1 parent a60f255 commit c0a8c98
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/ember-routing/lib/system/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, {
disconnectOutlet: function(options) {
var outletName;
var parentView;
var parent;
if (!options || typeof options === "string") {
outletName = options;
} else {
Expand All @@ -1853,7 +1854,8 @@ var Route = EmberObject.extend(ActionHandler, Evented, {
}

parentView = parentView && parentView.replace(/\//g, '.');
if (parentView === parentRoute(this).routeName) {
parent = parentRoute(this);
if (parent && parentView === parent.routeName) {
parentView = undefined;
}
outletName = outletName || 'main';
Expand Down
32 changes: 32 additions & 0 deletions packages/ember/tests/routing/basic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3500,6 +3500,38 @@ QUnit.test("Can render into a named outlet at the top level", function() {
equal(Ember.$('#qunit-fixture').text(), "A-The index-B-Hello world-C", "initial render");
});

QUnit.test("Can disconnect a named outlet at the top level", function() {
Ember.TEMPLATES.application = compile("A-{{outlet}}-B-{{outlet \"other\"}}-C");
Ember.TEMPLATES.modal = compile("Hello world");
Ember.TEMPLATES.index = compile("The index");

registry.register('route:application', Ember.Route.extend({
renderTemplate: function() {
this.render();
this.render('modal', {
into: 'application',
outlet: 'other'
});
},
actions: {
banish: function() {
this.disconnectOutlet({
parentView: 'application',
outlet: 'other'
});
}
}
}));

bootApplication();

equal(Ember.$('#qunit-fixture').text(), "A-The index-B-Hello world-C", "initial render");

Ember.run(router, 'send', 'banish');

equal(Ember.$('#qunit-fixture').text(), "A-The index-B--C", "second render");
});

QUnit.test("Can render into a named outlet at the top level, with empty main outlet", function() {
Ember.TEMPLATES.application = compile("A-{{outlet}}-B-{{outlet \"other\"}}-C");
Ember.TEMPLATES.modal = compile("Hello world");
Expand Down

0 comments on commit c0a8c98

Please sign in to comment.