Skip to content

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

@techniq

Description

@techniq

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcompilerChanges relating to the compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions