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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation for Route#renderTemplate #19433

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -181,6 +181,7 @@ if (ENV._DEBUG_RENDER_TREE) {
}

async '@test named outlets'() {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate(
'application',
strip`
Expand Down
Expand Up @@ -440,6 +440,7 @@ moduleFor(
}

['@test it can render into named outlets']() {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.router.map(function () {
this.route('colors');
});
Expand Down Expand Up @@ -599,6 +600,7 @@ moduleFor(
}

['@test it should update correctly when the controller changes']() {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.router.map(function () {
this.route('color', { path: '/colors/:color' });
});
Expand Down Expand Up @@ -643,6 +645,7 @@ moduleFor(
}

['@test it should produce a stable DOM when two routes render the same template']() {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.router.map(function () {
this.route('a');
this.route('b');
Expand Down
13 changes: 13 additions & 0 deletions packages/@ember/-internals/routing/lib/system/route.ts
Expand Up @@ -988,6 +988,19 @@ class Route extends EmberObject implements IRoute {
this.setupController(controller, context, transition);

if (this._environment.options.shouldRender) {
deprecate(
'Usage of `renderTemplate` is deprecated.',
this.renderTemplate === Route.prototype.renderTemplate,
{
id: 'route-render-template',
until: '4.0.0',
url: 'https://deprecations.emberjs.com/v3.x/#toc_route-render-template',
for: 'ember-source',
since: {
enabled: '3.27.0',
},
}
);
this.renderTemplate(controller, context);
}

Expand Down
33 changes: 22 additions & 11 deletions packages/ember-testing/tests/acceptance_test.js
Expand Up @@ -125,7 +125,8 @@ if (!jQueryDisabled) {
}

[`@test helpers can be chained with then`](assert) {
assert.expect(6);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(7);

window
.visit('/posts')
Expand Down Expand Up @@ -164,7 +165,8 @@ if (!jQueryDisabled) {
}

[`@test helpers can be chained to each other (legacy)`](assert) {
assert.expect(7);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(8);

window
.visit('/posts')
Expand Down Expand Up @@ -192,7 +194,8 @@ if (!jQueryDisabled) {
}

[`@test helpers don't need to be chained`](assert) {
assert.expect(5);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(6);

window.visit('/posts');

Expand All @@ -219,7 +222,8 @@ if (!jQueryDisabled) {
}

[`@test Nested async helpers`](assert) {
assert.expect(5);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(6);

window.visit('/posts');

Expand Down Expand Up @@ -247,7 +251,8 @@ if (!jQueryDisabled) {
}

[`@test Multiple nested async helpers`](assert) {
assert.expect(3);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(4);

window.visit('/posts');

Expand All @@ -270,7 +275,8 @@ if (!jQueryDisabled) {
}

[`@test Helpers nested in thens`](assert) {
assert.expect(5);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(6);

window.visit('/posts').then(() => {
window.click('a:first', '#comments-link');
Expand Down Expand Up @@ -311,7 +317,8 @@ if (!jQueryDisabled) {
}

[`@test Unhandled exceptions are logged via Ember.Test.adapter#exception`](assert) {
assert.expect(2);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(3);

console.error = () => {}; // eslint-disable-line no-console
let asyncHandled;
Expand Down Expand Up @@ -343,7 +350,8 @@ if (!jQueryDisabled) {
[`@test Unhandled exceptions in 'andThen' are logged via Ember.Test.adapter#exception`](
assert
) {
assert.expect(1);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(2);

console.error = () => {}; // eslint-disable-line no-console
Test.adapter = QUnitAdapter.create({
Expand All @@ -364,7 +372,8 @@ if (!jQueryDisabled) {
}

[`@test should not start routing on the root URL when visiting another`](assert) {
assert.expect(4);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(5);

window.visit('/posts');

Expand Down Expand Up @@ -427,7 +436,8 @@ if (!jQueryDisabled) {
}

[`@test visiting a URL that causes another transition should yield the correct URL`](assert) {
assert.expect(2);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(3);

window.visit('/redirect');

Expand All @@ -439,7 +449,8 @@ if (!jQueryDisabled) {
[`@test visiting a URL and then visiting a second URL with a transition should yield the correct URL`](
assert
) {
assert.expect(3);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(4);

window.visit('/posts');

Expand Down
1 change: 1 addition & 0 deletions packages/ember/tests/routing/decoupled_basic_test.js
Expand Up @@ -919,6 +919,7 @@ moduleFor(
}

['@test Router accounts for rootURL on page load when using history location'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
let rootURL = window.location.pathname + '/app';
let postsTemplateRendered = false;
let setHistory;
Expand Down
2 changes: 2 additions & 0 deletions packages/ember/tests/routing/model_loading_test.js
Expand Up @@ -204,6 +204,7 @@ moduleFor(
}

[`@test The route controller specified via controllerName is used in render`](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.router.map(function () {
this.route('home', { path: '/' });
});
Expand Down Expand Up @@ -484,6 +485,7 @@ moduleFor(
}

['@test Nested callbacks are not exited when moving to siblings'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
let rootSetup = 0;
let rootRender = 0;
let rootModel = 0;
Expand Down
23 changes: 21 additions & 2 deletions packages/ember/tests/routing/template_rendering_test.js
Expand Up @@ -71,6 +71,7 @@ moduleFor(
}

[`@test The Homepage with explicit template name in renderTemplate`](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.add(
'route:home',
Route.extend({
Expand All @@ -87,6 +88,7 @@ moduleFor(
}

async [`@test an alternate template will pull in an alternate controller`](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.add(
'route:home',
Route.extend({
Expand All @@ -113,6 +115,7 @@ moduleFor(
async [`@test An alternate template will pull in an alternate controller instead of controllerName`](
assert
) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.add(
'route:home',
Route.extend({
Expand Down Expand Up @@ -147,6 +150,7 @@ moduleFor(
}

async [`@test The template will pull in an alternate controller via key/value`](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.router.map(function () {
this.route('homepage', { path: '/' });
});
Expand Down Expand Up @@ -181,6 +185,7 @@ moduleFor(
async [`@test The Homepage with explicit template name in renderTemplate and controller`](
assert
) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.add(
'controller:home',
Controller.extend({
Expand All @@ -205,6 +210,7 @@ moduleFor(
}

async [`@test Model passed via renderTemplate model is set as controller's model`](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate(
'bio',
'<p>Model: {{@model.name}}</p><p>Controller: {{this.model.name}}</p>'
Expand Down Expand Up @@ -284,6 +290,7 @@ moduleFor(
}

['@test templateName is still used when calling render with no name and options'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('alert', `<div class='alert-box'>Invader!</div>`);
this.addTemplate('home', `<p>THIS IS THE REAL HOME</p>{{outlet 'alert'}}`);

Expand All @@ -305,7 +312,8 @@ moduleFor(
}

['@test Generated names can be customized when providing routes with dot notation'](assert) {
assert.expect(4);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(5);

this.addTemplate('index', '<div>Index</div>');
this.addTemplate('application', "<h1>Home</h1><div class='main'>{{outlet}}</div>");
Expand Down Expand Up @@ -393,6 +401,7 @@ moduleFor(
}

['@test Child routes render into specified template'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('index', '<div>Index</div>');
this.addTemplate('application', "<h1>Home</h1><div class='main'>{{outlet}}</div>");
this.addTemplate('top', "<div class='middle'>{{outlet}}</div>");
Expand Down Expand Up @@ -433,6 +442,7 @@ moduleFor(
}

['@test Rendering into specified template with slash notation'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('person.profile', 'profile {{outlet}}');
this.addTemplate('person.details', 'details!');

Expand Down Expand Up @@ -461,6 +471,7 @@ moduleFor(
}

['@test Only use route rendered into main outlet for default into property on child'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('application', "{{outlet 'menu'}}{{outlet}}");
this.addTemplate('posts', '{{outlet}}');
this.addTemplate('posts.index', '<p class="posts-index">postsIndex</p>');
Expand Down Expand Up @@ -600,6 +611,7 @@ moduleFor(
['@test The template is not re-rendered when two routes present the exact same template & controller'](
assert
) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.router.map(function () {
this.route('first');
this.route('second');
Expand Down Expand Up @@ -678,6 +690,7 @@ moduleFor(
}

['@test Route should tear down multiple outlets'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('application', "{{outlet 'menu'}}{{outlet}}{{outlet 'footer'}}");
this.addTemplate('posts', '{{outlet}}');
this.addTemplate('users', 'users');
Expand Down Expand Up @@ -999,7 +1012,8 @@ moduleFor(
}

['@test Specifying non-existent controller name in route#render throws'](assert) {
assert.expect(1);
expectDeprecation('Usage of `renderTemplate` is deprecated.');
assert.expect(2);

this.router.map(function () {
this.route('home', { path: '/' });
Expand Down Expand Up @@ -1049,6 +1063,7 @@ moduleFor(
}

['@test Can render into a named outlet at the top level'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('application', 'A-{{outlet}}-B-{{outlet "other"}}-C');
this.addTemplate('modal', 'Hello world');
this.addTemplate('index', 'The index');
Expand Down Expand Up @@ -1079,6 +1094,7 @@ moduleFor(
}

['@test Can disconnect a named outlet at the top level'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('application', 'A-{{outlet}}-B-{{outlet "other"}}-C');
this.addTemplate('modal', 'Hello world');
this.addTemplate('index', 'The index');
Expand Down Expand Up @@ -1125,6 +1141,7 @@ moduleFor(
}

['@test Can render into a named outlet at the top level, with empty main outlet'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('application', 'A-{{outlet}}-B-{{outlet "other"}}-C');
this.addTemplate('modal', 'Hello world');

Expand Down Expand Up @@ -1185,6 +1202,7 @@ moduleFor(
}

["@test Can render routes with no 'main' outlet and their children"](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('application', '<div id="application">{{outlet "app"}}</div>');
this.addTemplate(
'app',
Expand Down Expand Up @@ -1297,6 +1315,7 @@ moduleFor(
}

['@test Renders child into parent with non-default template name'](assert) {
expectDeprecation('Usage of `renderTemplate` is deprecated.');
this.addTemplate('application', '<div class="a">{{outlet}}</div>');
this.addTemplate('exports.root', '<div class="b">{{outlet}}</div>');
this.addTemplate('exports.index', '<div class="c"></div>');
Expand Down