Skip to content

Commit 2dead17

Browse files
committed
breaking: use CustomEvent constructor instead of deprecated createEvent method
closes #8474
1 parent 963cbcd commit 2dead17

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.changeset/odd-wasps-smoke.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+
breaking: use `CustomEvent` constructor instead of deprecated `createEvent` method

documentation/docs/05-misc/04-v4-migration-guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ The order in which preprocessors are applied has changed. Now, preprocessors are
151151

152152
- the `inert` attribute is now applied to outroing elements to make them invisible to assistive technology and prevent interaction. ([#8628](https://github.com/sveltejs/svelte/pull/8628))
153153
- the runtime now uses `classList.toggle(name, boolean)` which may not work in very old browsers. Consider using a [polyfill](https://github.com/eligrey/classList.js) if you need to support these browsers. ([#8629](https://github.com/sveltejs/svelte/issues/8629))
154+
- the runtime now uses the `CustomElement` constructor which may not work in very old browsers. Consider using a [polyfill](https://github.com/theftprevention/event-constructor-polyfill/tree/master) if you need to support these browsers. ([#8775](https://github.com/sveltejs/svelte/pull/8775))
154155
- people implementing their own stores from scratch using the `StartStopNotifier` interface (which is passed to the create function of `writable` etc) from `svelte/store` now need to pass an update function in addition to the set function. This has no effect on people using stores or creating stores using the existing Svelte stores. ([#6750](https://github.com/sveltejs/svelte/issues/6750))
155156
- `derived` will now throw an error on falsy values instead of stores passed to it. ([#7947](https://github.com/sveltejs/svelte/issues/7947))
156157
- type definitions for `svelte/internal` were removed to further discourage usage of those internal methods which are not public API. Most of these will likely change for Svelte 5

packages/svelte/src/runtime/internal/dom.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,12 +1005,7 @@ export function toggle_class(element, name, toggle) {
10051005
* @returns {CustomEvent<T>}
10061006
*/
10071007
export function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
1008-
/**
1009-
* @type {CustomEvent<T>}
1010-
*/
1011-
const e = document.createEvent('CustomEvent');
1012-
e.initCustomEvent(type, bubbles, cancelable, detail);
1013-
return e;
1008+
return new CustomEvent(type, { detail, bubbles, cancelable });
10141009
}
10151010

10161011
/**

0 commit comments

Comments
 (0)