diff --git a/src/index.js b/src/index.js index c518fce..51e4c24 100644 --- a/src/index.js +++ b/src/index.js @@ -209,6 +209,9 @@ function resolveNode(node, state, actions) { if (typeof node === 'function') { return resolveNode(node(state, actions), state, actions) } + if (node && node.type === 2) { + return resolveNode(node.lazy.view(node.lazy), state, actions) + } return node } diff --git a/test/index.test.js b/test/index.test.js index e6d858e..b481d81 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -471,6 +471,35 @@ describe('renderToString(view, state, actions)', () => { expect(html).toBe('
foo bar baz
') }) + it('should support Hyperapp V2 lazy nodes', () => { + const VNode = { + lazy: { + view: ({ name }) =>
{name}
, + name: 'foo', + }, + type: 2, + } + const html = renderToString(VNode) + expect(html).toBe('
foo
') + }) + + it('should support Hyperapp V2 nested lazy nodes', () => { + const VNode = { + lazy: { + view: () => ({ + lazy: { + view: ({ name }) =>
{name}
, + name: 'foo', + }, + type: 2, + }), + }, + type: 2, + } + const html = renderToString(VNode) + expect(html).toBe('
foo
') + }) + it('should render counter', () => { const testState = { count: 100 } const testActions = {