marklagendijk / jquery.tabbable

Simple utility for selecting the next / previous ':tabbable' element.
MIT License
47 stars 27 forks source link

Some elements are incorrectly excluded in Chrome #3

Open FesterCluck opened 9 years ago

FesterCluck commented 9 years ago

In Chrome anchor elements which have sized children (ie: images) are not considered as visible or focusable, and therefore excluded.

This is caused by the difference in the way Chrome reports their offsetWidth and offsetHeight compared to other browsers (Chrome reports 0). This causes jQuery's expr.filters.hidden (":hidden") filter to consider it hidden, and the expr.filters.visible (":visible") filter is just a NOT of hidden.

Using http://api.jquery.com/category/version/1.5/ as a test page will reveal the problem on the books near the bottom. The selector below should get you the 3 elements in question

$("ul.books li a")
FesterCluck commented 9 years ago

Issue logged with jQuery

https://github.com/jquery/jquery/issues/1855

FesterCluck commented 9 years ago

It appears this issue finally got the attention it deserved from the jquery team. The change lands in 3.0.0, as can be seen in jquery/jquery#2227. Is there any intention to test this project's compatibility with that version?

FesterCluck commented 9 years ago

For reference, the new way of determining :visible is

return element.offsetWidth || element.offsetHeight || element.getClientRects().length;

with :hidden simply being a NOT of visible.

FesterCluck commented 7 years ago

@marklagendijk I'd like to take on this upgrade after the transfer.