Watch DOM changes to add external link icons to new external links

This commit is contained in:
Alice Gaudon 2021-11-21 20:17:49 +01:00
parent 7f4996c908
commit 10d5d16967

View File

@ -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,
});
});
</script>