Closed sculove closed 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
all elements are focusable and have behavior associated with that.
OK. I got it. I may be worrying unduly.
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 ?