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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user