@@ -14,6 +14,9 @@ module.exports = wrapper;
1414
1515/* Wrapper around `toH`. */
1616function wrapper ( h , node , prefix ) {
17+ var r ;
18+ var v ;
19+
1720 if ( typeof h !== 'function' ) {
1821 throw new Error ( 'h is not a function' ) ;
1922 }
@@ -22,15 +25,18 @@ function wrapper(h, node, prefix) {
2225 throw new Error ( 'Expected element, not `' + node + '`' ) ;
2326 }
2427
28+ r = react ( h ) ;
29+ v = vdom ( h ) ;
30+
2531 if ( prefix === null || prefix === undefined ) {
26- prefix = react ( h ) || vdom ( h ) ? 'h-' : false ;
32+ prefix = r === true || v === true ? 'h-' : false ;
2733 }
2834
2935 return toH ( h , node , {
3036 prefix : prefix ,
3137 key : 0 ,
32- react : react ( h ) ,
33- vdom : vdom ( h ) ,
38+ react : r ,
39+ vdom : v ,
3440 hyperscript : hyperscript ( h )
3541 } ) ;
3642}
@@ -55,16 +61,16 @@ function toH(h, node, ctx) {
5561 addAttribute ( attributes , property , properties [ property ] , ctx ) ;
5662 }
5763
58- if ( ctx . vdom ) {
64+ if ( ctx . vdom === true ) {
5965 selector = selector . toUpperCase ( ) ;
6066 }
6167
62- if ( ctx . hyperscript && attributes . id ) {
68+ if ( ctx . hyperscript === true && attributes . id ) {
6369 selector += '#' + attributes . id ;
6470 delete attributes . id ;
6571 }
6672
67- if ( ( ctx . hyperscript || ctx . vdom ) && attributes . className ) {
73+ if ( ( ctx . hyperscript === true || ctx . vdom === true ) && attributes . className ) {
6874 selector += '.' + spaces . parse ( attributes . className ) . join ( '.' ) ;
6975 delete attributes . className ;
7076 }
@@ -73,15 +79,15 @@ function toH(h, node, ctx) {
7379 /* VDOM expects a `string` style in `attributes`
7480 * See https://github.com/Matt-Esch/virtual-dom/blob/947ecf9/
7581 * docs/vnode.md#propertiesstyle-vs-propertiesattributesstyle */
76- if ( ctx . vdom ) {
82+ if ( ctx . vdom === true ) {
7783 if ( ! attributes . attributes ) {
7884 attributes . attributes = { } ;
7985 }
8086
8187 attributes . attributes . style = attributes . style ;
8288 delete attributes . style ;
8389 /* React only accepts `style` as object. */
84- } else if ( ctx . react ) {
90+ } else if ( ctx . react === true ) {
8591 attributes . style = parseStyle ( attributes . style ) ;
8692 }
8793 }
@@ -140,14 +146,14 @@ function addAttribute(props, name, value, ctx) {
140146 }
141147
142148 /* Treat `true` and truthy known booleans. */
143- if ( info . boolean && ctx . hyperscript ) {
149+ if ( info . boolean && ctx . hyperscript === true ) {
144150 value = '' ;
145151 }
146152
147153 if ( info . name !== 'class' && ( info . mustUseAttribute || ! info . name ) ) {
148- if ( ctx . vdom ) {
154+ if ( ctx . vdom === true ) {
149155 subprop = 'attributes' ;
150- } else if ( ctx . hyperscript ) {
156+ } else if ( ctx . hyperscript === true ) {
151157 subprop = 'attrs' ;
152158 }
153159
@@ -170,14 +176,14 @@ function addAttribute(props, name, value, ctx) {
170176 * `selector`. */
171177function react ( h ) {
172178 var node = h && h ( 'div' ) ;
173- return node && node . _store && node . key === null ;
179+ return Boolean ( node && node . _store && node . key === null ) ;
174180}
175181
176182/* Check if `h` is `hyperscript`. It doesn’t accept
177183 * `class` as an attribute, it must be added through the
178184 * `selector`. */
179185function hyperscript ( h ) {
180- return h && h . context && h . cleanup ;
186+ return Boolean ( h && h . context && h . cleanup ) ;
181187}
182188
183189/**
0 commit comments