You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When i use <svelte:window onload={onLoad}> it does not work in chrome (And also not in svelte.dev environments), but it does work in Firefox.
After talking with chatgpt the fix was:
onMount(() => {
if (document.readyState === 'complete') {
onLoad();
} else {
// Otherwise, wait for the load event
window.addEventListener('load', onLoad, { once: true });
}
});
function onLoad(_event) {
console.debug('loaded window.');
isAppLoaded = true;
}
According to chatgpt onload event my fire before the sveltecode which attaches the eventhandler executes.
I am not a big expert in WebDev, but if I understand this correctly, it is not only a svelt issue. It would be nice if the had already the fix above implmeneted, if that is even the correct way to handle that.
Currently, it is successfully reproduces in the online environemnt of svelte.dev, but due to the nature of the issue (race condition), there might be a chance it won't reproduce.
Describe the bug
When i use
<svelte:window onload={onLoad}>
it does not work in chrome (And also not in svelte.dev environments), but it does work in Firefox.After talking with chatgpt the fix was:
According to chatgpt onload event my fire before the sveltecode which attaches the eventhandler executes.
I am not a big expert in WebDev, but if I understand this correctly, it is not only a svelt issue. It would be nice if the had already the fix above implmeneted, if that is even the correct way to handle that.
Reproduction
https://svelte.dev/playground/0f493cd43f36479fb6c907fa08d16ed3?version=5.16.0
Currently, it is successfully reproduces in the online environemnt of svelte.dev, but due to the nature of the issue (race condition), there might be a chance it won't reproduce.
Logs
No response
System Info
Independant Scripts: Chromium (131.0.2903.99) Internet Explorer: 11.0.26100.1882 npmPackages: svelte: ^5.0.0 => 5.16.0
Severity
annoyance
The text was updated successfully, but these errors were encountered: