wip: portal

This commit is contained in:
Evan You
2019-05-29 16:10:25 +08:00
parent 178c7c827e
commit 453cdcd600
4 changed files with 85 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
import { isArray, isFunction } from '@vue/shared'
import { isArray, isFunction, EMPTY_ARR } from '@vue/shared'
import { ComponentInstance } from './component'
import { HostNode } from './createRenderer'
@@ -29,6 +29,7 @@ export interface VNode {
// DOM
el: HostNode | null
anchor: HostNode | null // fragment anchor
target: HostNode | null // portal target
// optimization only
patchFlag: number | null
@@ -59,7 +60,7 @@ export function createBlock(
shouldTrack = true
const trackedNodes = blockStack.pop()
vnode.dynamicChildren =
trackedNodes && trackedNodes.length ? trackedNodes : null
trackedNodes && trackedNodes.length ? trackedNodes : EMPTY_ARR
// a block is always going to be patched
trackDynamicNode(vnode)
return vnode
@@ -81,6 +82,7 @@ export function createVNode(
component: null,
el: null,
anchor: null,
target: null,
patchFlag,
dynamicProps,
dynamicChildren: null