Skip to content

Commit

Permalink
Merge pull request #20578 from emberjs/beta-deprecate-outlet-template…
Browse files Browse the repository at this point in the history
…-factory

[BUGFIX beta] Deprecate outlet `TemplateFactory` support
  • Loading branch information
chancancode committed Nov 20, 2023
2 parents 72ca377 + f5a1cb9 commit 7694ed0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
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

0 comments on commit 7694ed0

Please sign in to comment.