Skip to content

Conversation

LeeWxx
Copy link
Contributor

@LeeWxx LeeWxx commented Sep 23, 2025

Fixes #16813

Server-rendered <select> elements stopped getting their scoped CSS because the special select branch skipped the hashing/directive merge. I pass the hash and directive data through to $$renderer.select, then let the existing attributes(...) helper merge them so the flow matches other elements. If there’s a better way to do this, I’m happy to adjust. Added a renderer unit test and an SSR sample to cover the regression.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Sep 23, 2025

🦋 Changeset detected

Latest commit: 449868d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@16821

@7nik
Copy link
Contributor

7nik commented Sep 23, 2025

Another bug from that PR is async attributes are awaited twice. I guess build_element_attributes on ~40 line should be called only if the element won't have special handling.

@LeeWxx
Copy link
Contributor Author

LeeWxx commented Sep 23, 2025

@7nik. Thanks for the review! I’ve applied all three points:

– Added prepare_element_spread to share object/css_hash/classes/styles/flags logic
– Simplified renderer.select to fixed args
– Skipped early build_element_attributes in special <select> branch

I’d value your thoughts. I’m happy to adjust if needed.

@LeeWxx LeeWxx force-pushed the fix/select-scoped-class-ssr branch from 2dd8e2c to b125ec0 Compare September 23, 2025 18:56
@LeeWxx
Copy link
Contributor Author

LeeWxx commented Sep 23, 2025

@7nik Thanks for pointing that out! I had overlooked <option>. I’ve added a guard and updated it so that both <select>and <option> now go through the shared prep and attributes.

Copy link
Contributor

@7nik 7nik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@svelte-docs-bot
Copy link

@Rich-Harris Rich-Harris merged commit ac7e160 into sveltejs:main Sep 24, 2025
13 of 14 checks passed
@github-actions github-actions bot mentioned this pull request Sep 24, 2025
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

Successfully merging this pull request may close these issues.

Regression: some elements don't get css scoped during SSR
3 participants