Skip to content

Svelte 5 migration: event modifier transformer doesn't respect indentation #12170

Closed
@Rich-Harris

Description

@Rich-Harris

Describe the bug

This...

<script>
  let count = 0;
</script>

<div>
  <div>
    <div>
      <div>
        <button on:click|preventDefault={() => count += 1}>
          clicks: {count}
        </button>
      </div>
    </div>
  </div>
</div>

...becomes this:

<script>
  let count = $state(0);
</script>

<div>
  <div>
    <div>
      <div>
        <button onclick={(event) => {
  event.preventDefault();
  count += 1
}}>
          clicks: {count}
        </button>
      </div>
    </div>
  </div>
</div>

Reproduction

demo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions