Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contents of div containing %sveltekit.body% no longer replaced in SvelteKit 2.5.5 #12097

Open
theodorejb opened this issue Apr 9, 2024 · 3 comments
Milestone

Comments

@theodorejb
Copy link

Describe the bug

I have an SPA mode app using adapter-static.

My app.html file contains the following inside the <body> tag:

<div style="display: contents">
    <div class="loading-animation">
        <div></div>
        <div></div>
    </div>
    %sveltekit.body%
</div>

Up to SvelteKit 2.5.4, the loading-animation div was removed from the DOM when the SvelteKit app finishes loading. However, this no longer works in SvelteKit 2.5.5, and the loading animation continues to display on top of the loaded app.

Reproduction

My top-level +layout.ts file contains:

export const ssr = false;
export const prerender = false;

Logs

No response

System Info

Windows 11, Firefox 124

Severity

blocking an upgrade

Additional Information

I suspect this issue may be caused by #12050.

@eltigerchino
Copy link
Member

I think this is the right behaviour since no SSR means no hydration, thus no repairing the DOM. It's easy enough to query the document for the loading element and remove it in an onMount callback.

cc: @Rich-Harris was disabling the hydration behaviour on SPA project considered a breaking change?

@theodorejb
Copy link
Author

Isn't the Svelte app hydrated to the DOM regardless of whether SSR is enabled? To me it's confusing that siblings of %sveltekit.body% wouldn't always be replaced when it's rendered, especially given that this has always worked before. If this difference is intended, it should at least be documented somewhere.

@eltigerchino
Copy link
Member

Isn't the Svelte app hydrated to the DOM regardless of whether SSR is enabled?

Hydration is only required when the page contents have already been rendered by SSR. If the HTML hasn't been rendered yet, it's just client-side rendering.

To me it's confusing that siblings of %sveltekit.body% wouldn't always be replaced when it's rendered, especially given that this has always worked before. If this difference is intended, it should at least be documented somewhere.

Yeah, this makes me think it might have been a breaking change and may be something we need to wait until the next major version for including documentation for it.

@eltigerchino eltigerchino added this to the soon milestone Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants