Skip to content

Commit e698f0c

Browse files
authored
Merge pull request #20891 from tcjr/deprecations-cleanup-template-resolving
[CLEANUP] Remove DEPRECATE_COMPONENT_TEMPLATE_RESOLVING deprecation
2 parents c1c8b00 + dc7758f commit e698f0c

File tree

6 files changed

+12
-295
lines changed

6 files changed

+12
-295
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,6 @@ export const DEPRECATIONS = {
102102
).toLowerCase()}-from-ember`,
103103
});
104104
},
105-
DEPRECATE_COMPONENT_TEMPLATE_RESOLVING: deprecation({
106-
id: 'component-template-resolving',
107-
url: 'https://deprecations.emberjs.com/id/component-template-resolving',
108-
until: '6.0.0',
109-
for: 'ember-source',
110-
since: {
111-
available: '5.10.0',
112-
enabled: '5.10.0',
113-
},
114-
}),
115105
DEPRECATE_ARRAY_PROTOTYPE_EXTENSIONS: deprecation({
116106
id: 'deprecate-array-prototype-extensions',
117107
url: 'https://deprecations.emberjs.com/id/deprecate-array-prototype-extensions',

packages/@ember/-internals/glimmer/lib/resolver.ts

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { InternalFactory, InternalOwner, RegisterOptions } from '@ember/-internals/owner';
1+
import type { InternalFactory, InternalOwner } from '@ember/-internals/owner';
22
import { isFactory } from '@ember/-internals/owner';
33
import { assert } from '@ember/debug';
44
import { _instrumentStart } from '@ember/instrumentation';
@@ -42,7 +42,6 @@ import { default as uniqueId } from './helpers/unique-id';
4242

4343
import { mountHelper } from './syntax/mount';
4444
import { outletHelper } from './syntax/outlet';
45-
import { DEPRECATIONS, deprecateUntil } from '@ember/-internals/deprecations';
4645

4746
function instrumentationPayload(name: string) {
4847
return { object: `component:${name}` };
@@ -56,29 +55,6 @@ function componentFor(
5655
return owner.factoryFor(fullName) || null;
5756
}
5857

59-
function layoutFor(
60-
name: string,
61-
owner: InternalOwner,
62-
options?: RegisterOptions
63-
): Nullable<Template> {
64-
if (DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved) {
65-
return null;
66-
}
67-
68-
let templateFullName = `template:components/${name}` as const;
69-
70-
let result = (owner.lookup(templateFullName, options) as Template) || null;
71-
72-
if (result) {
73-
deprecateUntil(
74-
`Components with separately resolved templates are deprecated. Migrate to either co-located js/ts + hbs files or to gjs/gts. Tried to lookup '${templateFullName}'.`,
75-
DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING
76-
);
77-
}
78-
79-
return result;
80-
}
81-
8258
type LookupResult =
8359
| {
8460
component: InternalFactory<object>;
@@ -93,11 +69,7 @@ type LookupResult =
9369
layout: TemplateFactory;
9470
};
9571

96-
function lookupComponentPair(
97-
owner: InternalOwner,
98-
name: string,
99-
options?: RegisterOptions
100-
): Nullable<LookupResult> {
72+
function lookupComponentPair(owner: InternalOwner, name: string): Nullable<LookupResult> {
10173
let component = componentFor(name, owner);
10274

10375
if (isFactory(component) && component.class) {
@@ -108,12 +80,10 @@ function lookupComponentPair(
10880
}
10981
}
11082

111-
let layout = layoutFor(name, owner, options);
112-
113-
if (component === null && layout === null) {
83+
if (component === null) {
11484
return null;
11585
} else {
116-
return { component, layout } as LookupResult;
86+
return { component, layout: null } as LookupResult;
11787
}
11888
}
11989

packages/@ember/-internals/glimmer/tests/integration/components/append-test.js

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
import {
2-
moduleFor,
3-
RenderingTestCase,
4-
strip,
5-
runTask,
6-
testUnless,
7-
expectDeprecation,
8-
} from 'internal-test-helpers';
1+
import { moduleFor, RenderingTestCase, strip, runTask } from 'internal-test-helpers';
92

103
import { set } from '@ember/object';
114

125
import { Component, compile } from '../../utils/helpers';
13-
import { DEPRECATIONS } from '../../../../deprecations';
146
import { setComponentTemplate } from '@glimmer/manager';
157

168
class AbstractAppendTest extends RenderingTestCase {
@@ -286,16 +278,9 @@ class AbstractAppendTest extends RenderingTestCase {
286278
);
287279
}
288280

289-
[`${testUnless(
290-
DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved
291-
)} lifecycle hooks during component append`](assert) {
281+
[`@test lifecycle hooks during component append`](assert) {
292282
let hooks = [];
293283

294-
expectDeprecation(
295-
/resolved templates/,
296-
DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled
297-
);
298-
299284
let oldRegisterComponent = this.registerComponent;
300285
let componentsByName = {};
301286

@@ -539,16 +524,9 @@ class AbstractAppendTest extends RenderingTestCase {
539524
);
540525
}
541526

542-
[`${testUnless(
543-
DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved
544-
)} appending, updating and destroying a single component`](assert) {
527+
[`@test appending, updating and destroying a single component`](assert) {
545528
let willDestroyCalled = 0;
546529

547-
expectDeprecation(
548-
/separately resolved templates/,
549-
DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled
550-
);
551-
552530
this.registerComponent('x-parent', {
553531
ComponentClass: Component.extend({
554532
layoutName: 'components/x-parent',
@@ -566,7 +544,7 @@ class AbstractAppendTest extends RenderingTestCase {
566544
tagName: '',
567545
}),
568546

569-
resolveableTemplate: '[child: {{this.bar}}]{{yield}}',
547+
template: '[child: {{this.bar}}]{{yield}}',
570548
});
571549

572550
let XParent;
@@ -652,9 +630,7 @@ class AbstractAppendTest extends RenderingTestCase {
652630
assert.equal(renderer._roots.length, 0, 'released the root component');
653631
}
654632

655-
[`${testUnless(
656-
DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved
657-
)} appending, updating and destroying multiple components`](assert) {
633+
[`@test appending, updating and destroying multiple components`](assert) {
658634
let willDestroyCalled = 0;
659635

660636
this.registerComponent('x-first', {

packages/@ember/-internals/glimmer/tests/integration/components/component-template-test.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { DEBUG } from '@glimmer/env';
2-
import { moduleFor, RenderingTestCase, runTask, testUnless } from 'internal-test-helpers';
2+
import { moduleFor, RenderingTestCase, runTask } from 'internal-test-helpers';
33

44
import { setComponentTemplate, getComponentTemplate } from '@glimmer/manager';
55
import { Component, compile } from '../../utils/helpers';
6-
import { DEPRECATIONS } from '../../../../deprecations';
76

87
moduleFor(
98
'Components test: setComponentTemplate',
@@ -22,23 +21,6 @@ moduleFor(
2221
this.assertComponentElement(this.firstChild, { content: 'hello' });
2322
}
2423

25-
[`${testUnless(
26-
DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved
27-
)} it takes precedence over resolver`]() {
28-
this.registerComponent('foo-bar', {
29-
ComponentClass: setComponentTemplate(compile('hello'), Component.extend()),
30-
resolveableTemplate: 'noooooo!',
31-
});
32-
33-
this.render('<FooBar />');
34-
35-
this.assertComponentElement(this.firstChild, { content: 'hello' });
36-
37-
runTask(() => this.rerender());
38-
39-
this.assertComponentElement(this.firstChild, { content: 'hello' });
40-
}
41-
4224
'@test calling it with primitives asserts'(assert) {
4325
if (!DEBUG) {
4426
assert.expect(0);

packages/@ember/-internals/glimmer/tests/unit/runtime-resolver-cache-test.js

Lines changed: 1 addition & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
import { ENV } from '@ember/-internals/environment';
2-
import {
3-
RenderingTestCase,
4-
moduleFor,
5-
runDestroy,
6-
runAppend,
7-
runTask,
8-
testUnless,
9-
expectDeprecation,
10-
} from 'internal-test-helpers';
2+
import { RenderingTestCase, moduleFor, runTask } from 'internal-test-helpers';
113

124
import { set } from '@ember/object';
135
import { templateCacheCounters } from '@ember/-internals/glimmer';
146
import { Component } from '../utils/helpers';
15-
import { DEPRECATIONS } from '../../../deprecations';
167

178
moduleFor(
189
'ember-glimmer runtime resolver cache',
@@ -125,116 +116,6 @@ moduleFor(
125116
this.expectCacheChanges({}, 'toggle back to component-two no change');
126117
}
127118

128-
[`${testUnless(
129-
DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved
130-
)} each template is only compiled once`]() {
131-
expectDeprecation(
132-
/resolved templates/,
133-
DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled
134-
);
135-
// static layout
136-
this.registerComponent('component-one', { resolveableTemplate: 'One' });
137-
138-
// test directly import template factory onto late bound layout
139-
let Two = Component.extend({
140-
layout: this.compile('Two'),
141-
});
142-
this.registerComponent('component-two', { ComponentClass: Two });
143-
144-
// inject layout onto component, share layout with component-one
145-
let Root = Component.extend({
146-
layout: this.owner.lookup('template:components/component-one'),
147-
});
148-
149-
this.registerComponent('root-component', { ComponentClass: Root });
150-
151-
// template instance shared between to template managers
152-
let rootFactory = this.owner.factoryFor('component:root-component');
153-
154-
// snapshot counters
155-
this.getCacheCounters();
156-
157-
// show component-one for the first time
158-
this.render(
159-
`
160-
{{~#if this.cond~}}
161-
{{component-one}}
162-
{{~else~}}
163-
{{component-two}}
164-
{{~/if}}`,
165-
{
166-
cond: true,
167-
}
168-
);
169-
170-
this.assertText('One');
171-
this.expectCacheChanges(
172-
{
173-
componentDefinitionCount: 1,
174-
templateCacheMisses: 2,
175-
templateCacheHits: ENV._DEBUG_RENDER_TREE ? 1 : 0,
176-
},
177-
'test case component and component-one no change'
178-
);
179-
180-
// show component-two for the first time
181-
runTask(() => set(this.context, 'cond', false));
182-
183-
this.assertText('Two');
184-
this.expectCacheChanges(
185-
{
186-
templateCacheMisses: 1,
187-
componentDefinitionCount: 1,
188-
templateCacheHits: ENV._DEBUG_RENDER_TREE ? 1 : 0,
189-
},
190-
'component-two first render misses template cache'
191-
);
192-
193-
// show component-one again
194-
runTask(() => set(this.context, 'cond', true));
195-
196-
this.assertText('One');
197-
this.expectCacheChanges({}, 'toggle back to component-one no change');
198-
199-
// show component-two again
200-
runTask(() => set(this.context, 'cond', false));
201-
202-
this.assertText('Two');
203-
this.expectCacheChanges(
204-
{
205-
templateCacheHits: ENV._DEBUG_RENDER_TREE ? 2 : 1,
206-
},
207-
'toggle back to component-two hits template cache'
208-
);
209-
210-
// render new root append
211-
let root = rootFactory.create();
212-
try {
213-
runAppend(root);
214-
this.assertText('TwoOne');
215-
// roots have different capabilities so this will hit
216-
this.expectCacheChanges(
217-
{ templateCacheHits: ENV._DEBUG_RENDER_TREE ? 2 : 1 },
218-
'append root with component-one no change'
219-
);
220-
221-
// render new root append
222-
let root2 = rootFactory.create();
223-
try {
224-
runAppend(root2);
225-
this.assertText('TwoOneOne');
226-
this.expectCacheChanges(
227-
{ templateCacheHits: ENV._DEBUG_RENDER_TREE ? 2 : 1 },
228-
'append another root no change'
229-
);
230-
} finally {
231-
runDestroy(root2);
232-
}
233-
} finally {
234-
runDestroy(root);
235-
}
236-
}
237-
238119
getCacheCounters() {
239120
let { componentDefinitionCount, helperDefinitionCount } = this.renderer._context.constants;
240121

0 commit comments

Comments
 (0)