[IMP] qweb: t-props directive

We reimplement the directive "t-props" and add some tests for it.
This commit is contained in:
Mathieu Duckerts-Antoine
2021-10-20 15:25:32 +02:00
committed by Géry Debongnie
parent 700d574314
commit ba2fe3ff55
7 changed files with 181 additions and 5 deletions
+5 -1
View File
@@ -105,6 +105,7 @@ export interface ASTComponent {
type: ASTType.TComponent;
name: string;
isDynamic: boolean;
dynamicProps: string | null;
props: { [name: string]: string };
handlers: { [event: string]: string };
slots: { [name: string]: AST };
@@ -657,6 +658,9 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
node.removeAttribute("t-component");
}
const dynamicProps = node.getAttribute("t-props");
node.removeAttribute("t-props");
const props: ASTComponent["props"] = {};
const handlers: ASTComponent["handlers"] = {};
for (let name of node.getAttributeNames()) {
@@ -706,7 +710,7 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
slots.default = defaultContent;
}
}
return { type: ASTType.TComponent, name, isDynamic, props, handlers, slots };
return { type: ASTType.TComponent, name, isDynamic, dynamicProps, props, handlers, slots };
}
// -----------------------------------------------------------------------------