Skip to content

Commit 190a046

Browse files
committed
Fix loading
1 parent 5a43ece commit 190a046

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/gitbook/e2e/util.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,16 @@ async function waitForIcons(page: Page) {
371371
return true;
372372
}
373373

374+
const state = icon.getAttribute('data-argos-state');
375+
376+
if (state === 'pending') {
377+
return false;
378+
}
379+
380+
if (state === 'loaded') {
381+
return true;
382+
}
383+
374384
// url("https://ka-p.fontawesome.com/releases/v6.6.0/svgs/light/moon.svg?v=2&token=a463935e93")
375385
const maskImage = window.getComputedStyle(icon).getPropertyValue('mask-image');
376386
const urlMatch = maskImage.match(/url\("([^"]+)"\)/);
@@ -384,8 +394,14 @@ async function waitForIcons(page: Page) {
384394
// If the URL is already queued for loading, we return the state.
385395
if (urlStates[url]) {
386396
if (urlStates[url] === 'loaded') {
387-
icon.setAttribute('data-bust', String(Date.now()));
388-
return true;
397+
icon.setAttribute('data-argos-state', 'pending');
398+
const bck = icon.style.maskImage;
399+
icon.style.maskImage = '';
400+
requestAnimationFrame(() => {
401+
icon.style.maskImage = bck;
402+
icon.setAttribute('data-argos-state', 'loaded');
403+
});
404+
return false;
389405
}
390406

391407
return false;

0 commit comments

Comments
 (0)