diff --git a/index.js b/index.js index aea7b28..54436a9 100644 --- a/index.js +++ b/index.js @@ -173,7 +173,7 @@ function addAttribute(props, name, value, ctx) { * `selector`. */ function react(h) { var node = h && h('div'); - return Boolean(node && node._store && node.key === null); + return Boolean(node && node._owner === null && node.key === null); } /* Check if `h` is `hyperscript`. It doesn’t accept diff --git a/test.js b/test.js index b1a5610..7401496 100644 --- a/test.js +++ b/test.js @@ -141,7 +141,46 @@ test('hast-to-hyperscript', function (t) { st.end(); }); - t.test('should support `React.createElement`', function (st) { + t.test('should support `React.createElement` in `development`', function (st) { + var currentEnv = process.env.NODE_ENV; + process.env.NODE_ENV = 'development'; + + var baseline = doc.replace(/ camel-case="on off"/, ''); + var actual = toH(r, hast); + var expected = r( + 'h1', + { + key: 'h-1', + id: 'a', + className: 'b c', + hidden: true, + height: '2' + }, + 'bravo ', + r('strong', { + key: 'h-2', + style: {color: 'red'}, + 'aria-valuenow': '1', + 'data-some': 'yes' + }, ['charlie']), + ' delta', + r('input', { + key: 'h-3', + type: 'file', + accept: '.jpg, .jpeg' + }) + ); + + st.deepEqual(html(rToString(actual)), html(baseline), 'equal output'); + st.deepEqual(html(rToString(expected)), html(baseline), 'equal output baseline'); + process.env.NODE_ENV = currentEnv; + st.end(); + }); + + t.test('should support `React.createElement` in `production`', function (st) { + var currentEnv = process.env.NODE_ENV; + process.env.NODE_ENV = 'production'; + var baseline = doc.replace(/ camel-case="on off"/, ''); var actual = toH(r, hast); var expected = r( @@ -170,6 +209,7 @@ test('hast-to-hyperscript', function (t) { st.deepEqual(html(rToString(actual)), html(baseline), 'equal output'); st.deepEqual(html(rToString(expected)), html(baseline), 'equal output baseline'); + process.env.NODE_ENV = currentEnv; st.end(); });