fix(runtime-core): fix attr fallthrough on compiled framgent w/ single static element + comments
This commit is contained in:
parent
6390ddfb7d
commit
1af3531719
@ -10,7 +10,8 @@ import {
|
|||||||
openBlock,
|
openBlock,
|
||||||
createBlock,
|
createBlock,
|
||||||
FunctionalComponent,
|
FunctionalComponent,
|
||||||
createCommentVNode
|
createCommentVNode,
|
||||||
|
Fragment
|
||||||
} from '@vue/runtime-dom'
|
} from '@vue/runtime-dom'
|
||||||
import { mockWarn } from '@vue/shared'
|
import { mockWarn } from '@vue/shared'
|
||||||
|
|
||||||
@ -573,12 +574,15 @@ describe('attribute fallthrough', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Child = {
|
const Child = {
|
||||||
setup(props: any) {
|
setup() {
|
||||||
return () => [
|
return () => (
|
||||||
createCommentVNode('hello'),
|
openBlock(),
|
||||||
h('button'),
|
createBlock(Fragment, null, [
|
||||||
createCommentVNode('world')
|
createCommentVNode('hello'),
|
||||||
]
|
h('button'),
|
||||||
|
createCommentVNode('world')
|
||||||
|
])
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +215,9 @@ export function renderComponentRoot(
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dev only
|
||||||
|
*/
|
||||||
const getChildRoot = (
|
const getChildRoot = (
|
||||||
vnode: VNode
|
vnode: VNode
|
||||||
): [VNode, ((root: VNode) => void) | undefined] => {
|
): [VNode, ((root: VNode) => void) | undefined] => {
|
||||||
@ -231,12 +234,14 @@ const getChildRoot = (
|
|||||||
}
|
}
|
||||||
const childRoot = children[0]
|
const childRoot = children[0]
|
||||||
const index = rawChildren.indexOf(childRoot)
|
const index = rawChildren.indexOf(childRoot)
|
||||||
const dynamicIndex = dynamicChildren
|
const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1
|
||||||
? dynamicChildren.indexOf(childRoot)
|
|
||||||
: null
|
|
||||||
const setRoot = (updatedRoot: VNode) => {
|
const setRoot = (updatedRoot: VNode) => {
|
||||||
rawChildren[index] = updatedRoot
|
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]
|
return [normalizeVNode(childRoot), setRoot]
|
||||||
}
|
}
|
||||||
|
@ -426,19 +426,20 @@ export function cloneVNode<T, U>(
|
|||||||
vnode: VNode<T, U>,
|
vnode: VNode<T, U>,
|
||||||
extraProps?: Data & VNodeProps | null
|
extraProps?: Data & VNodeProps | null
|
||||||
): VNode<T, U> {
|
): VNode<T, U> {
|
||||||
const props = extraProps
|
|
||||||
? vnode.props
|
|
||||||
? mergeProps(vnode.props, extraProps)
|
|
||||||
: extend({}, extraProps)
|
|
||||||
: vnode.props
|
|
||||||
// This is intentionally NOT using spread or extend to avoid the runtime
|
// This is intentionally NOT using spread or extend to avoid the runtime
|
||||||
// key enumeration cost.
|
// key enumeration cost.
|
||||||
|
const { props, patchFlag } = vnode
|
||||||
|
const mergedProps = extraProps
|
||||||
|
? props
|
||||||
|
? mergeProps(props, extraProps)
|
||||||
|
: extend({}, extraProps)
|
||||||
|
: props
|
||||||
return {
|
return {
|
||||||
__v_isVNode: true,
|
__v_isVNode: true,
|
||||||
__v_skip: true,
|
__v_skip: true,
|
||||||
type: vnode.type,
|
type: vnode.type,
|
||||||
props,
|
props: mergedProps,
|
||||||
key: props && normalizeKey(props),
|
key: mergedProps && normalizeKey(mergedProps),
|
||||||
ref: extraProps && extraProps.ref ? normalizeRef(extraProps) : vnode.ref,
|
ref: extraProps && extraProps.ref ? normalizeRef(extraProps) : vnode.ref,
|
||||||
scopeId: vnode.scopeId,
|
scopeId: vnode.scopeId,
|
||||||
children: vnode.children,
|
children: vnode.children,
|
||||||
@ -448,10 +449,14 @@ export function cloneVNode<T, U>(
|
|||||||
shapeFlag: vnode.shapeFlag,
|
shapeFlag: vnode.shapeFlag,
|
||||||
// if the vnode is cloned with extra props, we can no longer assume its
|
// if the vnode is cloned with extra props, we can no longer assume its
|
||||||
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
||||||
|
// note: perserve flag for fragments since they use the flag for children
|
||||||
|
// fast paths only.
|
||||||
patchFlag:
|
patchFlag:
|
||||||
extraProps && vnode.type !== Fragment
|
extraProps && vnode.type !== Fragment
|
||||||
? vnode.patchFlag | PatchFlags.FULL_PROPS
|
? patchFlag === -1 // hoisted node
|
||||||
: vnode.patchFlag,
|
? PatchFlags.FULL_PROPS
|
||||||
|
: patchFlag | PatchFlags.FULL_PROPS
|
||||||
|
: patchFlag,
|
||||||
dynamicProps: vnode.dynamicProps,
|
dynamicProps: vnode.dynamicProps,
|
||||||
dynamicChildren: vnode.dynamicChildren,
|
dynamicChildren: vnode.dynamicChildren,
|
||||||
appContext: vnode.appContext,
|
appContext: vnode.appContext,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user