mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
@@ -235,9 +235,11 @@ QWeb.addDirective({
|
||||
`def${defID} = w${widgetID}._updateProps(props${widgetID}, extra.forceUpdate, extra.patchQueue);`
|
||||
);
|
||||
ctx.addElse();
|
||||
ctx.addLine(
|
||||
`w${widgetID} = new context.widgets['${value}'](owner, props${widgetID});`
|
||||
);
|
||||
ctx.addLine(`let W${widgetID} = context.widgets['${value}'];`);
|
||||
|
||||
// maybe only do this in dev mode...
|
||||
ctx.addLine(`if (!W${widgetID}) {throw new Error(\`Cannot find the definition of widget "${value}"\`)}`);
|
||||
ctx.addLine(`w${widgetID} = new W${widgetID}(owner, props${widgetID});`);
|
||||
ctx.addLine(
|
||||
`context.__owl__.cmap[${templateID}] = w${widgetID}.__owl__.id;`
|
||||
);
|
||||
|
||||
@@ -31,7 +31,9 @@ exports[`class and style attributes with t-widget dynamic t-att-style is properl
|
||||
if (w4) {
|
||||
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
||||
} else {
|
||||
w4 = new context.widgets['child'](owner, props4);
|
||||
let W4 = context.widgets['child'];
|
||||
if (!W4) {throw new Error(\`Cannot find the definition of widget \\"child\\"\`)}
|
||||
w4 = new W4(owner, props4);
|
||||
context.__owl__.cmap[4] = w4.__owl__.id;
|
||||
def3 = w4._prepare();
|
||||
}
|
||||
@@ -78,7 +80,9 @@ exports[`class and style attributes with t-widget t-att-class is properly added/
|
||||
if (w4) {
|
||||
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
||||
} else {
|
||||
w4 = new context.widgets['child'](owner, props4);
|
||||
let W4 = context.widgets['child'];
|
||||
if (!W4) {throw new Error(\`Cannot find the definition of widget \\"child\\"\`)}
|
||||
w4 = new W4(owner, props4);
|
||||
context.__owl__.cmap[4] = w4.__owl__.id;
|
||||
def3 = w4._prepare();
|
||||
}
|
||||
@@ -143,7 +147,9 @@ exports[`composition sub widgets with some state rendered in a loop 1`] = `
|
||||
if (w7) {
|
||||
def6 = w7._updateProps(props7, extra.forceUpdate, extra.patchQueue);
|
||||
} else {
|
||||
w7 = new context.widgets['ChildWidget'](owner, props7);
|
||||
let W7 = context.widgets['ChildWidget'];
|
||||
if (!W7) {throw new Error(\`Cannot find the definition of widget \\"ChildWidget\\"\`)}
|
||||
w7 = new W7(owner, props7);
|
||||
context.__owl__.cmap[key8] = w7.__owl__.id;
|
||||
def6 = w7._prepare();
|
||||
}
|
||||
@@ -191,7 +197,9 @@ exports[`random stuff/miscellaneous snapshotting compiled code 1`] = `
|
||||
if (w4) {
|
||||
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
||||
} else {
|
||||
w4 = new context.widgets['child'](owner, props4);
|
||||
let W4 = context.widgets['child'];
|
||||
if (!W4) {throw new Error(\`Cannot find the definition of widget \\"child\\"\`)}
|
||||
w4 = new W4(owner, props4);
|
||||
context.__owl__.cmap[key5] = w4.__owl__.id;
|
||||
def3 = w4._prepare();
|
||||
}
|
||||
@@ -237,7 +245,9 @@ exports[`random stuff/miscellaneous t-props should not be undefined (snapshottin
|
||||
if (w4) {
|
||||
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
||||
} else {
|
||||
w4 = new context.widgets['child'](owner, props4);
|
||||
let W4 = context.widgets['child'];
|
||||
if (!W4) {throw new Error(\`Cannot find the definition of widget \\"child\\"\`)}
|
||||
w4 = new W4(owner, props4);
|
||||
context.__owl__.cmap[4] = w4.__owl__.id;
|
||||
def3 = w4._prepare();
|
||||
}
|
||||
|
||||
+22
-1
@@ -852,6 +852,25 @@ describe("composition", () => {
|
||||
expect(children(widget)[0].__owl__.parent).toBe(widget);
|
||||
});
|
||||
|
||||
test("throw a nice error if it cannot find widget", async () => {
|
||||
expect.assertions(1);
|
||||
env.qweb.addTemplate(
|
||||
"Parent",
|
||||
`<div><t t-widget="SomeMispelledWidget"/></div>`
|
||||
);
|
||||
class Parent extends Widget {
|
||||
widgets = { SomeWidget: Widget };
|
||||
}
|
||||
const parent = new Parent(env);
|
||||
try {
|
||||
await parent.mount(fixture);
|
||||
} catch (e) {
|
||||
expect(e.message).toBe(
|
||||
'Cannot find the definition of widget "SomeMispelledWidget"'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("t-refs on widget are widgets", async () => {
|
||||
env.qweb.addTemplate(
|
||||
"WidgetC",
|
||||
@@ -1956,7 +1975,9 @@ describe("async rendering", () => {
|
||||
|
||||
const app = new App(env);
|
||||
await app.mount(fixture);
|
||||
expect(fixture.innerHTML).toBe("<div><ul><li><div>1</div></li><li><div>2</div></li></ul></div>");
|
||||
expect(fixture.innerHTML).toBe(
|
||||
"<div><ul><li><div>1</div></li><li><div>2</div></li></ul></div>"
|
||||
);
|
||||
});
|
||||
|
||||
test("properly behave when destroyed/unmounted while rendering ", async () => {
|
||||
|
||||
Reference in New Issue
Block a user