From dd14cd5ca58b33e6c6fdf748313a783a8d867d0d Mon Sep 17 00:00:00 2001 From: Cina Saffary Date: Mon, 15 Jul 2024 12:39:22 -0500 Subject: [PATCH] fix: append pending inline text at resolution time rather than immediately during close if blocked This fixes an issue where an inline host node would remain empty if it was the last node in the tree and a blocking node was encountered. --- src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 097125a..1fca76e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -74,11 +74,13 @@ export = function writableDOM( } }, close() { - appendInlineTextIfNeeded(pendingText, inlineHostNode); - - return isBlocked + const promise = isBlocked ? new Promise((_) => (resolve = _)) : Promise.resolve(); + + return promise.then(() => { + appendInlineTextIfNeeded(pendingText, inlineHostNode); + }); }, };