Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add touch events on microtask to avoid Chromium bug #12735

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/healthy-mangos-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
---
'svelte': patch
---

fix: add touch events on microtask to avoid Chromium bug
8 changes: 6 additions & 2 deletions packages/svelte/src/internal/client/dom/elements/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 59,12 @@ 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. The same applies to wheel events.
if (event_name.startsWith('pointer') || event_name === 'wheel') {
// this bug. The same applies to wheel events and touch events.
if (
event_name.startsWith('pointer') ||
event_name.startsWith('touch') ||
event_name === 'wheel'
) {
queue_micro_task(() => {
dom.addEventListener(event_name, target_handler, options);
});
Expand Down
Loading