Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): inherit attrs inconsistent (#2549) #2640

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions packages/runtime-core/src/componentRenderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import {
isVNode
} from './vnode'
import { handleError, ErrorCodes } from './errorHandling'
import { PatchFlags, ShapeFlags, isOn, isModelListener } from '@vue/shared'
import {
PatchFlags,
ShapeFlags,
isOn,
isModelListener,
isArray
} from '@vue/shared'
import { warn } from './warning'
import { isHmrUpdating } from './hmr'
import { NormalizedProps } from './componentProps'
Expand Down Expand Up @@ -117,7 +123,7 @@ export function renderComponentRoot(
// to have comments along side the root element which makes it a fragment
let root = result
let setRoot: ((root: VNode) => void) | undefined = undefined
if (__DEV__) {
if (__DEV__ && isRootCommentEffectChild(root)) {
;[root, setRoot] = getChildRoot(result)
}

Expand Down Expand Up @@ -247,6 +253,20 @@ const getChildRoot = (
return [normalizeVNode(childRoot), setRoot]
}

const isRootCommentEffectChild = (vnode: VNode): boolean => {
const { children } = vnode
if (isArray(children)) {
let isFragmentChild = false
const comments = children.filter(child => {
if ((child as VNode).type === Fragment) isFragmentChild = true
return (child as VNode).type === Comment
})
return !isFragmentChild && comments.length === children.length - 1
}

return false
}

/**
* dev only
*/
Expand Down