Skip to content

Commit 47e2c92

Browse files
[website] Fix error regression homepage
1 parent 3641a0b commit 47e2c92

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/src/modules/utils/useLazyCSS.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@ export default function useLazyCSS(href: string, before: string, options: { laye
2121

2222
// With layer option, we need to fetch the CSS content and wrap it
2323
let styleElement: HTMLStyleElement | null = null;
24-
const abortController = new AbortController();
24+
let cancelled = false;
2525

2626
// Fetch the CSS content directly to avoid CORS issues with cssRules
27-
fetch(href, { signal: abortController.signal })
27+
fetch(href)
2828
.then((response) => {
2929
if (!response.ok) {
3030
throw new Error(`Failed to fetch CSS: ${response.statusText}`);
3131
}
3232
return response.text();
3333
})
3434
.then((cssText) => {
35+
if (cancelled) {
36+
return;
37+
}
38+
3539
// Create a style element with the CSS wrapped in the specified layer
3640
styleElement = document.createElement('style');
3741
styleElement.setAttribute('data-href', href);
@@ -60,7 +64,7 @@ export default function useLazyCSS(href: string, before: string, options: { laye
6064
// Cleanup function
6165
return () => {
6266
// Cancel any pending fetch
63-
abortController.abort();
67+
cancelled = true;
6468

6569
// Remove the style element if it was created
6670
if (styleElement && styleElement.parentElement) {

0 commit comments

Comments
 (0)