diff --git a/packages/ember-glimmer/lib/component-managers/render.ts b/packages/ember-glimmer/lib/component-managers/render.ts index 352dde6b538..eddba543e25 100644 --- a/packages/ember-glimmer/lib/component-managers/render.ts +++ b/packages/ember-glimmer/lib/component-managers/render.ts @@ -49,10 +49,6 @@ class SingletonRenderManager extends AbstractRenderManager { this._pushToDebugStack(`controller:${name} (with the render helper)`, env); } - if (dynamicScope.rootOutletState) { - dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); - } - return { controller } as RenderState; } @@ -76,10 +72,6 @@ class NonSingletonRenderManager extends AbstractRenderManager { this._pushToDebugStack(`controller:${name} (with the render helper)`, environment); } - if (dynamicScope.rootOutletState) { - dynamicScope.outletState = dynamicScope.rootOutletState.getOrphan(name); - } - return { controller, model: modelRef }; } diff --git a/packages/ember-glimmer/lib/views/outlet.ts b/packages/ember-glimmer/lib/views/outlet.ts index 238579daaa5..7ef31cd0a04 100644 --- a/packages/ember-glimmer/lib/views/outlet.ts +++ b/packages/ember-glimmer/lib/views/outlet.ts @@ -22,50 +22,11 @@ export class RootOutletStateReference implements VersionedPathReference> { - return new OrphanedOutletStateReference(this, name); - } - update(state: OutletState) { this.outletView.setOutletState(state); } } -// So this is a relic of the past that SHOULD go away -// in 3.0. Preferably it is deprecated in the release that -// follows the Glimmer release. -class OrphanedOutletStateReference extends RootOutletStateReference { - public root: any; - public name: string; - - constructor(root: RootOutletStateReference, name: string) { - super(root.outletView); - this.root = root; - this.name = name; - } - - value(): Option { - let rootState = this.root.value(); - - let orphans = rootState.outlets.main.outlets.__ember_orphans__; - - if (!orphans) { - return null; - } - - let matched = orphans.outlets[this.name]; - - if (!matched) { - return null; - } - - let state = Object.create(null); - state[matched.render.outlet] = matched; - matched.wasUsed = true; - return { outlets: state, render: undefined }; - } -} - class ChildOutletStateReference implements VersionedPathReference { public parent: VersionedPathReference; public key: string; diff --git a/packages/ember-routing/lib/system/router.js b/packages/ember-routing/lib/system/router.js index cfc42e13bd8..06eb28a27a6 100644 --- a/packages/ember-routing/lib/system/router.js +++ b/packages/ember-routing/lib/system/router.js @@ -1491,27 +1491,8 @@ function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { if (target) { set(target.outlets, renderOptions.outlet, myState); } else { - if (renderOptions.into) { - deprecate( - `Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated.`, - false, - { - id: 'ember-routing.top-level-render-helper', - until: '3.0.0', - url: 'https://emberjs.com/deprecations/v2.x/#toc_rendering-into-a-render-helper-that-resolves-to-an-outlet' - } - ); - - // Megahax time. Post-3.0-breaking-changes, we will just assert - // right here that the user tried to target a nonexistent - // thing. But for now we still need to support the `render` - // helper, and people are allowed to target templates rendered - // by the render helper. So instead we defer doing anyting with - // these orphan renders until afterRender. - appendOrphan(liveRoutes, renderOptions.into, myState); - } else { - liveRoutes = myState; - } + assert(`Cannot render into a {{render}} helper '${renderOptions.into}' that resolves to an {{outlet}}`, !renderOptions.into); + liveRoutes = myState; } return { liveRoutes, @@ -1519,23 +1500,6 @@ function appendLiveRoute(liveRoutes, defaultParentState, renderOptions) { }; } -function appendOrphan(liveRoutes, into, myState) { - if (!liveRoutes.outlets.__ember_orphans__) { - liveRoutes.outlets.__ember_orphans__ = { - render: { - name: '__ember_orphans__' - }, - outlets: Object.create(null) - }; - } - liveRoutes.outlets.__ember_orphans__.outlets[into] = myState; - run.schedule('afterRender', () => { - // `wasUsed` gets set by the render helper. - assert(`You attempted to render into '${into}' but it was not found`, - liveRoutes.outlets.__ember_orphans__.outlets[into].wasUsed); - }); -} - function representEmptyRoute(liveRoutes, defaultParentState, route) { // the route didn't render anything let alreadyAppended = findLiveRoute(liveRoutes, route.routeName); diff --git a/packages/ember/tests/routing/basic_test.js b/packages/ember/tests/routing/basic_test.js index e6a6e129649..e93f983cc2b 100644 --- a/packages/ember/tests/routing/basic_test.js +++ b/packages/ember/tests/routing/basic_test.js @@ -1931,10 +1931,7 @@ QUnit.test('Route should tear down multiple outlets', function() { equal(jQuery('div.posts-footer:contains(postsFooter)', '#qunit-fixture').length, 0, 'The posts/footer template was removed'); }); - -QUnit.test('Route will assert if you try to explicitly render {into: ...} a missing template', function () { - expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); - +QUnit.test('Route will assert if you try to explicitly render {into: ...} a {{render}} helper that resolves to an {{outlet}}', function () { Router.map(function() { this.route('home', { path: '/' }); }); @@ -1945,7 +1942,7 @@ QUnit.test('Route will assert if you try to explicitly render {into: ...} a miss } }); - expectAssertion(() => bootApplication(), 'You attempted to render into \'nonexistent\' but it was not found'); + expectAssertion(() => bootApplication(), 'Cannot render into a {{render}} helper \'nonexistent\' that resolves to an {{outlet}}'); }); QUnit.test('Route supports clearing outlet explicitly', function() { @@ -3083,204 +3080,6 @@ QUnit.test('Allows any route to disconnectOutlet another route\'s templates', fu equal(trim(jQuery('#qunit-fixture').text()), 'hi'); }); -QUnit.test('Can this.render({into:...}) the render helper', function() { - expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); - - expectDeprecation(() => { - setTemplate('application', compile('{{render "sidebar"}}')); - }, /Please refactor [\w\{\}"` ]+ to a component/); - - setTemplate('sidebar', compile('')); - setTemplate('index', compile('other')); - setTemplate('bar', compile('bar')); - - App.IndexRoute = Route.extend({ - renderTemplate() { - this.render({ into: 'sidebar' }); - }, - actions: { - changeToBar() { - this.disconnectOutlet({ - parentView: 'sidebar', - outlet: 'main' - }); - this.render('bar', { into: 'sidebar' }); - } - } - }); - - bootApplication(); - equal(jQuery('#qunit-fixture .sidebar').text(), 'other'); - run(router, 'send', 'changeToBar'); - equal(jQuery('#qunit-fixture .sidebar').text(), 'bar'); -}); - -QUnit.test('Can disconnect from the render helper', function() { - expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); - - expectDeprecation(() => { - setTemplate('application', compile('{{render "sidebar"}}')); - }, /Please refactor [\w\{\}"` ]+ to a component/); - - setTemplate('sidebar', compile('')); - setTemplate('index', compile('other')); - - App.IndexRoute = Route.extend({ - renderTemplate() { - this.render({ into: 'sidebar' }); - }, - actions: { - disconnect: function() { - this.disconnectOutlet({ - parentView: 'sidebar', - outlet: 'main' - }); - } - } - }); - - bootApplication(); - equal(jQuery('#qunit-fixture .sidebar').text(), 'other'); - run(router, 'send', 'disconnect'); - equal(jQuery('#qunit-fixture .sidebar').text(), ''); -}); - -QUnit.test('Can this.render({into:...}) the render helper\'s children', function() { - expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); - - expectDeprecation(() => { - setTemplate('application', compile('{{render "sidebar"}}')); - }, /Please refactor [\w\{\}"` ]+ to a component/); - - setTemplate('sidebar', compile('')); - setTemplate('index', compile('
{{outlet}}
')); - setTemplate('other', compile('other')); - setTemplate('bar', compile('bar')); - - App.IndexRoute = Route.extend({ - renderTemplate() { - this.render({ into: 'sidebar' }); - this.render('other', { into: 'index' }); - }, - actions: { - changeToBar() { - this.disconnectOutlet({ - parentView: 'index', - outlet: 'main' - }); - this.render('bar', { into: 'index' }); - } - } - }); - - bootApplication(); - equal(jQuery('#qunit-fixture .sidebar .index').text(), 'other'); - run(router, 'send', 'changeToBar'); - equal(jQuery('#qunit-fixture .sidebar .index').text(), 'bar'); -}); - -QUnit.test('Can disconnect from the render helper\'s children', function() { - expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); - - expectDeprecation(() => { - setTemplate('application', compile('{{render "sidebar"}}')); - }, /Please refactor [\w\{\}"` ]+ to a component/); - - setTemplate('sidebar', compile('')); - setTemplate('index', compile('
{{outlet}}
')); - setTemplate('other', compile('other')); - - App.IndexRoute = Route.extend({ - renderTemplate() { - this.render({ into: 'sidebar' }); - this.render('other', { into: 'index' }); - }, - actions: { - disconnect() { - this.disconnectOutlet({ - parentView: 'index', - outlet: 'main' - }); - } - } - }); - - bootApplication(); - equal(jQuery('#qunit-fixture .sidebar .index').text(), 'other'); - run(router, 'send', 'disconnect'); - equal(jQuery('#qunit-fixture .sidebar .index').text(), ''); -}); - -QUnit.test('Can this.render({into:...}) nested render helpers', function() { - expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); - - expectDeprecation(() => { - setTemplate('application', compile('{{render "sidebar"}}')); - }, /Please refactor [\w\{\}"` ]+ to a component/); - - expectDeprecation(() => { - setTemplate('sidebar', compile('')); - }, /Please refactor [\w\{\}"` ]+ to a component/); - - setTemplate('cart', compile('
{{outlet}}
')); - setTemplate('index', compile('other')); - setTemplate('baz', compile('baz')); - - App.IndexRoute = Route.extend({ - renderTemplate() { - this.render({ into: 'cart' }); - }, - actions: { - changeToBaz() { - this.disconnectOutlet({ - parentView: 'cart', - outlet: 'main' - }); - this.render('baz', { into: 'cart' }); - } - } - }); - - bootApplication(); - equal(jQuery('#qunit-fixture .cart').text(), 'other'); - run(router, 'send', 'changeToBaz'); - equal(jQuery('#qunit-fixture .cart').text(), 'baz'); -}); - -QUnit.test('Can disconnect from nested render helpers', function() { - expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./); - - expectDeprecation(() => { - setTemplate('application', compile('{{render "sidebar"}}')); - }, /Please refactor [\w\{\}"` ]+ to a component/); - - expectDeprecation(() => { - setTemplate('sidebar', compile('')); - }, /Please refactor [\w\{\}"` ]+ to a component/); - - setTemplate('cart', compile('
{{outlet}}
')); - setTemplate('index', compile('other')); - - App.IndexRoute = Route.extend({ - renderTemplate() { - this.render({ into: 'cart' }); - }, - actions: { - disconnect() { - this.disconnectOutlet({ - parentView: 'cart', - outlet: 'main' - }); - } - } - }); - - bootApplication(); - equal(jQuery('#qunit-fixture .cart').text(), 'other'); - run(router, 'send', 'disconnect'); - equal(jQuery('#qunit-fixture .cart').text(), ''); -}); - QUnit.test('Components inside an outlet have their didInsertElement hook invoked when the route is displayed', function(assert) { setTemplate('index', compile('{{#if showFirst}}{{my-component}}{{else}}{{other-component}}{{/if}}'));