# all files / src/ cloneElement.js

0% Statements 0/9
0% Branches 0/12
0% Functions 0/1
0% Lines 0/9

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24

     import {
        createElement
    } from './createElement'

    export function cloneElement(vnode, props) {
      if (!vnode.vtype) {
        return Object.assign({}, vnode);
      }
      if (vnode.key) {
        vnode.props.key = vode.key;
      }
      if (vnode._refKey) {
        vnode.props.ref = vnode._refKey;
      } else if (vnode.ref && vnode.ref !== vnode.constructor.prototype.ref) {
        vnode.props.ref = vnode.ref;
      }

      return createElement(
        vnode.type,
        Object.assign({}, vnode.props, props),
        arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.props.children
      )
    }