Skip to content

bug: serializeShadowRoot: 'scoped' does not apply scoped classes to host element children #6219

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

Open
3 tasks done
Armand-Lluka opened this issue Apr 1, 2025 · 2 comments
Open
3 tasks done
Assignees
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted

Comments

@Armand-Lluka
Copy link

Armand-Lluka commented Apr 1, 2025

Prerequisites

Stencil Version

4.27.1

Current Behavior

When using renderToString to hydrate scoped web components, the "scoped" classes are not being applied correctly to the children of the host element.

Image

Expected Behavior

When using renderToString with serializeShadowRoot: 'scoped', the children of the host element should properly have the sc-web-component-name class applied and all the defined styles that come with it.

System Info

System: node 20.18.3
Platform: darwin (24.3.0)
CPU Model: Apple M1 Pro (8 cpus)
Compiler: stencil-bug-reproduction/node_modules/@stencil/core/compiler/stencil.js
Build: 1741890846
Stencil: 4.28.2 🎤
TypeScript: 5.5.4
Rollup: 4.34.9
Parse5: 7.2.1
jQuery: 4.0.0-pre
Terser: 5.37.0

Steps to Reproduce

Go to: https://github.com/Armand-Lluka/stencil-bug-reproductions/tree/scoped-styling-bug-demo

  1. npm i
  2. npm run build
  3. npm run serve to spin up server
  4. Visit http://localhost:8090/
  5. Disable JS on the client and notice that classes and styles are not being properly applied.
  6. If you add the class manually, sc-my-component, to the child of the host element, then the styles are again properly applied.
Image

Code Reproduction URL

https://github.com/Armand-Lluka/stencil-bug-reproductions

Additional Information

@Armand-Lluka
Copy link
Author

This was not fixed with #6224 I've updated Stencil to the latest version in the example to demonstrate this.

@christian-bromann
Copy link
Member

I've raised a PR with a fix at #6237

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted
Projects
None yet
Development

No branches or pull requests

3 participants