Skip to content

Commit bd5e5eb

Browse files
authored
correctly unmount vnodes (#242)
* 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
1 parent dec7a7a commit bd5e5eb

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.changeset/breezy-avocados-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"preact-render-to-string": patch
3+
---
4+
5+
correctly unmount vnodes

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ function renderToString(vnode, context, opts) {
8585
if (options[COMMIT]) options[COMMIT](vnode, EMPTY_ARR);
8686
options[SKIP_EFFECTS] = previousSkipEffects;
8787
EMPTY_ARR.length = 0;
88+
8889
return res;
8990
}
9091

@@ -242,8 +243,12 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
242243
selectValue,
243244
vnode
244245
);
246+
245247
if (options[DIFFED]) options[DIFFED](vnode);
246248
vnode[PARENT] = undefined;
249+
250+
if (options.unmount) options.unmount(vnode);
251+
247252
return str;
248253
}
249254

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

367372
if (options[DIFFED]) options[DIFFED](vnode);
368373
vnode[PARENT] = undefined;
374+
if (options.unmount) options.unmount(vnode);
369375

370376
if (hasChildren) {
371377
s = s + pieces;

0 commit comments

Comments
 (0)