[IMP] compiler: allow to declare default slot scope on component

This commit is contained in:
Samuel Degueldre
2022-02-02 08:36:11 +01:00
committed by Aaron Bohy
parent 83de53d283
commit 140818b5f9
4 changed files with 134 additions and 55 deletions
+6
View File
@@ -677,6 +677,9 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
const dynamicProps = node.getAttribute("t-props");
node.removeAttribute("t-props");
const defaultSlotScope = node.getAttribute("t-slot-scope");
node.removeAttribute("t-slot-scope");
const props: ASTComponent["props"] = {};
for (let name of node.getAttributeNames()) {
const value = node.getAttribute(name)!;
@@ -742,6 +745,9 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
const defaultContent = parseChildNodes(clone, ctx);
if (defaultContent) {
slots.default = { content: defaultContent };
if (defaultSlotScope) {
slots.default.scope = defaultSlotScope;
}
}
}
return { type: ASTType.TComponent, name, isDynamic, dynamicProps, props, slots };