-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (20 loc) · 750 Bytes
/
index.js
File metadata and controls
26 lines (20 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { element } from 'deku'
import { string } from 'to-style'
import classNames from 'classnames'
import componentType from 'component-type'
export default function magic (type, attributes, ...children) {
const vnode = element(type, attributes, ...children)
if (componentType(vnode.attributes.class) === 'array') {
vnode.attributes.class = classNames.apply(null, vnode.attributes.class)
}
if (componentType(vnode.attributes.class) === 'object') {
vnode.attributes.class = classNames(vnode.attributes.class)
}
if (componentType(vnode.attributes.style) === 'object') {
vnode.attributes.style = string(vnode.attributes.style)
}
if (!vnode.attributes.hidden) {
delete vnode.attributes.hidden
}
return vnode
}