(vnode: VNode)
| 281 | * root for attrs and scope id processing. |
| 282 | */ |
| 283 | const getChildRoot = (vnode: VNode): [VNode, SetRootFn] => { |
| 284 | const rawChildren = vnode.children as VNodeArrayChildren |
| 285 | const dynamicChildren = vnode.dynamicChildren |
| 286 | const childRoot = filterSingleRoot(rawChildren, false) |
| 287 | if (!childRoot) { |
| 288 | return [vnode, undefined] |
| 289 | } else if ( |
| 290 | __DEV__ && |
| 291 | childRoot.patchFlag > 0 && |
| 292 | childRoot.patchFlag & PatchFlags.DEV_ROOT_FRAGMENT |
| 293 | ) { |
| 294 | return getChildRoot(childRoot) |
| 295 | } |
| 296 | |
| 297 | const index = rawChildren.indexOf(childRoot) |
| 298 | const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1 |
| 299 | const setRoot: SetRootFn = (updatedRoot: VNode) => { |
| 300 | rawChildren[index] = updatedRoot |
| 301 | if (dynamicChildren) { |
| 302 | if (dynamicIndex > -1) { |
| 303 | dynamicChildren[dynamicIndex] = updatedRoot |
| 304 | } else if (updatedRoot.patchFlag > 0) { |
| 305 | vnode.dynamicChildren = [...dynamicChildren, updatedRoot] |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | return [normalizeVNode(childRoot), setRoot] |
| 310 | } |
| 311 | |
| 312 | export function filterSingleRoot( |
| 313 | children: VNodeArrayChildren, |
no test coverage detected