mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79ea50aab9 |
@@ -46,6 +46,8 @@ Here is how the `Navbar` component could be defined, with the `t-slot` directive
|
||||
</div>
|
||||
```
|
||||
|
||||
Note that `t-slot` can only be used on a `<t>` element.
|
||||
|
||||
## Named slots
|
||||
|
||||
Default slots are very useful, but sometimes, we may need more than one slot.
|
||||
|
||||
@@ -798,6 +798,12 @@ function parseTSlot(node: Element, ctx: ParsingContext): AST | null {
|
||||
if (!node.hasAttribute("t-slot")) {
|
||||
return null;
|
||||
}
|
||||
if (node.tagName !== "t") {
|
||||
throw new OwlError(
|
||||
`Directive 't-slot' can only be used on <t> nodes (used on a <${node.tagName}>)`
|
||||
);
|
||||
}
|
||||
|
||||
const name = node.getAttribute("t-slot")!;
|
||||
node.removeAttribute("t-slot");
|
||||
let attrs: Attrs | null = null;
|
||||
|
||||
@@ -1686,6 +1686,12 @@ describe("qweb parser", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("t-slot on a div tag should throw", async () => {
|
||||
expect(() => parse(`<div t-slot="name"/>`)).toThrowError(
|
||||
"Directive 't-slot' can only be used on <t> nodes (used on a <div>)"
|
||||
);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// t-debug
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user