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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Deprecate outlet TemplateFactory support #20578

Merged
merged 1 commit into from
Nov 20, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion packages/@ember/-internals/glimmer/lib/syntax/outlet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { InternalOwner } from '@ember/-internals/owner';
import { assert } from '@ember/debug';
import { assert, deprecate } from '@ember/debug';
import { DEBUG } from '@glimmer/env';
import type { CapturedArguments, DynamicScope } from '@glimmer/interfaces';
import { CurriedType } from '@glimmer/interfaces';
Expand Down Expand Up @@ -124,6 +124,36 @@ function stateFor(ref: Reference, outlet: OutletState | undefined): OutletDefini
// and is no longer considered supported
if (isTemplateFactory(template)) {
template = template(render.owner);

if (DEBUG) {
let message =
'The `template` property of `OutletState` should be a ' +
'`Template` rather than a `TemplateFactory`. This is known to be a ' +
"problem in older versions of `@ember/test-helpers`. If you haven't " +
'done so already, try upgrading to the latest version.\n\n';

if (template.result === 'ok' && typeof template.moduleName === 'string') {
message +=
'The offending template has a moduleName `' +
template.moduleName +
'`, which might be helpful for identifying ' +
'source of this issue.\n\n';
}

message +=
'Please note that `OutletState` is a private API in Ember.js ' +
"and not meant to be used outside of the framework's internal code.";

deprecate(message, false, {
id: 'outlet-state-template-factory',
until: '5.9.0',
for: 'ember-source',
since: {
available: '5.5.0',
enabled: '5.5.0',
},
});
}
}

return {
Expand Down
4 changes: 4 additions & 0 deletions packages/ember/tests/ember-test-helpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ module('@ember/test-helpers emulation test', function () {

module('setupRenderingContext', function (hooks) {
hooks.beforeEach(async function () {
expectDeprecation(
/The `template` property of `OutletState` should be a `Template` rather than a `TemplateFactory`/
);

this.application = Application.create({
rootElement: '#qunit-fixture',
autoboot: false,
Expand Down
Loading