Skip to content

Commit 2c69cc0

Browse files
authored
Merge pull request #257 from mariusGundersen/no-flash-replace
Replace the <link> without flashing the css
2 parents 919b7c4 + 7db4ac9 commit 2c69cc0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/transform.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ export async function transformCSS(
2525
const promise = new Promise((res) => {
2626
link.onload = res;
2727
});
28-
el.replaceWith(link);
28+
el.insertAdjacentElement('beforebegin', link);
2929
// Wait for new stylesheet to be loaded
3030
await promise;
31+
el.remove();
3132
URL.revokeObjectURL(url);
3233
updatedObject.el = link;
3334
} else if (el.hasAttribute('data-has-inline-styles')) {

0 commit comments

Comments
 (0)