Skip to content

Commit

Permalink
fix: cloneElement should clone void vnode as well
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Mar 8, 2018
1 parent a4cb918 commit b007de9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/nerv/src/clone-element.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import createElement from './create-element'
import createVText from './vdom/create-vtext'
import { extend, clone, isArray, isString } from 'nerv-utils'
import { isVText, isVNode, EMPTY_CHILDREN, VType, isNullOrUndef } from 'nerv-shared'
import { isVText, isVNode, EMPTY_CHILDREN, VType, isNullOrUndef, isPortal, isInvalid } from 'nerv-shared'
import { createVoid } from './vdom/create-void'

export default function cloneElement (vnode, props?: object, ...children): any {
if (isVText(vnode)) {
Expand All @@ -10,6 +11,9 @@ export default function cloneElement (vnode, props?: object, ...children): any {
if (isString(vnode)) {
return createVText(vnode)
}
if (!isInvalid(vnode) && isPortal(vnode.vtype, vnode)) {
return createVoid()
}
const properties = clone(extend(clone(vnode.props), props))
if (vnode.namespace) {
properties.namespace = vnode.namespace
Expand Down

0 comments on commit b007de9

Please sign in to comment.