From d165c77d9363f724e51f86cd9ca5ec43ed0a28e7 Mon Sep 17 00:00:00 2001 From: Gabe Lyons Date: Tue, 13 Sep 2022 14:49:00 -0700 Subject: [PATCH] update multiple favicons --- datahub-web-react/src/AppConfigProvider.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/datahub-web-react/src/AppConfigProvider.tsx b/datahub-web-react/src/AppConfigProvider.tsx index ef1246b9f988e4..9a03b38584b79d 100644 --- a/datahub-web-react/src/AppConfigProvider.tsx +++ b/datahub-web-react/src/AppConfigProvider.tsx @@ -6,13 +6,16 @@ import { AppConfigContext, DEFAULT_APP_CONFIG } from './appConfigContext'; import { useAppConfigQuery } from './graphql/app.generated'; function changeFavicon(src) { - let link = document.querySelector("link[rel~='icon']") as any; - if (!link) { - link = document.createElement('link'); + const links = document.querySelectorAll("link[rel~='icon']") as any; + if (!links || links.length === 0) { + const link = document.createElement('link'); link.rel = 'icon'; document.getElementsByTagName('head')[0].appendChild(link); } - link.href = src; + links.forEach((link) => { + // eslint-disable-next-line no-param-reassign + link.href = src; + }); } const AppConfigProvider = ({ children }: { children: React.ReactNode }) => {