From cac8630de667fe5271395041c5b17e2d73cdfd63 Mon Sep 17 00:00:00 2001 From: Mathias Date: Wed, 15 May 2024 18:34:56 +0200 Subject: [PATCH] chore: use CustomEvent constructor instead of deprecated createEvent method (#11629) * chore: use CustomEvent constructor instead of deprecated createEvent method * while we're here... * changeset --------- Co-authored-by: Rich Harris --- .changeset/yellow-trees-juggle.md | 5 +++++ .../client/dom/elements/transitions.js | 19 +++---------------- 2 files changed, 8 insertions(+), 16 deletions(-) create mode 100644 .changeset/yellow-trees-juggle.md diff --git a/.changeset/yellow-trees-juggle.md b/.changeset/yellow-trees-juggle.md new file mode 100644 index 0000000000..64642597e2 --- /dev/null +++ b/.changeset/yellow-trees-juggle.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: use `new CustomEvent` instead of deprecated `initCustomEvent` diff --git a/packages/svelte/src/internal/client/dom/elements/transitions.js b/packages/svelte/src/internal/client/dom/elements/transitions.js index 3551a093da..cff1cce746 100644 --- a/packages/svelte/src/internal/client/dom/elements/transitions.js +++ b/packages/svelte/src/internal/client/dom/elements/transitions.js @@ -10,25 +10,12 @@ import { TRANSITION_GLOBAL, TRANSITION_IN, TRANSITION_OUT } from '../../../../co import { BLOCK_EFFECT, EFFECT_RAN, EFFECT_TRANSPARENT } from '../../constants.js'; /** - * @template T - * @param {string} type - * @param {T} [detail] - * @param {any}params_0 - * @returns {Event} - */ -function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) { - const e = document.createEvent('CustomEvent'); - e.initCustomEvent(type, bubbles, cancelable, detail); - return e; -} - -/** - * @param {Element} dom + * @param {Element} element * @param {'introstart' | 'introend' | 'outrostart' | 'outroend'} type * @returns {void} */ -function dispatch_event(dom, type) { - dom.dispatchEvent(custom_event(type)); +function dispatch_event(element, type) { + element.dispatchEvent(new CustomEvent(type)); } /**