From a3b2501c3103720ac0e4642458cd3261bd1f9f9c Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Mon, 19 Sep 2016 22:28:26 +0200 Subject: [PATCH] Recognize explicit `tabindex="-1"` elements as focusable This is especially helpful in the devtools, where many ``s have this attribute, but not much else to go for. --- extension/lib/utils.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index e8b0e3c..57c7d01 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -108,7 +108,12 @@ isDevtoolsWindow = (window) -> ] isFocusable = (element) -> - return element.tabIndex > -1 and + # Focusable elements have `.tabIndex > 1` (but not necessarily a + # `tabindex="…"` attribute) … + return (element.tabIndex > -1 or + # … or an explicit `tabindex="-1"` attribute (which means that it is + # focusable, but not reachable with ``). + element.getAttribute?('tabindex') == '-1') and not (element.localName?.endsWith?('box') and element.localName != 'checkbox') and not (element.localName == 'toolbarbutton' and -- 2.39.3