Skip to content

null and undefined events are handled differently #16704

@hyunbinseo

Description

@hyunbinseo

Describe the bug

All other attributes are included unless their value is nullish (null or undefined).

https://svelte.dev/docs/svelte/basic-markup#Element-attributes

Because events are just attributes, the same rules as for attributes apply:

https://svelte.dev/docs/svelte/basic-markup#Events

However, ondblclick={null} is treated differently in the JS output:

<button name={undefined} value={null} onclick={undefined} ondblclick={null}></button>
$.set_attribute(button, 'name', undefined);
$.set_value(button, null);
button.__click = undefined;

button.__dblclick = function (...$$args) {
  (null)?.apply(this, $$args);
};

Shouldn't this be button.__dblclick = null; instead?

Reproduction

https://svelte.dev/playground/d6dd8c1f6355475fbe357d501b60137a?version=5.38.6

Logs

System Info

-

Severity

annoyance

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