Skip to content

bug: ssr. Incorrect slotted node order with serializeShadowRoot: 'scoped' #6293

Closed

Description

@johnjenkins

Prerequisites

Stencil Version

latest

Current Behavior

When slotted nodes are nested in 2 (or more) components deep and rendered via serializeShadowRoot: 'scoped' the original node order will be lost; instead taking the order of the <slot /> elements within the component.
Visually, this doesn't impact anything however it can cause hydration errors in meta frameworks (e.g. nuxt / next etc).

Given the following outer markup:

<cmp-parent>
  <cmp-child>
    <p slot="two">Slot 2</p> <!-- should be first in the final dom  --!>
    <p slot="one">Slot 1</p>  <!-- should be second in final dom  --!>
  </cmp-child>
</cmp-parent>

returns the following:

Image

pay special attention to

<!--o.0.5.-->
<!--o.0.7.-->
...
<p c-id="0.7" slot="one">Slot 1</p>
<p c-id="0.5" slot="two">Slot 2</p>

The comments match the slotted nodes and represent the original order of the nodes: 5 first, 7 second.

However the final result shows slot 'one' is first and 'two' second - not the order they were originally

Image

Expected Behavior

The original order should be preserved in the final hydrated DOM

System Info

Steps to Reproduce

pnpm i
pnpm build
pnpm express

Code Reproduction URL

https://github.com/johnjenkins/stencil-start-m6opf9rg

Additional Information

No response

Activity

  1. added
    Bug: Validated
    on Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedHelp Wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions