chore: improve

This commit is contained in:
daiwei 2025-03-09 22:11:37 +08:00
parent 7c9bd7c093
commit 5392c7a956
1 changed files with 3 additions and 7 deletions

View File

@ -32,16 +32,11 @@ function hasMultipleChildren(node: ElementNode): boolean {
const first = children[0]
// template
if (first && isTemplateNode(first)) {
return true
}
// has v-for
if (
children.length === 1 &&
first.type === NodeTypes.ELEMENT &&
findDir(first, 'for')
(findDir(first, 'for') || isTemplateNode(first))
) {
return true
}
@ -51,10 +46,11 @@ function hasMultipleChildren(node: ElementNode): boolean {
// has v-if/v-else-if/v-else
if (
children.length > 1 &&
children.every(
(c, index) =>
c.type === NodeTypes.ELEMENT &&
// not template
!isTemplateNode(c) &&
// not has v-for
!findDir(c, 'for') &&
// if the first child has v-if, the rest should also have v-else-if/v-else