Skip to content

Commit 515b222

Browse files
committed
Clean up deprecate-implicit-route-model deprecation
1 parent d5c9e05 commit 515b222

File tree

5 files changed

+3
-218
lines changed

5 files changed

+3
-218
lines changed

packages/@ember/-internals/deprecations/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ export const DEPRECATIONS = {
102102
).toLowerCase()}-from-ember`,
103103
});
104104
},
105-
DEPRECATE_IMPLICIT_ROUTE_MODEL: deprecation({
106-
id: 'deprecate-implicit-route-model',
107-
for: 'ember-source',
108-
since: { available: '5.3.0', enabled: '5.3.0' },
109-
until: '6.0.0',
110-
url: 'https://deprecations.emberjs.com/v5.x/#toc_deprecate-implicit-route-model',
111-
}),
112105
DEPRECATE_TEMPLATE_ACTION: deprecation({
113106
id: 'template-action',
114107
url: 'https://deprecations.emberjs.com/id/template-action',

packages/@ember/-internals/environment/lib/env.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,22 +132,6 @@ export const ENV = {
132132
*/
133133
_DEFAULT_ASYNC_OBSERVERS: false,
134134

135-
/**
136-
Whether the app still has default record-loading behavior in the model
137-
hook from RFC https://rfcs.emberjs.com/id/0774-implicit-record-route-loading
138-
This will also remove the default store property from the route.
139-
140-
This is not intended to be set directly, as the implementation may change in
141-
the future. Use `@ember/optional-features` instead.
142-
143-
@property _NO_IMPLICIT_ROUTE_MODEL
144-
@for EmberENV
145-
@type Boolean
146-
@default false
147-
@private
148-
*/
149-
_NO_IMPLICIT_ROUTE_MODEL: false,
150-
151135
/**
152136
Controls the maximum number of scheduled rerenders without "settling". In general,
153137
applications should not need to modify this environment variable, but please

packages/@ember/routing/route.ts

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
} from '@ember/-internals/metal';
88
import type Owner from '@ember/owner';
99
import { getOwner } from '@ember/-internals/owner';
10-
import { ENV } from '@ember/-internals/environment';
1110
import type { default as BucketCache } from './lib/cache';
1211
import EmberObject, { computed, get, set, getProperties, setProperties } from '@ember/object';
1312
import Evented from '@ember/object/evented';
@@ -19,7 +18,6 @@ import type { AnyFn } from '@ember/-internals/utility-types';
1918
import Controller from '@ember/controller';
2019
import type { ControllerQueryParamType } from '@ember/controller';
2120
import { assert, info, isTesting } from '@ember/debug';
22-
import { DEPRECATIONS, deprecateUntil } from '@ember/-internals/deprecations';
2321
import EngineInstance from '@ember/engine/instance';
2422
import { dependentKeyCompat } from '@ember/object/compat';
2523
import { once } from '@ember/runloop';
@@ -62,16 +60,6 @@ type RouteTransitionState = TransitionState<Route> & {
6260
type MaybeParameters<T> = T extends AnyFn ? Parameters<T> : unknown[];
6361
type MaybeReturnType<T> = T extends AnyFn ? ReturnType<T> : unknown;
6462

65-
interface StoreLike {
66-
find(type: string, value: unknown): unknown;
67-
}
68-
69-
function isStoreLike(store: unknown): store is StoreLike {
70-
return (
71-
typeof store === 'object' && store !== null && typeof (store as StoreLike).find === 'function'
72-
);
73-
}
74-
7563
const RENDER = Symbol('render');
7664
const RENDER_STATE = Symbol('render-state');
7765

@@ -1190,7 +1178,7 @@ class Route<Model = unknown> extends EmberObject.extend(ActionHandler, Evented)
11901178
params: Record<string, unknown>,
11911179
transition: Transition
11921180
): Model | PromiseLike<Model> | undefined {
1193-
let name, sawParams, value;
1181+
let name, sawParams;
11941182
// SAFETY: Since `_qp` is protected we can't infer the type
11951183
let queryParams = (get(this, '_qp') as Route<Model>['_qp']).map;
11961184

@@ -1202,7 +1190,6 @@ class Route<Model = unknown> extends EmberObject.extend(ActionHandler, Evented)
12021190
let match = prop.match(/^(.*)_id$/);
12031191
if (match !== null) {
12041192
name = match[1];
1205-
value = params[prop];
12061193
}
12071194
sawParams = true;
12081195
}
@@ -1223,7 +1210,7 @@ class Route<Model = unknown> extends EmberObject.extend(ActionHandler, Evented)
12231210
}
12241211
}
12251212

1226-
return this.findModel(name, value);
1213+
return undefined;
12271214
}
12281215

12291216
/**
@@ -1239,30 +1226,6 @@ class Route<Model = unknown> extends EmberObject.extend(ActionHandler, Evented)
12391226
return this.model(this._paramsFor(this.routeName, _params), transition);
12401227
}
12411228

1242-
/**
1243-
1244-
@method findModel
1245-
@param {String} type the model type
1246-
@param {Object} value the value passed to find
1247-
@private
1248-
*/
1249-
findModel(type: string, value: unknown) {
1250-
if (ENV._NO_IMPLICIT_ROUTE_MODEL) {
1251-
return;
1252-
}
1253-
deprecateUntil(
1254-
`The implicit model loading behavior for routes is deprecated. ` +
1255-
`Please define an explicit model hook for ${this.fullRouteName}.`,
1256-
DEPRECATIONS.DEPRECATE_IMPLICIT_ROUTE_MODEL
1257-
);
1258-
1259-
const store = 'store' in this ? this.store : get(this, '_store');
1260-
assert('Expected route to have a store with a find method', isStoreLike(store));
1261-
1262-
// SAFETY: We don't actually know it will return this, but this code path is also deprecated.
1263-
return store.find(type, value) as Model | PromiseLike<Model> | undefined;
1264-
}
1265-
12661229
/**
12671230
A hook you can use to setup the controller for the current route.
12681231

packages/@ember/routing/tests/system/route_test.js

Lines changed: 1 addition & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
import { setOwner } from '@ember/-internals/owner';
2-
import { ENV } from '@ember/-internals/environment';
3-
import { DEPRECATIONS } from '@ember/-internals/deprecations';
4-
import {
5-
runDestroy,
6-
buildOwner,
7-
moduleFor,
8-
testUnless,
9-
AbstractTestCase,
10-
} from 'internal-test-helpers';
2+
import { runDestroy, buildOwner, moduleFor, AbstractTestCase } from 'internal-test-helpers';
113
import Service, { service } from '@ember/service';
12-
import EmberObject from '@ember/object';
134
import EmberRoute from '@ember/routing/route';
145
import ObjectProxy from '@ember/object/proxy';
156
import { getDebugFunction, setDebugFunction } from '@ember/debug';
@@ -30,64 +21,6 @@ moduleFor(
3021
route = routeOne = routeTwo = lookupHash = undefined;
3122
}
3223

33-
['@test noops if _NO_IMPLICIT_ROUTE_MODEL is true'](assert) {
34-
this._NO_IMPLICIT_ROUTE_MODEL = ENV._NO_IMPLICIT_ROUTE_MODEL;
35-
ENV._NO_IMPLICIT_ROUTE_MODEL = true;
36-
assert.equal(
37-
route.findModel('post', 1),
38-
undefined,
39-
'When _NO_IMPLICIT_ROUTE_MODEL is true, findModel does nothing'
40-
);
41-
ENV._NO_IMPLICIT_ROUTE_MODEL = this._NO_IMPLICIT_ROUTE_MODEL;
42-
}
43-
44-
[`${testUnless(
45-
DEPRECATIONS.DEPRECATE_IMPLICIT_ROUTE_MODEL.isRemoved
46-
)} default store utilizes the container to acquire the model factory`](assert) {
47-
assert.expect(5);
48-
49-
let Post = EmberObject.extend();
50-
let post = {};
51-
52-
Post.reopenClass({
53-
find() {
54-
return post;
55-
},
56-
});
57-
58-
let ownerOptions = {
59-
ownerOptions: {
60-
hasRegistration() {
61-
return true;
62-
},
63-
factoryFor(fullName) {
64-
assert.equal(fullName, 'model:post', 'correct factory was looked up');
65-
66-
return {
67-
class: Post,
68-
create() {
69-
return Post.create();
70-
},
71-
};
72-
},
73-
},
74-
};
75-
76-
let owner = buildOwner(ownerOptions);
77-
setOwner(route, owner);
78-
79-
expectDeprecation(
80-
() => {
81-
assert.equal(route.model({ post_id: 1 }), post);
82-
assert.equal(route.findModel('post', 1), post, '#findModel returns the correct post');
83-
},
84-
/The implicit model loading behavior for routes is deprecated./,
85-
DEPRECATIONS.DEPRECATE_IMPLICIT_ROUTE_MODEL.isEnabled
86-
);
87-
88-
runDestroy(owner);
89-
}
90-
9124
['@test default store can be overridden'](assert) {
9225
runDestroy(route);
9326

@@ -104,92 +37,6 @@ moduleFor(
10437
assert.true(calledFind, 'store.find was called');
10538
}
10639

107-
[`${testUnless(
108-
DEPRECATIONS.DEPRECATE_IMPLICIT_ROUTE_MODEL.isRemoved
109-
)} assert if 'store.find' method is not found`]() {
110-
runDestroy(route);
111-
112-
let owner = buildOwner();
113-
let Post = EmberObject.extend();
114-
115-
owner.register(
116-
'route:index',
117-
EmberRoute.extend({
118-
routeName: 'index',
119-
})
120-
);
121-
owner.register('model:post', Post);
122-
123-
route = owner.lookup('route:index');
124-
125-
ignoreDeprecation(() =>
126-
expectAssertion(function () {
127-
route.findModel('post', 1);
128-
}, `You used the dynamic segment \`post_id\` in your route ` +
129-
`\`index\` for which Ember requires you provide a ` +
130-
`data-loading implementation. Commonly, that is done by ` +
131-
`adding a model hook implementation on the route ` +
132-
`(\`model({post_id}) {\`) or by injecting an implemention of ` +
133-
`a data store: \`@service store;\`.\n\n` +
134-
`Rarely, applications may attempt to use a legacy behavior where ` +
135-
`the model class (in this case \`post\`) is resolved and the ` +
136-
`\`find\` method on that class is invoked to load data. In this ` +
137-
`application, a model of \`post\` was found but it did not ` +
138-
`provide a \`find\` method. You should not add a \`find\` ` +
139-
`method to your model. Instead, please implement an appropriate ` +
140-
`\`model\` hook on the \`index\` route.`)
141-
);
142-
143-
runDestroy(owner);
144-
}
145-
146-
[`${testUnless(
147-
DEPRECATIONS.DEPRECATE_IMPLICIT_ROUTE_MODEL.isRemoved
148-
)} asserts if model class is not found`]() {
149-
runDestroy(route);
150-
151-
let owner = buildOwner();
152-
owner.register(
153-
'route:index',
154-
EmberRoute.extend({
155-
routeName: 'index',
156-
})
157-
);
158-
159-
route = owner.lookup('route:index');
160-
161-
ignoreDeprecation(() =>
162-
expectAssertion(function () {
163-
route.model({ post_id: 1 });
164-
}, `You used the dynamic segment \`post_id\` in your route ` +
165-
`\`index\` for which Ember requires you provide a ` +
166-
`data-loading implementation. Commonly, that is done by ` +
167-
`adding a model hook implementation on the route ` +
168-
`(\`model({post_id}) {\`) or by injecting an implemention of ` +
169-
`a data store: \`@service store;\`.`)
170-
);
171-
172-
runDestroy(owner);
173-
}
174-
175-
[`${testUnless(
176-
DEPRECATIONS.DEPRECATE_IMPLICIT_ROUTE_MODEL.isRemoved
177-
)} 'store' does not need to be injected`](assert) {
178-
runDestroy(route);
179-
180-
let owner = buildOwner();
181-
182-
owner.register('route:index', EmberRoute);
183-
184-
route = owner.lookup('route:index');
185-
186-
ignoreDeprecation(() => ignoreAssertion(() => route.model({ post_id: 1 })));
187-
188-
assert.ok(true, 'no error was raised');
189-
190-
runDestroy(owner);
191-
}
192-
19340
["@test modelFor doesn't require the router"](assert) {
19441
let owner = buildOwner();
19542
setOwner(route, owner);

tests/docs/expected.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module.exports = {
99
'[]',
1010
'_DEBUG_RENDER_TREE',
1111
'_DEFAULT_ASYNC_OBSERVERS',
12-
'_NO_IMPLICIT_ROUTE_MODEL',
1312
'_RERENDER_LOOP_LIMIT',
1413
'_ALL_DEPRECATIONS_ENABLED',
1514
'_OVERRIDE_DEPRECATION_VERSION',
@@ -201,7 +200,6 @@ module.exports = {
201200
'finally',
202201
'find',
203202
'findBy',
204-
'findModel',
205203
'firstObject',
206204
'flushWatchers',
207205
'fn',

0 commit comments

Comments
 (0)