From c71e29c1eb9d6c585591fb46f744eaec46d779d9 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Wed, 29 May 2024 09:16:56 +0100 Subject: [PATCH] fix: better support for onwheel events in chrome (#11808) --- .changeset/metal-pans-trade.md | 5 +++++ packages/svelte/src/internal/client/dom/elements/events.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/metal-pans-trade.md 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); });