Skip to content

Commit

Permalink
chore: use CustomEvent constructor instead of deprecated createEvent …
Browse files Browse the repository at this point in the history
…method (#11629)

* chore: use CustomEvent constructor instead of deprecated createEvent method

* while we're here...

* changeset

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
  • Loading branch information
matubu and Rich-Harris committed May 15, 2024
1 parent 4bedd0e commit cac8630
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-trees-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

chore: use `new CustomEvent` instead of deprecated `initCustomEvent`
19 changes: 3 additions & 16 deletions packages/svelte/src/internal/client/dom/elements/transitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit cac8630

Please sign in to comment.