From 64a2fbd3e8a612b8b9a8557ad7880eec99fce570 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Fri, 28 Oct 2022 20:15:49 -0700 Subject: [PATCH] Add to anchor rel attributes do not overwrite --- web/utils/no-link-referrer.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/utils/no-link-referrer.ts b/web/utils/no-link-referrer.ts index 9f3308fb1..0d43ef9ce 100644 --- a/web/utils/no-link-referrer.ts +++ b/web/utils/no-link-referrer.ts @@ -15,7 +15,9 @@ export default function setupNoLinkReferrer(observationRoot: HTMLElement): void const config = { attributes: false, childList: true, subtree: true }; const addNoReferrer = (node: Element): void => { - node.setAttribute('rel', 'noopener noreferrer '); + const existingAttributes = node.getAttribute('rel'); + const attributes = `${existingAttributes} noopener noreferrer`; + node.setAttribute('rel', attributes); }; // Callback function to execute when mutations are observed