diff --git a/.changeset/metal-pans-trade.md b/.changeset/metal-pans-trade.md new file mode 100644 index 0000000000..5c0feea516 --- /dev/null +++ b/.changeset/metal-pans-trade.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +fix: better support for onwheel events in chrome diff --git a/packages/svelte/src/internal/client/dom/elements/events.js b/packages/svelte/src/internal/client/dom/elements/events.js index 81285acb30..fb2cf88c37 100644 --- a/packages/svelte/src/internal/client/dom/elements/events.js +++ b/packages/svelte/src/internal/client/dom/elements/events.js @@ -55,8 +55,8 @@ export function create_event(event_name, dom, handler, options) { // Chrome has a bug where pointer events don't work when attached to a DOM element that has been cloned // with cloneNode() and the DOM element is disconnected from the document. To ensure the event works, we // defer the attachment till after it's been appended to the document. TODO: remove this once Chrome fixes - // this bug. - if (event_name.startsWith('pointer')) { + // this bug. The same applies to wheel events. + if (event_name.startsWith('pointer') || event_name === 'wheel') { queue_micro_task(() => { dom.addEventListener(event_name, target_handler, options); });