Skip to content

Commit 4d0bd29

Browse files
committed
Clear placeholder content when comments iframe loads
Remove non-iframe child nodes from the root element once the iframe signals it has initialised, allowing users to add loading placeholders that get cleaned up automatically. Fixes #1990
1 parent b7a13a6 commit 4d0bd29

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

frontend/apps/remark42/app/embed.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ function createInstance(config: typeof window.remark_config) {
7979
}
8080

8181
if (data.inited === true) {
82+
// remove placeholder content added by the user before comments loaded
83+
Array.from(root!.childNodes)
84+
.filter((node) => node !== iframe)
85+
.forEach((node) => node.remove());
86+
8287
postHashToIframe();
8388
postTitleToIframe(document.title);
8489
}

0 commit comments

Comments
 (0)