Skip to content

Commit cac8630

Browse files
matubuRich-Harris
andauthored
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 <[email protected]>
1 parent 4bedd0e commit cac8630

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

.changeset/yellow-trees-juggle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
chore: use `new CustomEvent` instead of deprecated `initCustomEvent`

packages/svelte/src/internal/client/dom/elements/transitions.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,12 @@ import { TRANSITION_GLOBAL, TRANSITION_IN, TRANSITION_OUT } from '../../../../co
1010
import { BLOCK_EFFECT, EFFECT_RAN, EFFECT_TRANSPARENT } from '../../constants.js';
1111

1212
/**
13-
* @template T
14-
* @param {string} type
15-
* @param {T} [detail]
16-
* @param {any}params_0
17-
* @returns {Event}
18-
*/
19-
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
20-
const e = document.createEvent('CustomEvent');
21-
e.initCustomEvent(type, bubbles, cancelable, detail);
22-
return e;
23-
}
24-
25-
/**
26-
* @param {Element} dom
13+
* @param {Element} element
2714
* @param {'introstart' | 'introend' | 'outrostart' | 'outroend'} type
2815
* @returns {void}
2916
*/
30-
function dispatch_event(dom, type) {
31-
dom.dispatchEvent(custom_event(type));
17+
function dispatch_event(element, type) {
18+
element.dispatchEvent(new CustomEvent(type));
3219
}
3320

3421
/**

0 commit comments

Comments
 (0)