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
This commit is contained in:
Dmitry Verkhoturov
2026-02-10 23:52:22 +00:00
parent b7a13a6636
commit 4d0bd29b45
+5
View File
@@ -79,6 +79,11 @@ function createInstance(config: typeof window.remark_config) {
}
if (data.inited === true) {
// remove placeholder content added by the user before comments loaded
Array.from(root!.childNodes)
.filter((node) => node !== iframe)
.forEach((node) => node.remove());
postHashToIframe();
postTitleToIframe(document.title);
}