mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
@@ -705,11 +705,13 @@ QWeb.addDirective({
|
|||||||
ctx.addLine(
|
ctx.addLine(
|
||||||
`const slot${slotKey} = this.slots[context.__owl__.slotId + '_' + '${value}'];`
|
`const slot${slotKey} = this.slots[context.__owl__.slotId + '_' + '${value}'];`
|
||||||
);
|
);
|
||||||
|
ctx.addIf(`slot${slotKey}`)
|
||||||
ctx.addLine(
|
ctx.addLine(
|
||||||
`slot${slotKey}(context.__owl__.parent, Object.assign({}, extra, {parentNode: c${
|
`slot${slotKey}(context.__owl__.parent, Object.assign({}, extra, {parentNode: c${
|
||||||
ctx.parentNode
|
ctx.parentNode
|
||||||
}}));`
|
}}));`
|
||||||
);
|
);
|
||||||
|
ctx.closeIf();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1083,12 +1083,16 @@ exports[`t-slot directive can define and call slots 2`] = `
|
|||||||
var vn2 = h('div', p2, c2);
|
var vn2 = h('div', p2, c2);
|
||||||
c1.push(vn2);
|
c1.push(vn2);
|
||||||
const slot3 = this.slots[context.__owl__.slotId + '_' + 'header'];
|
const slot3 = this.slots[context.__owl__.slotId + '_' + 'header'];
|
||||||
slot3(context.__owl__.parent, Object.assign({}, extra, {parentNode: c2}));
|
if (slot3) {
|
||||||
|
slot3(context.__owl__.parent, Object.assign({}, extra, {parentNode: c2}));
|
||||||
|
}
|
||||||
let c4 = [], p4 = {key:4};
|
let c4 = [], p4 = {key:4};
|
||||||
var vn4 = h('div', p4, c4);
|
var vn4 = h('div', p4, c4);
|
||||||
c1.push(vn4);
|
c1.push(vn4);
|
||||||
const slot5 = this.slots[context.__owl__.slotId + '_' + 'footer'];
|
const slot5 = this.slots[context.__owl__.slotId + '_' + 'footer'];
|
||||||
slot5(context.__owl__.parent, Object.assign({}, extra, {parentNode: c4}));
|
if (slot5) {
|
||||||
|
slot5(context.__owl__.parent, Object.assign({}, extra, {parentNode: c4}));
|
||||||
|
}
|
||||||
return vn1;
|
return vn1;
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3031,6 +3031,30 @@ describe("t-slot directive", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("missing slots are ignored", async () => {
|
||||||
|
env.qweb.addTemplates(`
|
||||||
|
<templates>
|
||||||
|
<div t-name="Parent">
|
||||||
|
<Dialog/>
|
||||||
|
</div>
|
||||||
|
<span t-name="Dialog">
|
||||||
|
<t t-slot="default"/>
|
||||||
|
<span>some content</span>
|
||||||
|
<t t-slot="footer"/>
|
||||||
|
</span>
|
||||||
|
</templates>
|
||||||
|
`);
|
||||||
|
class Dialog extends Widget {}
|
||||||
|
class Parent extends Widget {
|
||||||
|
components = { Dialog };
|
||||||
|
}
|
||||||
|
const parent = new Parent(env);
|
||||||
|
await parent.mount(fixture);
|
||||||
|
|
||||||
|
expect(fixture.innerHTML).toBe(
|
||||||
|
'<div><span><span>some content</span></span></div>'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("t-model directive", () => {
|
describe("t-model directive", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user