mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
make sure subwidgets have proper parents
This commit is contained in:
@@ -682,7 +682,7 @@ const widgetDirective: Directive = {
|
|||||||
let props = node.getAttribute("t-props");
|
let props = node.getAttribute("t-props");
|
||||||
let widgetID = ctx.generateID();
|
let widgetID = ctx.generateID();
|
||||||
ctx.addLine(
|
ctx.addLine(
|
||||||
`let _${widgetID} = new context.widgets['${value}'](context, ${props})`
|
`let _${widgetID} = new context.widgets['${value}'](owner, ${props})`
|
||||||
);
|
);
|
||||||
ctx.addLine(
|
ctx.addLine(
|
||||||
`let def${defID} = _${widgetID}._start().then(() => _${widgetID}._render()).then(vnode=>{Object.assign(_${dummyID}, vnode);_${dummyID}.key="${dummyID}";_${dummyID}.data.hook = {create(_,vn){_${widgetID}._mount(vn)}}})`
|
`let def${defID} = _${widgetID}._start().then(() => _${widgetID}._render()).then(vnode=>{Object.assign(_${dummyID}, vnode);_${dummyID}.key="${dummyID}";_${dummyID}.data.hook = {create(_,vn){_${widgetID}._mount(vn)}}})`
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ describe("composition", () => {
|
|||||||
const widget = new WidgetA(env);
|
const widget = new WidgetA(env);
|
||||||
await widget.mount(fixture);
|
await widget.mount(fixture);
|
||||||
expect(fixture.innerHTML).toBe("<div>Hello<div>world</div></div>");
|
expect(fixture.innerHTML).toBe("<div>Hello<div>world</div></div>");
|
||||||
|
expect(widget._.children[0]._.parent).toBe(widget);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("t-refs on widget are widgets", async () => {
|
test("t-refs on widget are widgets", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user