visionmedia / page.js

Micro client-side router inspired by the Express router

Home Page:http://visionmedia.github.com/page.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect fallback from event.which to event.button

jstanley0 opened this issue · comments

This line of code is incorrect:

return null == e.which ? e.button : e.which;

because which returns 1 to mean the primary button, and button returns 0 to mean the same thing.

When calling clickHandler from a React onClick, a synthetic event is supplied which implements button but not which. As a result, _which returns 0 and the event handler skips the event because it was expecting 1.

you can use:

return e.button !== undefined ? e.button : e.which;

With this modification, if e.button is available, it will be returned. Otherwise, if e.button is undefined, it will fall back to e.which. This way, you ensure consistent behavior for determining the primary button regardless of the event system being used.

I also edited this in the code and requested a pull request