Skip to content

Commit 00a3608

Browse files
committed
fix(core): prevent regression in isGesture()
1 parent 6908e0b commit 00a3608

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/core/ui/core/bindable/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,19 @@ export function getEventOrGestureName(name: string): string {
9393
}
9494

9595
export function isGesture(eventOrGestureName: string): boolean {
96-
return !!gestureFromString(eventOrGestureName);
96+
// I believe we perform a case-insensitive lookup rather than an exact match
97+
// for the original camelCase, mainly out of caution for upstream callers that
98+
// might have converted the event name to lowercase (which was certainly a
99+
// problem in Svelte 3).
100+
//
101+
// Not sure whether it's still needed in practice, though (all Core tests pass
102+
// without case-insensitive matching and without trimming whitespace), so
103+
// worth revisiting in future.
104+
const t = eventOrGestureName.trim().toLowerCase();
105+
106+
// Would be nice to have a convenience function for getting all GestureState
107+
// names in `gestures-common.ts`, but it creates a circular dependency.
108+
return t === 'tap' || t === 'doubletap' || t === 'pinch' || t === 'pan' || t === 'swipe' || t === 'rotation' || t === 'longpress' || t === 'touch';
97109
}
98110

99111
// TODO: Make this instance function so that we dont need public statc tapEvent = "tap"

0 commit comments

Comments
 (0)