Skip to content

Commit

Permalink
Merge pull request #1445 from emberjs/fix-canary
Browse files Browse the repository at this point in the history
Fix ember-canary error/deprecation
  • Loading branch information
chancancode authored Nov 19, 2023
2 parents dd7bd45 + b348397 commit 99c9e47
Showing 1 changed file with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export interface RenderOptions {
Renders the provided template and appends it to the DOM.
@public
@param {Template|Component} templateOrComponent the component (or template) to render
@param {Template|Component} templateFactoryOrComponent the component (or template) to render
@param {RenderOptions} options options hash containing engine owner ({ owner: engineOwner })
@returns {Promise<void>} resolves when settled
Expand All @@ -99,12 +99,12 @@ export interface RenderOptions {
await render(hbs`<div class="container"></div>`);
*/
export function render(
templateOrComponent: object,
templateFactoryOrComponent: object,
options?: RenderOptions
): Promise<void> {
let context = getContext();

if (!templateOrComponent) {
if (!templateFactoryOrComponent) {
throw new Error('you must pass a template to `render()`');
}

Expand All @@ -128,7 +128,7 @@ export function render(
let OutletTemplate = lookupOutletTemplate(owner);
let ownerToRenderFrom = options?.owner || owner;

if (isComponent(templateOrComponent)) {
if (isComponent(templateFactoryOrComponent)) {
// We use this to track when `render` is used with a component so that we can throw an
// assertion if `this.{set,setProperty} is used in the same test
ComponentRenderMap.set(context, true);
Expand All @@ -144,19 +144,16 @@ export function render(
}

context = {
ProvidedComponent: templateOrComponent,
ProvidedComponent: templateFactoryOrComponent,
};
templateOrComponent = INVOKE_PROVIDED_COMPONENT;
} else {
templateId += 1;
let templateFullName = `template:-undertest-${templateId}` as const;
ownerToRenderFrom.register(templateFullName, templateOrComponent);
templateOrComponent = lookupTemplate(
ownerToRenderFrom,
templateFullName
);
templateFactoryOrComponent = INVOKE_PROVIDED_COMPONENT;
}

templateId += 1;
let templateFullName = `template:-undertest-${templateId}` as const;
ownerToRenderFrom.register(templateFullName, templateFactoryOrComponent);
let template = lookupTemplate(ownerToRenderFrom, templateFullName);

let outletState = {
render: {
owner, // always use the host app owner for application outlet
Expand All @@ -177,7 +174,7 @@ export function render(
name: 'index',
controller: context,
ViewClass: undefined,
template: templateOrComponent,
template,
outlets: {},
},
outlets: {},
Expand Down

0 comments on commit 99c9e47

Please sign in to comment.