Skip to content

Commit

Permalink
Incorrect event.button checking. (#608)
Browse files Browse the repository at this point in the history
MouseEvent.button === 0 if main button pressed, usually the left button or the un-initialized state (https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button). Also usually if event.which not available this means event.button exists, so enough just check them in the correct sequence.
  • Loading branch information
PaulMaly authored Mar 23, 2021
1 parent 75b11d8 commit 2630996
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions packages/kit/src/runtime/client/router.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { find_anchor, get_base_uri } from './utils';

/** @param {MouseEvent} event */
function which(event) {
return event.which === null ? event.button : event.which;
}

function scroll_state() {
return {
x: pageXOffset,
Expand Down Expand Up @@ -73,7 +68,7 @@ export class Router {
addEventListener('click', (event) => {
// Adapted from https://github.com/visionmedia/page.js
// MIT license https://github.com/visionmedia/page.js#license
if (which(event) !== 1) return;
if (event.button || event.which !== 1) return;
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
if (event.defaultPrevented) return;

Expand Down

0 comments on commit 2630996

Please sign in to comment.