accessedAttrs = true
}
+type SetRootFn = ((root: VNode) => void) | undefined
+
export function renderComponentRoot(
instance: ComponentInternalInstance
): VNode {
// in dev mode, comments are preserved, and it's possible for a template
// to have comments along side the root element which makes it a fragment
let root = result
- let setRoot: ((root: VNode) => void) | undefined = undefined
+ let setRoot: SetRootFn = undefined
if (
__DEV__ &&
result.patchFlag > 0 &&
* template into a fragment root, but we need to locate the single element
* root for attrs and scope id processing.
*/
-const getChildRoot = (
- vnode: VNode
-): [VNode, ((root: VNode) => void) | undefined] => {
+const getChildRoot = (vnode: VNode): [VNode, SetRootFn] => {
const rawChildren = vnode.children as VNodeArrayChildren
const dynamicChildren = vnode.dynamicChildren
const childRoot = filterSingleRoot(rawChildren)
}
const index = rawChildren.indexOf(childRoot)
const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1
- const setRoot = (updatedRoot: VNode) => {
+ const setRoot: SetRootFn = (updatedRoot: VNode) => {
rawChildren[index] = updatedRoot
if (dynamicChildren) {
if (dynamicIndex > -1) {