Skip to content

Svelte 5: $props destructing rename property incorrect #9883

@epfn

Description

@epfn

Describe the bug

When renaming prop with object destructing for example let {class: className} = $props() this <Component class='red' /> doesn't work but <Component className='red' /> works.

REPL

Reproduction

Component.svelte

<script>
	let {class: className} = $props()
</script>

<button class={className}>
	Button
</button>

<style>
	.red {
		background-color: red;
	}
</style>

Doesn't work

<Component class='red' />

Works

<Component className='red' />

Logs

No response

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (16) x64 AMD Ryzen 7 1700 Eight-Core Processor
    Memory: 23.53 GB / 31.94 GB
  Binaries:
    Node: 20.8.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.9.0 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Chromium (120.0.2210.61)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    svelte: 5.0.0-next.22 => 5.0.0-next.22

Severity

annoyance

Metadata

Metadata

Assignees

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