Skip to content

Commit e5c4e57

Browse files
committed
Update lookupComponent and lookupComponentPair to not try to resolve templates once the deprecation is in the removed state
1 parent 87b4568 commit e5c4e57

File tree

4 files changed

+38
-25
lines changed

4 files changed

+38
-25
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { default as uniqueId } from './helpers/unique-id';
4747
import actionModifier from './modifiers/action';
4848
import { mountHelper } from './syntax/mount';
4949
import { outletHelper } from './syntax/outlet';
50-
import { DEPRECATIONS, deprecateUntil } from '@ember/-internals/deprecations';
50+
import { DEPRECATIONS, deprecateUntil, isRemoved } from '@ember/-internals/deprecations';
5151

5252
function instrumentationPayload(name: string) {
5353
return { object: `component:${name}` };
@@ -105,6 +105,10 @@ function lookupComponentPair(
105105
}
106106
}
107107

108+
if (isRemoved(DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.options)) {
109+
return { component, layout: null } as LookupResult;
110+
}
111+
108112
let layout = layoutFor(name, owner, options);
109113

110114
if (component === null && layout === null) {
@@ -261,7 +265,9 @@ export default class ResolverImpl
261265
let key: object;
262266

263267
if (pair.component === null) {
264-
key = template = pair.layout(owner);
268+
if (!isRemoved(DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.options)) {
269+
key = template = pair.layout(owner);
270+
}
265271
} else {
266272
key = pair.component;
267273
}

packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts

+18-15
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ if (ENV._DEBUG_RENDER_TREE) {
219219
)
220220
);
221221
this.register(
222-
'component:components/inspect-model',
222+
'component:inspect-model',
223223
setComponentTemplate(
224224
compileTemplate('{{@model}}', {
225225
moduleName: 'foo/components/inspect-model.hbs',
@@ -260,7 +260,7 @@ if (ENV._DEBUG_RENDER_TREE) {
260260
)
261261
);
262262
this.register(
263-
'component:components/inspect-model',
263+
'component:inspect-model',
264264
setComponentTemplate(
265265
compileTemplate('{{@model}}', {
266266
moduleName: 'bar/components/inspect-model.hbs',
@@ -629,10 +629,13 @@ if (ENV._DEBUG_RENDER_TREE) {
629629
})
630630
);
631631
this.register(
632-
'template:components/hello',
633-
compileTemplate('<span>Hello {{@message}}</span>', {
634-
moduleName: 'foo/components/hello.hbs',
635-
})
632+
'component:hello',
633+
setComponentTemplate(
634+
compileTemplate('<span>Hello {{@message}}</span>', {
635+
moduleName: 'foo/components/hello.hbs',
636+
}),
637+
templateOnlyComponent()
638+
)
636639
);
637640
}
638641

@@ -963,7 +966,7 @@ if (ENV._DEBUG_RENDER_TREE) {
963966
this.addComponent('hello-world', {
964967
ComponentClass: setComponentTemplate(
965968
compileTemplate('{{@name}}', { moduleName: 'my-app/components/hello-world.hbs' }),
966-
templateOnlyComponent()
969+
templateOnlyComponent('my-app/components/hello-world', 'HelloWorld')
967970
),
968971
});
969972

@@ -1048,7 +1051,7 @@ if (ENV._DEBUG_RENDER_TREE) {
10481051
name: 'hello-world',
10491052
args: { positional: [], named: { name: 'first' } },
10501053
instance: (instance: Record<string, string>) => instance['name'] === 'first',
1051-
template: 'my-app/templates/components/hello-world.hbs',
1054+
template: '(unknown template module)',
10521055
bounds: this.nodeBounds(this.element!.firstChild),
10531056
children: [],
10541057
},
@@ -1064,7 +1067,7 @@ if (ENV._DEBUG_RENDER_TREE) {
10641067
name: 'hello-world',
10651068
args: { positional: [], named: { name: 'first' } },
10661069
instance: (instance: Record<string, string>) => instance['name'] === 'first',
1067-
template: 'my-app/templates/components/hello-world.hbs',
1070+
template: '(unknown template module)',
10681071
bounds: this.nodeBounds(this.element!.firstChild),
10691072
children: [],
10701073
},
@@ -1073,7 +1076,7 @@ if (ENV._DEBUG_RENDER_TREE) {
10731076
name: 'hello-world',
10741077
args: { positional: [], named: { name: 'second' } },
10751078
instance: (instance: Record<string, string>) => instance['name'] === 'second',
1076-
template: 'my-app/templates/components/hello-world.hbs',
1079+
template: '(unknown template module)',
10771080
bounds: this.nodeBounds(this.element!.lastChild),
10781081
children: [],
10791082
},
@@ -1089,7 +1092,7 @@ if (ENV._DEBUG_RENDER_TREE) {
10891092
name: 'hello-world',
10901093
args: { positional: [], named: { name: 'first' } },
10911094
instance: (instance: Record<string, string>) => instance['name'] === 'first',
1092-
template: 'my-app/templates/components/hello-world.hbs',
1095+
template: '(unknown template module)',
10931096
bounds: this.nodeBounds(this.element!.firstChild),
10941097
children: [],
10951098
},
@@ -1133,7 +1136,7 @@ if (ENV._DEBUG_RENDER_TREE) {
11331136
name: 'hello-world',
11341137
args: { positional: [], named: { name: 'first' } },
11351138
instance: (instance: Record<string, string>) => instance['name'] === 'first',
1136-
template: 'my-app/templates/components/hello-world.hbs',
1139+
template: '(unknown template module)',
11371140
bounds: this.nodeBounds(this.element!.firstChild),
11381141
children: [],
11391142
},
@@ -1149,7 +1152,7 @@ if (ENV._DEBUG_RENDER_TREE) {
11491152
name: 'hello-world',
11501153
args: { positional: [], named: { name: 'first' } },
11511154
instance: (instance: Record<string, string>) => instance['name'] === 'first',
1152-
template: 'my-app/templates/components/hello-world.hbs',
1155+
template: '(unknown template module)',
11531156
bounds: this.nodeBounds(this.element!.firstChild),
11541157
children: [],
11551158
},
@@ -1158,7 +1161,7 @@ if (ENV._DEBUG_RENDER_TREE) {
11581161
name: 'hello-world',
11591162
args: { positional: [], named: { name: 'second' } },
11601163
instance: (instance: Record<string, string>) => instance['name'] === 'second',
1161-
template: 'my-app/templates/components/hello-world.hbs',
1164+
template: '(unknown template module)',
11621165
bounds: this.nodeBounds(this.element!.lastChild),
11631166
children: [],
11641167
},
@@ -1174,7 +1177,7 @@ if (ENV._DEBUG_RENDER_TREE) {
11741177
name: 'hello-world',
11751178
args: { positional: [], named: { name: 'first' } },
11761179
instance: (instance: Record<string, string>) => instance['name'] === 'first',
1177-
template: 'my-app/templates/components/hello-world.hbs',
1180+
template: '(unknown template module)',
11781181
bounds: this.nodeBounds(this.element!.firstChild),
11791182
children: [],
11801183
},

packages/@ember/-internals/glimmer/tests/integration/application/engine-test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ModuleBasedTestResolver,
55
strip,
66
runTaskNext,
7+
expectDeprecation,
78
} from 'internal-test-helpers';
89

910
import { Component } from '@ember/-internals/glimmer';
@@ -14,6 +15,9 @@ import Engine from '@ember/engine';
1415
import { next } from '@ember/runloop';
1516

1617
import { compile } from '../../utils/helpers';
18+
import { setComponentTemplate } from '@glimmer/manager';
19+
import { templateOnlyComponent } from '@glimmer/runtime';
20+
import { DEPRECATIONS } from '../../../../deprecations';
1721

1822
moduleFor(
1923
'Application test: engine rendering',
@@ -217,10 +221,8 @@ moduleFor(
217221
);
218222
this.register('template:application', sharedTemplate);
219223
this.register(
220-
'template:components/ambiguous-curlies',
221-
compile(strip`
222-
<p>Component!</p>
223-
`)
224+
'component:ambiguous-curlies',
225+
setComponentTemplate(compile(`<p>Component!</p>`), templateOnlyComponent())
224226
);
225227
},
226228
})
@@ -275,10 +277,8 @@ moduleFor(
275277
);
276278
this.register('component:my-component', sharedComponent);
277279
this.register(
278-
'template:components/ambiguous-curlies',
279-
compile(strip`
280-
<p>Component!</p>
281-
`)
280+
'component:ambiguous-curlies',
281+
setComponentTemplate(compile(`<p>Component!</p>`), templateOnlyComponent())
282282
);
283283
},
284284
})

packages/internal-test-helpers/lib/test-cases/test-resolver-application.ts

+4
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@ export default abstract class TestResolverApplicationTestCase extends AbstractAp
4848
this.resolver!.add(`component:${name}`, ComponentClass);
4949

5050
if (typeof template === 'string') {
51+
// moduleName not passed to this.compile, because *it's just wrong*.
52+
// moduleName represents a path-on-disk, and we can't guarantee we have that mapping.
5153
setComponentTemplate(this.compile(template, {}), ComponentClass);
5254
}
5355

5456
return;
5557
}
5658

5759
if (typeof template === 'string') {
60+
// moduleName not passed to this.compile, because *it's just wrong*.
61+
// moduleName represents a path-on-disk, and we can't guarantee we have that mapping.
5862
let toComponent = setComponentTemplate(this.compile(template, {}), templateOnly());
5963

6064
this.resolver!.add(`component:${name}`, toComponent);

0 commit comments

Comments
 (0)