Skip to content

Commit fd0cb35

Browse files
committed
Merge pull request #11029 from ef4/bound-outlet-names
Allow bound outlet names
2 parents 984f9a2 + 6e63de4 commit fd0cb35

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

packages/ember-htmlbars/lib/keywords/real_outlet.js

-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { get } from "ember-metal/property_get";
77
import ComponentNode from "ember-htmlbars/system/component-node";
8-
import { isStream } from "ember-metal/streams/utils";
98
import topLevelViewTemplate from "ember-htmlbars/templates/top-level-view";
109
topLevelViewTemplate.revision = 'Ember@VERSION_STRING_PLACEHOLDER';
1110

@@ -17,12 +16,6 @@ export default {
1716
setupState(state, env, scope, params, hash) {
1817
var outletState = env.outletState;
1918
var read = env.hooks.getValue;
20-
21-
Ember.assert(
22-
"Using {{outlet}} with an unquoted name is not supported.",
23-
!params[0] || !isStream(params[0])
24-
);
25-
2619
var outletName = read(params[0]) || 'main';
2720
var selectedOutletState = outletState[outletName];
2821

packages/ember-routing-htmlbars/tests/helpers/outlet_test.js

+41-5
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,49 @@ QUnit.test("should not throw deprecations if {{outlet}} is used with a quoted na
239239
runAppend(top);
240240
});
241241

242-
QUnit.test("should throw an assertion if {{outlet}} used with unquoted name", function() {
243-
top.setOutletState(withTemplate("{{outlet foo}}"));
244-
expectAssertion(function() {
245-
runAppend(top);
246-
}, "Using {{outlet}} with an unquoted name is not supported.");
242+
QUnit.test("{{outlet}} should work with an unquoted name", function() {
243+
var routerState = {
244+
render: {
245+
controller: Ember.Controller.create({
246+
outletName: 'magical'
247+
}),
248+
template: compile('{{outlet outletName}}')
249+
},
250+
outlets: {
251+
magical: withTemplate("It's magic")
252+
}
253+
};
254+
255+
top.setOutletState(routerState);
256+
runAppend(top);
257+
258+
equal(top.$().text().trim(), "It's magic");
247259
});
248260

261+
QUnit.test("{{outlet}} should rerender when bound name changes", function() {
262+
var routerState = {
263+
render: {
264+
controller: Ember.Controller.create({
265+
outletName: 'magical'
266+
}),
267+
template: compile('{{outlet outletName}}')
268+
},
269+
outlets: {
270+
magical: withTemplate("It's magic"),
271+
second: withTemplate("second")
272+
}
273+
};
274+
275+
top.setOutletState(routerState);
276+
runAppend(top);
277+
equal(top.$().text().trim(), "It's magic");
278+
run(function() {
279+
routerState.render.controller.set('outletName', 'second');
280+
});
281+
equal(top.$().text().trim(), "second");
282+
});
283+
284+
249285
function withTemplate(string) {
250286
return {
251287
render: {

0 commit comments

Comments
 (0)