feat: show fragment ids in dev

This commit is contained in:
Evan You 2019-11-04 11:24:37 -05:00
parent 300a705221
commit e1d25e3537

View File

@ -619,6 +619,8 @@ export function createRenderer<
} }
} }
let devFragmentID = 0
function processFragment( function processFragment(
n1: HostVNode | null, n1: HostVNode | null,
n2: HostVNode, n2: HostVNode,
@ -629,10 +631,16 @@ export function createRenderer<
isSVG: boolean, isSVG: boolean,
optimized: boolean optimized: boolean
) { ) {
const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateComment(''))! const showID = __DEV__ && !__TEST__
const fragmentStartAnchor = (n2.el = n1
? n1.el
: hostCreateComment(showID ? `fragment-${devFragmentID}-start` : ''))!
const fragmentEndAnchor = (n2.anchor = n1 const fragmentEndAnchor = (n2.anchor = n1
? n1.anchor ? n1.anchor
: hostCreateComment(''))! : hostCreateComment(showID ? `fragment-${devFragmentID}-end` : ''))!
if (showID) {
devFragmentID++
}
if (n1 == null) { if (n1 == null) {
hostInsert(fragmentStartAnchor, container, anchor) hostInsert(fragmentStartAnchor, container, anchor)
hostInsert(fragmentEndAnchor, container, anchor) hostInsert(fragmentEndAnchor, container, anchor)