fix: visit synthetic value node during ssr (#17824)

Closes #17821

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

- [x] 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
- [x] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`.
- [x] This message body should clearly illustrate what problems it
solves.
- [x] Ideally, include a test that fails without this PR but passes with
it.
- [x] If this PR changes code within `packages/svelte/src`, add a
changeset (`npx changeset`).

### Tests and linting

- [x] Run the tests with `pnpm test` and lint the project with `pnpm
lint`
pull/17812/head
Paolo Ricciuti 7 months ago committed by GitHub
parent a10cf95ca7
commit e3d277b000
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: visit synthetic value node during ssr

@ -126,7 +126,7 @@ export function RegularElement(node, context) {
if (node.metadata.synthetic_value_node) {
body = optimiser.transform(
node.metadata.synthetic_value_node.expression,
/** @type {Expression} */ (context.visit(node.metadata.synthetic_value_node.expression)),
node.metadata.synthetic_value_node.metadata.expression
);
} else {

@ -0,0 +1 @@
<!--[--><select><option>Dog</option><option>cat</option></select><!--]-->

@ -0,0 +1,11 @@
<script>
import { writable } from 'svelte/store';
const value = writable('dog');
const label = writable('Dog');
</script>
<select bind:value={$value}>
<option>{$label}</option>
<option>cat</option>
</select>

@ -0,0 +1 @@
<!--[--><select><option disabled="" value="" selected="">placeholder</option><option value="a">A</option><option value="b">B</option></select><!--]-->

@ -0,0 +1,13 @@
<script>
import { readable } from 'svelte/store';
const t = readable((/** @type {string} */ key) => key);
let value = $state('');
</script>
<select bind:value>
<option disabled value="">{$t('placeholder')}</option>
<option value="a">A</option>
<option value="b">B</option>
</select>
Loading…
Cancel
Save