Skip to content

Use CustomEvent constructor instead of deprecated initCustomEvent() #7178

@angryziber

Description

@angryziber

Describe the bug

Compiled components use a deprecated initCustomEvent, which is not supported by e.g. happy-dom.

Instead of

function custom_event(type, detail, bubbles = false) {
    const e = document.createEvent('CustomEvent');
    e.initCustomEvent(type, bubbles, false, detail);
    return e;
}

it would be nice to use the CustomEvent constructor, which is supported in all modern browsers.
https://caniuse.com/?search=CustomEvent

Reproduction

Open svelte/internal/index.mjs

Logs

No response

System Info

Not relevant

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions