diff --git a/.changeset/friendly-numbers-hang.md b/.changeset/friendly-numbers-hang.md index 764bcd8..4e8fe4b 100644 --- a/.changeset/friendly-numbers-hang.md +++ b/.changeset/friendly-numbers-hang.md @@ -2,4 +2,5 @@ 'preact-render-to-string': patch --- -Fix issue where subtree re-render for Suspense boundaries caused a circular reference in the VNode's parent +Ensure that the `_parent` is kept around across multiple suspensions and avoid circular references. +In doing so our `useId` hook should always output unique ids during renderingToString. diff --git a/package-lock.json b/package-lock.json index e4d3c80..6e40cb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "preact-render-to-string", - "version": "6.5.11", + "version": "6.5.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "preact-render-to-string", - "version": "6.5.11", + "version": "6.5.12", "license": "MIT", "devDependencies": { "@babel/plugin-transform-react-jsx": "^7.12.12", @@ -14,7 +14,7 @@ "@babel/register": "^7.12.10", "@changesets/changelog-github": "^0.4.1", "@changesets/cli": "^2.18.0", - "baseline-rts": "npm:preact-render-to-string@6.5.11", + "baseline-rts": "npm:preact-render-to-string@latest", "benchmarkjs-pretty": "^2.0.1", "chai": "^4.2.0", "check-export-map": "^1.3.1", diff --git a/src/index.js b/src/index.js index 4c7fe19..ff4c774 100644 --- a/src/index.js +++ b/src/index.js @@ -443,7 +443,6 @@ function _renderToString( return EMPTY_STR; } finally { if (afterDiff) afterDiff(vnode); - vnode[PARENT] = null; if (ummountHook) ummountHook(vnode); } @@ -473,7 +472,6 @@ function _renderToString( if (afterDiff) afterDiff(vnode); // when we are dealing with suspense we can't do this... - vnode[PARENT] = null; if (options.unmount) options.unmount(vnode); @@ -688,9 +686,6 @@ function _renderToString( if (afterDiff) afterDiff(vnode); - // TODO: this was commented before - vnode[PARENT] = null; - if (ummountHook) ummountHook(vnode); // Emit self-closing tag for empty void elements: diff --git a/test/compat/render-chunked.test.js b/test/compat/render-chunked.test.js index 575e0f9..502507f 100644 --- a/test/compat/render-chunked.test.js +++ b/test/compat/render-chunked.test.js @@ -145,7 +145,48 @@ describe('renderToChunks', () => { '
id: P0-0
loading...id: P0-0
'), + createSubtree('24', 'id: P0-1
'), + 'id: {id}
; + } + + const result = []; + const promise = renderToChunks( +id: P0-0
loading...loading...id: P0-1
'), + createSubtree('36', 'id: P0-2
'), 'it works
'), + createSubtree('47', 'it works
'), 'it works
'), + createSubtree('54', 'it works
'), '