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

bug: ssr <slot />s can be incorrectly resolved during client-side hydration #6130

Closed
3 tasks done
johnjenkins opened this issue Jan 29, 2025 · 1 comment · Fixed by #6131
Closed
3 tasks done

bug: ssr <slot />s can be incorrectly resolved during client-side hydration #6130

johnjenkins opened this issue Jan 29, 2025 · 1 comment · Fixed by #6131
Labels

Comments

@johnjenkins
Copy link
Contributor

Prerequisites

Stencil Version

latest

Current Behavior

if sibling <slot /> elements change from server to client render, vdom resolution can fail.

example:

import { Build, Component, Host, h } from '@stencil/core';

@Component({
  tag: 'incorrect-slot-hydrate',
  shadow: true,
})
export class MyApp {
  render() {
    return (
      <Host>
        <div>
          <slot name="slot-1" />
          <slot />
          {Build.isBrowser && <slot name="client-side-slot" />}
        </div>
      </Host>
    );
  }
}

After client hydrate:

...
  <slot name="slot-1"></slot>
  <slot name="slot-1"></slot>
  <slot name="client-side-slot"></slot>
...

^ the default slot is replaced with an incorrect duplicate of the first slot

Expected Behavior

Slots from server render should be correctly resolved during client-side hydration. In this case, the default slot should not be removed.

System Info

Steps to Reproduce

https://stackblitz.com/edit/stencil-start-1wfms9fy?file=src%2Fcomponents%2Fincorrect-slot-hydrate.tsx

Click on 'incorrect-slot-hydrate'

There should be slotted text 'Default slot content' but the default slot has been removed / given a 'name' so the text does not render.

Code Reproduction URL

https://stackblitz.com/edit/stencil-start-1wfms9fy?file=src%2Fcomponents%2Fincorrect-slot-hydrate.tsx

Additional Information

Image

@christian-bromann
Copy link
Member

This has been released in @stencil/[email protected]

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

Successfully merging a pull request may close this issue.

2 participants