Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

replace onload with addEventListener in inject_styles #1790

Merged
merged 1 commit into from
Jul 20, 2021

Conversation

ankitstarski
Copy link
Contributor

When multiple dynamically imported components are loaded, only one of them resolves the promise. Upon further investigation, I found out that those components were loading .css files and inject_styles function was using onload in order to resolve inject_styles promise.

If two components use the same css file, the first onload will be overridden by the second one.

The solution is to replace onload with addEventListener("load", ....

@Rich-Harris pushed a fix for this in svelte kit (kit#347)

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not merging much into Sapper, but this one looks fine since it aligns the code with SvelteKit

@benmccann
Copy link
Member

Although that code change was from before SvelteKit switched to Vite. That code no longer exists in SvelteKit as Vite is now responsible for it. That being said I'll go ahead and merge this since it looks like Rich approves of the change

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants