Skip to content

[Svelte 5] Events should be allowed to be camelCasedΒ #10044

@D-Marc1

Description

@D-Marc1

Describe the problem

While it's a welcomed addition that Svelte 5 is becoming more like vanilla JS, when it comes to events, like onclick={}, onsubmit={}, etc., it's weird why it doesn't allow for it to be camelCased, like so: onClick={} and onSubmit={}.

Even vanilla HTML/JS allows you to camelCase the event name, so it doesn't make sense why Svelte 5 is restricting it to only allowed nocase. Additionally, React is the opposite, where it only allows camelCase, as functions and variables are typically camelCased in JS. If camelCased events were allowed in Svelte 5, it would be easier to do the shorthand syntax of {onClick} (of course it normally should be more descriptive anyway).

Describe the proposed solution

I propose to allow both camelCase and nocase syntax for native events, much like how it already work.

So following would both work:

<button onClick={}>My button</button>
<button onclick={}>My button</button>

Alternatives considered

There's no alternative that I'm aware of.

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions