fix(runtime-core): fix attr fallthrough on compiled framgent w/ single static element + comments

This commit is contained in:
Evan You
2020-07-21 13:09:58 -04:00
parent 6390ddfb7d
commit 1af3531719
3 changed files with 34 additions and 20 deletions

View File

@@ -215,6 +215,9 @@ export function renderComponentRoot(
return result
}
/**
* dev only
*/
const getChildRoot = (
vnode: VNode
): [VNode, ((root: VNode) => void) | undefined] => {
@@ -231,12 +234,14 @@ const getChildRoot = (
}
const childRoot = children[0]
const index = rawChildren.indexOf(childRoot)
const dynamicIndex = dynamicChildren
? dynamicChildren.indexOf(childRoot)
: null
const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1
const setRoot = (updatedRoot: VNode) => {
rawChildren[index] = updatedRoot
if (dynamicIndex !== null) dynamicChildren[dynamicIndex] = updatedRoot
if (dynamicIndex > -1) {
dynamicChildren[dynamicIndex] = updatedRoot
} else if (dynamicChildren && updatedRoot.patchFlag > 0) {
dynamicChildren.push(updatedRoot)
}
}
return [normalizeVNode(childRoot), setRoot]
}