Last active
April 13, 2016 17:13
-
-
Save developit/6adf4f42e5e196702124262a32fe2914 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { h } from 'preact'; | |
| export default function cloneElement(vnode, props, ...children) { | |
| return h( | |
| vnode.nodeName, | |
| extend(extend({}, vnode.attributes || {}), props), | |
| children.length ? children : vnode.children | |
| ); | |
| } | |
| // Object.assign() ponyfill | |
| function extend(obj, props) { | |
| for (let i in props) { | |
| if (props.hasOwnProperty(i)) { | |
| obj[i] = props[i]; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment