diff --git a/src/index.js b/src/index.js index d911576..015c99b 100644 --- a/src/index.js +++ b/src/index.js @@ -23,8 +23,11 @@ import { } from './lib/constants.js'; const EMPTY_ARR = []; +const EMPTY_OBJ = {}; const isArray = Array.isArray; const assign = Object.assign; +const BEGIN_SUSPENSE_DENOMINATOR = ''; +const END_SUSPENSE_DENOMINATOR = ''; // Global state for the current render pass let beforeDiff, afterDiff, renderHook, ummountHook; @@ -149,10 +152,6 @@ function markAsDirty() { this.__d = true; } -const EMPTY_OBJ = {}; -const BEGIN_SUSPENSE_DENOMINATOR = ''; -const END_SUSPENSE_DENOMINATOR = ''; - /** * @param {VNode} vnode * @param {Record} context @@ -373,7 +372,10 @@ function _renderToString( try { rendered = type.call(component, props, cctx); } catch (e) { - if (asyncMode) vnode._suspended = true; + if (asyncMode) { + console.log('marking', vnode.type); + vnode._suspended = true; + } throw e; } } diff --git a/test/compat/async.test.jsx b/test/compat/async.test.jsx index 1063138..e686aa4 100644 --- a/test/compat/async.test.jsx +++ b/test/compat/async.test.jsx @@ -17,7 +17,7 @@ describe('Async renderToString', () => { ); - const expected = `
bar
`; + const expected = `
bar
`; suspended.resolve(); @@ -40,7 +40,7 @@ describe('Async renderToString', () => { ); - const expected = `
bar
`; + const expected = `
bar
`; suspended.resolve(); @@ -73,7 +73,7 @@ describe('Async renderToString', () => { ); - const expected = ``; + const expected = ``; suspendedOne.resolve(); suspendedTwo.resolve(); @@ -109,7 +109,7 @@ describe('Async renderToString', () => { ); - const expected = ``; + const expected = ``; suspendedOne.resolve(); suspendedTwo.resolve(); @@ -152,7 +152,7 @@ describe('Async renderToString', () => { ); - const expected = ``; + const expected = ``; suspendedOne.resolve(); suspendedTwo.resolve(); @@ -164,7 +164,7 @@ describe('Async renderToString', () => { expect(rendered).to.equal(expected); }); - it.only('should render JSX with deeply nested suspense boundaries', async () => { + it('should render JSX with deeply nested suspense boundaries', async () => { const { Suspender: SuspenderOne, suspended: suspendedOne @@ -199,7 +199,7 @@ describe('Async renderToString', () => { ); - const expected = ``; + const expected = ``; suspendedOne.resolve(); suspendedTwo.resolve(); @@ -243,7 +243,7 @@ describe('Async renderToString', () => { ); - const expected = ``; + const expected = ``; suspendedOne.resolve(); suspendedTwo.resolve(); @@ -303,10 +303,10 @@ describe('Async renderToString', () => { suspended.resolve(); const rendered = await promise; - expect(rendered).to.equal('

ok

'); + expect(rendered).to.equal('

ok

'); }); - it('should work with an in-render suspension', async () => { + it.only('should work with an in-render suspension', async () => { const Context = createContext(); let c = 0; @@ -340,6 +340,9 @@ describe('Async renderToString', () => { ); - expect(rendered).to.equal(`
2
`); + // Before we get to the actual DOM this suspends twice + expect(rendered).to.equal( + `
2
` + ); }); });