diff --git a/compat/test/browser/suspense.test.js b/compat/test/browser/suspense.test.js
index a7d3c8b7a5..5c7ad45294 100644
--- a/compat/test/browser/suspense.test.js
+++ b/compat/test/browser/suspense.test.js
@@ -299,6 +299,25 @@ describe('suspense', () => {
});
});
+ it('should not duplicate DOM when suspending while rendering', () => {
+ scratch.innerHTML = '
Hello
';
+
+ const [Lazy, resolve] = createLazy();
+ render(
+
+
+ ,
+ scratch
+ );
+ rerender(); // Flush rerender queue to mimic what preact will really do
+ expect(scratch.innerHTML).to.equal('');
+
+ return resolve(() => Hello
).then(() => {
+ rerender();
+ expect(scratch.innerHTML).to.equal('Hello
');
+ });
+ });
+
it('should suspend when a promise is thrown', () => {
class ClassWrapper extends Component {
render(props) {
diff --git a/src/diff/index.js b/src/diff/index.js
index 287f94344d..ae2d77ffc2 100644
--- a/src/diff/index.js
+++ b/src/diff/index.js
@@ -275,7 +275,7 @@ export function diff(
if (isHydrating || excessDomChildren != null) {
newVNode._flags |= isHydrating
? MODE_HYDRATE | MODE_SUSPENDED
- : MODE_HYDRATE;
+ : MODE_SUSPENDED;
while (oldDom && oldDom.nodeType === 8 && oldDom.nextSibling) {
oldDom = oldDom.nextSibling;