fix(attr-fallthrough): ensure consistent attr fallthrough for root fragments with comments
fix #2549
This commit is contained in:
@@ -314,14 +314,23 @@ function createRootCodegen(root: RootNode, context: TransformContext) {
|
||||
}
|
||||
} else if (children.length > 1) {
|
||||
// root has multiple nodes - return a fragment block.
|
||||
let patchFlag = PatchFlags.STABLE_FRAGMENT
|
||||
let patchFlagText = PatchFlagNames[PatchFlags.STABLE_FRAGMENT]
|
||||
// check if the fragment actually contains a single valid child with
|
||||
// the rest being comments
|
||||
if (
|
||||
__DEV__ &&
|
||||
children.filter(c => c.type !== NodeTypes.COMMENT).length === 1
|
||||
) {
|
||||
patchFlag |= PatchFlags.DEV_ROOT_FRAGMENT
|
||||
patchFlagText += `, ${PatchFlagNames[PatchFlags.DEV_ROOT_FRAGMENT]}`
|
||||
}
|
||||
root.codegenNode = createVNodeCall(
|
||||
context,
|
||||
helper(FRAGMENT),
|
||||
undefined,
|
||||
root.children,
|
||||
`${PatchFlags.STABLE_FRAGMENT} /* ${
|
||||
PatchFlagNames[PatchFlags.STABLE_FRAGMENT]
|
||||
} */`,
|
||||
patchFlag + (__DEV__ ? ` /* ${patchFlagText} */` : ``),
|
||||
undefined,
|
||||
undefined,
|
||||
true
|
||||
|
||||
Reference in New Issue
Block a user