[FIX] parser: give t-set-slot="default" priority over the content

Currently, if a component has a default slot defined with t-set-slot,
and also content that compiles to something (eg, text or even a comment
node), the content takes priority over the t-set-slot. As t-set-slot is
more explicity, it should have priority.
This commit is contained in:
Samuel Degueldre
2022-10-10 13:54:20 +02:00
committed by Géry Debongnie
parent d546244fc3
commit ba1a270c93
3 changed files with 50 additions and 2 deletions
+3 -2
View File
@@ -781,8 +781,9 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
// default slot
const defaultContent = parseChildNodes(clone, ctx);
if (defaultContent) {
slots = slots || {};
slots = slots || {};
// t-set-slot="default" has priority over content
if (defaultContent && !slots.default) {
slots.default = { content: defaultContent, on, attrs: null, scope: defaultSlotScope };
}
}