From 10d5d1696797889ebed6ec0a0281ab63fcee56ff Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sun, 21 Nov 2021 20:17:49 +0100 Subject: [PATCH] Watch DOM changes to add external link icons to new external links --- src/assets/views/scripts/ExternalLinkIcons.svelte | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/assets/views/scripts/ExternalLinkIcons.svelte b/src/assets/views/scripts/ExternalLinkIcons.svelte index 62f0a81..e21205e 100644 --- a/src/assets/views/scripts/ExternalLinkIcons.svelte +++ b/src/assets/views/scripts/ExternalLinkIcons.svelte @@ -11,6 +11,7 @@ document.querySelectorAll('a[target="_blank"]').forEach(el => { if (!el.classList.contains('no-icon')) { + el.classList.add('no-icon'); el.appendChild(iconElement.cloneNode(true)); } }); @@ -18,6 +19,13 @@ onMount(() => { addExternalLinkIcons(); + + new MutationObserver(() => { + addExternalLinkIcons(); + }).observe(document.body, { + childList: true, + subtree: true, + }); });