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

Svelte 5: bind:this no longer allows dynamic type on <input> #9709

Closed
techniq opened this issue Nov 29, 2023 · 0 comments · Fixed by #9713
Closed

Svelte 5: bind:this no longer allows dynamic type on <input> #9709

techniq opened this issue Nov 29, 2023 · 0 comments · Fixed by #9713
Labels
bug compiler Changes relating to the compiler
Milestone

Comments

@techniq
Copy link

techniq commented Nov 29, 2023

Describe the bug

In Svelte 4, you could use bind:this with a dynamic type..

<script>
  let type = 'text';
  let el;
</script>

<input {type} bind:this={el} />

but in Svelte 5 (runes or non-runes mode), this throws a compiler error: 'type' attribute must be a static text value if input uses two-way binding

image

This was explicitly checked and allowed in Svelte 4, so likely a regression.

Reproduction

Logs

index-a870eda6.js:83 CompileError: 'type' attribute must be a static text value if input uses two-way binding
    at sr (compiler.cjs@5.0.0-next.15:1:226153)
    at BindDirective (compiler.cjs@5.0.0-next.15:1:502150)
    at r (compiler.cjs@5.0.0-next.15:1:305770)
    at o (compiler.cjs@5.0.0-next.15:1:305833)
    at r (compiler.cjs@5.0.0-next.15:1:305770)
    at o (compiler.cjs@5.0.0-next.15:1:305833)
    at Object.next (compiler.cjs@5.0.0-next.15:1:112832)
    at r (compiler.cjs@5.0.0-next.15:1:305753)
    at next (compiler.cjs@5.0.0-next.15:1:305809)
    at _ (compiler.cjs@5.0.0-next.15:1:305020)


### System Info

```shell
svelte: `5.0.0-next.15`

Severity

blocking an upgrade

@techniq techniq changed the title Svelte 5: bind:this no longer allowed dynamic type Svelte 5: bind:this no longer allows dynamic type on <input> Nov 29, 2023
@Conduitry Conduitry added bug compiler Changes relating to the compiler labels Nov 29, 2023
@dummdidumm dummdidumm added this to the 5.0 milestone Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug compiler Changes relating to the compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants