diff --git a/src/react/hooks/paragon/useParagonThemeCore.js b/src/react/hooks/paragon/useParagonThemeCore.js index f1090d52e..d3b5983bb 100644 --- a/src/react/hooks/paragon/useParagonThemeCore.js +++ b/src/react/hooks/paragon/useParagonThemeCore.js @@ -34,8 +34,9 @@ const useParagonThemeCore = ({ setIsBrandThemeCoreLoaded(true); return; } - const getParagonThemeCoreLink = () => document.head.querySelector('link[data-paragon-theme-core="true"'); + const getParagonThemeCoreLink = () => document.head.querySelector('link[data-paragon-theme-core="true"]'); const existingCoreThemeLink = document.head.querySelector(`link[href='${themeCore.urls.default}']`); + const brandCoreLink = document.head.querySelector(`link[href='${themeCore.urls.brandOverride}']`); if (!existingCoreThemeLink) { const getExistingCoreThemeLinks = (isBrandOverride) => { const coreThemeLinkSelector = `link[data-${isBrandOverride ? 'brand' : 'paragon'}-theme-core="true"]`; @@ -126,6 +127,15 @@ const useParagonThemeCore = ({ } else { setIsBrandThemeCoreLoaded(true); } + } else { + existingCoreThemeLink.rel = 'stylesheet'; + existingCoreThemeLink.removeAttribute('as'); + if (brandCoreLink) { + brandCoreLink.rel = 'stylesheet'; + brandCoreLink.removeAttribute('as'); + } + setIsParagonThemeCoreLoaded(true); + setIsBrandThemeCoreLoaded(true); } }, [themeCore?.urls, onLoad]); }; diff --git a/src/react/hooks/paragon/useParagonThemeVariants.js b/src/react/hooks/paragon/useParagonThemeVariants.js index efb8ef4c5..737129ef9 100644 --- a/src/react/hooks/paragon/useParagonThemeVariants.js +++ b/src/react/hooks/paragon/useParagonThemeVariants.js @@ -187,7 +187,13 @@ const useParagonThemeVariants = ({ } else { const updatedStylesheetRel = generateStylesheetRelAttr(themeVariant); existingThemeVariantLink.rel = updatedStylesheetRel; - existingThemeVariantBrandLink.rel = updatedStylesheetRel; + existingThemeVariantLink.removeAttribute('as'); + if (existingThemeVariantBrandLink) { + existingThemeVariantBrandLink.rel = updatedStylesheetRel; + existingThemeVariantBrandLink.removeAttribute('as'); + } + setIsParagonThemeVariantLoaded(true); + setIsBrandThemeVariantLoaded(true); } }); }, [themeVariants, currentThemeVariant, onLoad]);