Skip to content

Commit 2f3966c

Browse files
authored
Fix icons flaky (#3012)
1 parent 8f65a22 commit 2f3966c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/gitbook/e2e/util.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,6 @@ async function waitForIcons(page: Page) {
330330
throw new Error('Icon is not an SVGElement');
331331
}
332332

333-
// If not visible, we don't care about loading state
334-
if (!icon.checkVisibility()) {
335-
return true;
336-
}
337-
338333
// If loaded, good it passes the test.
339334
if (icon.dataset.loadingState === 'loaded') {
340335
return true;
@@ -370,7 +365,12 @@ async function waitForIcons(page: Page) {
370365
const img = new Image();
371366
img.src = url;
372367
img.decode().then(() => {
373-
icon.dataset.loadingState = 'loaded';
368+
// Wait two frames to let the time to the icon to repaint.
369+
requestAnimationFrame(() => {
370+
requestAnimationFrame(() => {
371+
icon.dataset.loadingState = 'loaded';
372+
});
373+
});
374374
});
375375

376376
return false;

0 commit comments

Comments
 (0)