@@ -14,6 +14,9 @@ module.exports = wrapper;
14
14
15
15
/* Wrapper around `toH`. */
16
16
function wrapper ( h , node , prefix ) {
17
+ var r ;
18
+ var v ;
19
+
17
20
if ( typeof h !== 'function' ) {
18
21
throw new Error ( 'h is not a function' ) ;
19
22
}
@@ -22,15 +25,18 @@ function wrapper(h, node, prefix) {
22
25
throw new Error ( 'Expected element, not `' + node + '`' ) ;
23
26
}
24
27
28
+ r = react ( h ) ;
29
+ v = vdom ( h ) ;
30
+
25
31
if ( prefix === null || prefix === undefined ) {
26
- prefix = react ( h ) || vdom ( h ) ? 'h-' : false ;
32
+ prefix = r === true || v === true ? 'h-' : false ;
27
33
}
28
34
29
35
return toH ( h , node , {
30
36
prefix : prefix ,
31
37
key : 0 ,
32
- react : react ( h ) ,
33
- vdom : vdom ( h ) ,
38
+ react : r ,
39
+ vdom : v ,
34
40
hyperscript : hyperscript ( h )
35
41
} ) ;
36
42
}
@@ -55,16 +61,16 @@ function toH(h, node, ctx) {
55
61
addAttribute ( attributes , property , properties [ property ] , ctx ) ;
56
62
}
57
63
58
- if ( ctx . vdom ) {
64
+ if ( ctx . vdom === true ) {
59
65
selector = selector . toUpperCase ( ) ;
60
66
}
61
67
62
- if ( ctx . hyperscript && attributes . id ) {
68
+ if ( ctx . hyperscript === true && attributes . id ) {
63
69
selector += '#' + attributes . id ;
64
70
delete attributes . id ;
65
71
}
66
72
67
- if ( ( ctx . hyperscript || ctx . vdom ) && attributes . className ) {
73
+ if ( ( ctx . hyperscript === true || ctx . vdom === true ) && attributes . className ) {
68
74
selector += '.' + spaces . parse ( attributes . className ) . join ( '.' ) ;
69
75
delete attributes . className ;
70
76
}
@@ -73,15 +79,15 @@ function toH(h, node, ctx) {
73
79
/* VDOM expects a `string` style in `attributes`
74
80
* See https://github.com/Matt-Esch/virtual-dom/blob/947ecf9/
75
81
* docs/vnode.md#propertiesstyle-vs-propertiesattributesstyle */
76
- if ( ctx . vdom ) {
82
+ if ( ctx . vdom === true ) {
77
83
if ( ! attributes . attributes ) {
78
84
attributes . attributes = { } ;
79
85
}
80
86
81
87
attributes . attributes . style = attributes . style ;
82
88
delete attributes . style ;
83
89
/* React only accepts `style` as object. */
84
- } else if ( ctx . react ) {
90
+ } else if ( ctx . react === true ) {
85
91
attributes . style = parseStyle ( attributes . style ) ;
86
92
}
87
93
}
@@ -140,14 +146,14 @@ function addAttribute(props, name, value, ctx) {
140
146
}
141
147
142
148
/* Treat `true` and truthy known booleans. */
143
- if ( info . boolean && ctx . hyperscript ) {
149
+ if ( info . boolean && ctx . hyperscript === true ) {
144
150
value = '' ;
145
151
}
146
152
147
153
if ( info . name !== 'class' && ( info . mustUseAttribute || ! info . name ) ) {
148
- if ( ctx . vdom ) {
154
+ if ( ctx . vdom === true ) {
149
155
subprop = 'attributes' ;
150
- } else if ( ctx . hyperscript ) {
156
+ } else if ( ctx . hyperscript === true ) {
151
157
subprop = 'attrs' ;
152
158
}
153
159
@@ -170,14 +176,14 @@ function addAttribute(props, name, value, ctx) {
170
176
* `selector`. */
171
177
function react ( h ) {
172
178
var node = h && h ( 'div' ) ;
173
- return node && node . _store && node . key === null ;
179
+ return Boolean ( node && node . _store && node . key === null ) ;
174
180
}
175
181
176
182
/* Check if `h` is `hyperscript`. It doesn’t accept
177
183
* `class` as an attribute, it must be added through the
178
184
* `selector`. */
179
185
function hyperscript ( h ) {
180
- return h && h . context && h . cleanup ;
186
+ return Boolean ( h && h . context && h . cleanup ) ;
181
187
}
182
188
183
189
/**
0 commit comments