hammerjs / hammer-time

A fast click based on the touch-action css property
MIT License
100 stars 29 forks source link

How about check focusable element? #19

Closed sculove closed 8 years ago

sculove commented 8 years ago

the focus method might be used unfocusable elements. https://github.com/hammerjs/hammer-time/blob/master/hammer-time.js#L78

How about add conditional in code which uses HTMLElement.foucs method ?

arschmitz commented 8 years ago

By unfousable elements do you mean things like divs with no tabindex or a disabled input? Im not completely sure what your suggesting. All HTMLElements have the focus method and thats whats being used here. Even if an element is not focusable it still has the method it just does not do anything.

If your worried about trying to focus things like document or window these cases cant happen. Firstly because the target must either have a style property containing touch-action or have a parent which does and document and window do not. In addition the target has getBoundClientRect called on it prior. All of these things would fail if the target was not an HTMLElement.

If im missing something here let me know but it does not seem like this check is needed

runspired commented 8 years ago

all elements are focusable and have behavior associated with that.

sculove commented 8 years ago

OK. I got it. I may be worrying unduly.