-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathvhtml.js
47 lines (36 loc) · 980 Bytes
/
vhtml.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict'
var VNode = require('virtual-dom/vnode/vnode.js')
var isHook = require('virtual-dom/vnode/is-vhook')
var xml = require('./xml')
var softSetHook = require('virtual-dom/virtual-hyperscript/hooks/soft-set-hook.js')
module.exports = h
function h (tagName, props, children) {
var tag = tagName
// support keys
if (props.hasOwnProperty('key')) {
var key = props.key
props.key = undefined
}
if (props.innerHTML === false) {
props.innerHTML = ''
}
// support namespace
if (props.hasOwnProperty('namespace')) {
var namespace = props.namespace
props.namespace = undefined
}
// fix cursor bug
if (tag.toLowerCase() === 'input' &&
!namespace &&
props.hasOwnProperty('value') &&
props.value !== undefined &&
!isHook(props.value)
) {
props.value = softSetHook(props.value)
}
var vnode = new VNode(tag, props, children, key, namespace)
if (props.xmlns) {
xml.transform(vnode)
}
return vnode
}