Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update links in head and *isLoaded to true #534

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/react/hooks/paragon/useParagonThemeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
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"]`;
Expand Down Expand Up @@ -126,6 +127,15 @@
} else {
setIsBrandThemeCoreLoaded(true);
}
} else {
existingCoreThemeLink.rel = 'stylesheet';
existingCoreThemeLink.removeAttribute('as');

Check warning on line 132 in src/react/hooks/paragon/useParagonThemeCore.js

View check run for this annotation

Codecov / codecov/patch

src/react/hooks/paragon/useParagonThemeCore.js#L130-L132

Added lines #L130 - L132 were not covered by tests
if (brandCoreLink) {
brandCoreLink.rel = 'stylesheet';
brandCoreLink.removeAttribute('as');

Check warning on line 135 in src/react/hooks/paragon/useParagonThemeCore.js

View check run for this annotation

Codecov / codecov/patch

src/react/hooks/paragon/useParagonThemeCore.js#L134-L135

Added lines #L134 - L135 were not covered by tests
}
setIsParagonThemeCoreLoaded(true);
setIsBrandThemeCoreLoaded(true);

Check warning on line 138 in src/react/hooks/paragon/useParagonThemeCore.js

View check run for this annotation

Codecov / codecov/patch

src/react/hooks/paragon/useParagonThemeCore.js#L137-L138

Added lines #L137 - L138 were not covered by tests
}
}, [themeCore?.urls, onLoad]);
};
Expand Down
8 changes: 7 additions & 1 deletion src/react/hooks/paragon/useParagonThemeVariants.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@
} else {
const updatedStylesheetRel = generateStylesheetRelAttr(themeVariant);
existingThemeVariantLink.rel = updatedStylesheetRel;
existingThemeVariantBrandLink.rel = updatedStylesheetRel;
existingThemeVariantLink.removeAttribute('as');

Check warning on line 190 in src/react/hooks/paragon/useParagonThemeVariants.js

View check run for this annotation

Codecov / codecov/patch

src/react/hooks/paragon/useParagonThemeVariants.js#L190

Added line #L190 was not covered by tests
if (existingThemeVariantBrandLink) {
existingThemeVariantBrandLink.rel = updatedStylesheetRel;
existingThemeVariantBrandLink.removeAttribute('as');

Check warning on line 193 in src/react/hooks/paragon/useParagonThemeVariants.js

View check run for this annotation

Codecov / codecov/patch

src/react/hooks/paragon/useParagonThemeVariants.js#L192-L193

Added lines #L192 - L193 were not covered by tests
}
setIsParagonThemeVariantLoaded(true);
setIsBrandThemeVariantLoaded(true);

Check warning on line 196 in src/react/hooks/paragon/useParagonThemeVariants.js

View check run for this annotation

Codecov / codecov/patch

src/react/hooks/paragon/useParagonThemeVariants.js#L195-L196

Added lines #L195 - L196 were not covered by tests
}
});
}, [themeVariants, currentThemeVariant, onLoad]);
Expand Down