createVNode,
VNode,
VNodeChildren
-} from './h.js'
+} from './vnode.js'
import { TEXT, CLASS, STYLE, PROPS, KEYED, UNKEYED } from './patchFlags'
+import { isString, isFunction, isArray } from '@vue/shared'
const emptyArr: any[] = []
const emptyObj: { [key: string]: any } = {}
processEmptyNode(n1, n2, container, anchor)
} else if (type === Fragment) {
processFragment(n1, n2, container, anchor, optimized)
- } else if (typeof type === 'function') {
- // TODO Component
+ } else if (isFunction(type)) {
+ processComponent(n1, n2, container, anchor)
} else {
processElement(n1, n2, container, anchor, optimized)
}
hostPatchProp(el, key, vnode.props[key], null, false)
}
}
- if (typeof vnode.children === 'string') {
+ if (isString(vnode.children)) {
hostSetElementText(el, vnode.children)
} else if (vnode.children != null) {
mountChildren(vnode.children, el)
if (child == null) {
// empty placeholder
return createVNode(Empty)
- } else if (Array.isArray(child)) {
+ } else if (isArray(child)) {
// fragment
return createVNode(Fragment, null, child)
} else if (typeof child === 'object') {
}
}
+ function processComponent(
+ n1: VNode | null,
+ n2: VNode,
+ container: HostNode,
+ anchor?: HostNode
+ ) {}
+
function patchChildren(
n1: VNode | null,
n2: VNode,
}
}
- if (typeof c2 === 'string') {
+ if (isString(c2)) {
// text children fast path
- if (Array.isArray(c1)) {
+ if (isArray(c1)) {
unmountChildren(c1 as VNode[])
}
hostSetElementText(container, c2)
} else {
- if (typeof c1 === 'string') {
+ if (isString(c1)) {
hostSetElementText(container, '')
if (c2 != null) {
mountChildren(c2, container, anchor)
}
- } else if (Array.isArray(c1)) {
- if (Array.isArray(c2)) {
+ } else if (isArray(c1)) {
+ if (isArray(c2)) {
// two arrays, cannot assume anything, do full diff
patchKeyedChildren(c1 as VNode[], c2, container, anchor, optimized)
} else {
const shouldRemoveChildren = vnode.type === Fragment && doRemove
if (vnode.dynamicChildren != null) {
unmountChildren(vnode.dynamicChildren, shouldRemoveChildren)
- } else if (Array.isArray(vnode.children)) {
+ } else if (isArray(vnode.children)) {
unmountChildren(vnode.children as VNode[], shouldRemoveChildren)
}
if (doRemove) {