Add to anchor rel attributes do not overwrite

This commit is contained in:
Gabe Kangas 2022-10-28 20:15:49 -07:00
parent d91f682d21
commit 64a2fbd3e8
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA

View File

@ -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