Skip to content

Commit 8bde2d5

Browse files
authored
fix: add touch events on microtask to avoid Chromium bug (#12735)
1 parent 76cb89c commit 8bde2d5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.changeset/healthy-mangos-brush.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+
fix: add touch events on microtask to avoid Chromium bug

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ export function create_event(event_name, dom, handler, options) {
5959
// Chrome has a bug where pointer events don't work when attached to a DOM element that has been cloned
6060
// with cloneNode() and the DOM element is disconnected from the document. To ensure the event works, we
6161
// defer the attachment till after it's been appended to the document. TODO: remove this once Chrome fixes
62-
// this bug. The same applies to wheel events.
63-
if (event_name.startsWith('pointer') || event_name === 'wheel') {
62+
// this bug. The same applies to wheel events and touch events.
63+
if (
64+
event_name.startsWith('pointer') ||
65+
event_name.startsWith('touch') ||
66+
event_name === 'wheel'
67+
) {
6468
queue_micro_task(() => {
6569
dom.addEventListener(event_name, target_handler, options);
6670
});

0 commit comments

Comments
 (0)