Skip to content

Commit

Permalink
correctly unmount vnodes (#242)
Browse files Browse the repository at this point in the history
* correctly unmount vnodes

* options.unmount after diffed

* remove change as we are merging to a tagged branch

* Create breezy-avocados-call.md

* Update index.js
  • Loading branch information
JoviDeCroock authored Sep 10, 2022
1 parent dec7a7a commit bd5e5eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-avocados-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"preact-render-to-string": patch
---

correctly unmount vnodes
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function renderToString(vnode, context, opts) {
if (options[COMMIT]) options[COMMIT](vnode, EMPTY_ARR);
options[SKIP_EFFECTS] = previousSkipEffects;
EMPTY_ARR.length = 0;

return res;
}

Expand Down Expand Up @@ -242,8 +243,12 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
selectValue,
vnode
);

if (options[DIFFED]) options[DIFFED](vnode);
vnode[PARENT] = undefined;

if (options.unmount) options.unmount(vnode);

return str;
}

Expand Down Expand Up @@ -366,6 +371,7 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {

if (options[DIFFED]) options[DIFFED](vnode);
vnode[PARENT] = undefined;
if (options.unmount) options.unmount(vnode);

if (hasChildren) {
s = s + pieces;
Expand Down

0 comments on commit bd5e5eb

Please sign in to comment.