|
@@ -43,6 +43,7 @@ function walk(
|
|
|
resultCache: Map<TemplateChildNode, boolean>,
|
|
resultCache: Map<TemplateChildNode, boolean>,
|
|
|
doNotHoistNode: boolean = false
|
|
doNotHoistNode: boolean = false
|
|
|
) {
|
|
) {
|
|
|
|
|
+ let hasHoistedNode = false
|
|
|
for (let i = 0; i < children.length; i++) {
|
|
for (let i = 0; i < children.length; i++) {
|
|
|
const child = children[i]
|
|
const child = children[i]
|
|
|
// only plain elements & text calls are eligible for hoisting.
|
|
// only plain elements & text calls are eligible for hoisting.
|
|
@@ -55,6 +56,7 @@ function walk(
|
|
|
;(child.codegenNode as VNodeCall).patchFlag =
|
|
;(child.codegenNode as VNodeCall).patchFlag =
|
|
|
PatchFlags.HOISTED + (__DEV__ ? ` /* HOISTED */` : ``)
|
|
PatchFlags.HOISTED + (__DEV__ ? ` /* HOISTED */` : ``)
|
|
|
child.codegenNode = context.hoist(child.codegenNode!)
|
|
child.codegenNode = context.hoist(child.codegenNode!)
|
|
|
|
|
+ hasHoistedNode = true
|
|
|
continue
|
|
continue
|
|
|
} else {
|
|
} else {
|
|
|
// node may contain dynamic children, but its props may be eligible for
|
|
// node may contain dynamic children, but its props may be eligible for
|
|
@@ -81,6 +83,7 @@ function walk(
|
|
|
isStaticNode(child.content, resultCache)
|
|
isStaticNode(child.content, resultCache)
|
|
|
) {
|
|
) {
|
|
|
child.codegenNode = context.hoist(child.codegenNode)
|
|
child.codegenNode = context.hoist(child.codegenNode)
|
|
|
|
|
+ hasHoistedNode = true
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// walk further
|
|
// walk further
|
|
@@ -98,7 +101,7 @@ function walk(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (context.transformHoist) {
|
|
|
|
|
|
|
+ if (hasHoistedNode && context.transformHoist) {
|
|
|
context.transformHoist(children, context)
|
|
context.transformHoist(children, context)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|