DEV: Set owner for raw views

Plugins/themes use injections in their raw view class. On recent versions of Ember these were failing with 'Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.'
This commit is contained in:
David Taylor 2022-07-11 23:03:56 +01:00
parent a4c4d3cb50
commit 897de60330
1 changed files with 2 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import { helperContext, registerUnbound } from "discourse-common/lib/helpers";
import { findRawTemplate } from "discourse-common/lib/raw-templates"; import { findRawTemplate } from "discourse-common/lib/raw-templates";
import { htmlSafe } from "@ember/template"; import { htmlSafe } from "@ember/template";
import { RUNTIME_OPTIONS } from "discourse-common/lib/raw-handlebars-helpers"; import { RUNTIME_OPTIONS } from "discourse-common/lib/raw-handlebars-helpers";
import { getOwner, setOwner } from "@ember/application";
function renderRaw(ctx, template, templateName, params) { function renderRaw(ctx, template, templateName, params) {
params = Object.assign({}, params); params = Object.assign({}, params);
@ -13,6 +14,7 @@ function renderRaw(ctx, template, templateName, params) {
if (viewClass) { if (viewClass) {
params.view = viewClass.create(params, context); params.view = viewClass.create(params, context);
setOwner(params.view, getOwner(context.site));
} }
if (!params.view) { if (!params.view) {