From f5d38e2e05bd54073c2bf8e8210b78b2cf2637d8 Mon Sep 17 00:00:00 2001 From: Paul Capron Date: Wed, 14 Oct 2020 23:53:11 +0200 Subject: [PATCH] Focusable: Fix handling of `visibility: collapse` "collapse" is similar to "hidden", with a slight difference in the case of tr/tbody/td/colgroup elements. See https://www.w3.org/TR/CSS22/visufx.html#visibility See https://www.w3.org/TR/CSS22/tables.html#dynamic-effects See https://developer.mozilla.org/en-US/docs/Web/CSS/visibility#Table_example "visibility: collapse" elements are always not focusable, though. Commit d3025968f34 introduced a regression by testing with `!== "hidden"` instead of `=== "visible"`. Closes gh-1843 --- tests/unit/core/core.html | 8 ++++++++ tests/unit/core/selector.js | 6 +++++- ui/focusable.js | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index 31a5bb579..7434a1e1f 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -108,9 +108,17 @@ + . + + + + + + +
.
diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js index f8b9f20c3..6d867f634 100644 --- a/tests/unit/core/selector.js +++ b/tests/unit/core/selector.js @@ -133,7 +133,7 @@ QUnit.test( "focusable - disabled elements", function( assert ) { } ); QUnit.test( "focusable - hidden styles", function( assert ) { - assert.expect( 12 ); + assert.expect( 15 ); assert.isNotFocusable( "#displayNoneAncestor-input", "input, display: none parent" ); assert.isNotFocusable( "#displayNoneAncestor-span", "span with tabindex, display: none parent" ); @@ -149,9 +149,13 @@ QUnit.test( "focusable - hidden styles", function( assert ) { assert.isNotFocusable( "#displayNone-input", "input, display: none" ); assert.isNotFocusable( "#visibilityHidden-input", "input, visibility: hidden" ); + assert.isNotFocusable( "#visibilityCollapse-input", "input, visibility: collapse" ); assert.isNotFocusable( "#displayNone-span", "span with tabindex, display: none" ); assert.isNotFocusable( "#visibilityHidden-span", "span with tabindex, visibility: hidden" ); + assert.isNotFocusable( "#visibilityCollapse-span", "span with tabindex, visibility: collapse" ); + + assert.isNotFocusable( "#visibilityCollapse-td", "td with tabindex, visibility: collapse" ); } ); QUnit.test( "focusable - natively focusable with various tabindex", function( assert ) { diff --git a/ui/focusable.js b/ui/focusable.js index b1a7b61e2..433474fcd 100644 --- a/ui/focusable.js +++ b/ui/focusable.js @@ -70,7 +70,7 @@ function visible( element ) { element = element.parent(); visibility = element.css( "visibility" ); } - return visibility !== "hidden"; + return visibility === "visible"; } $.extend( $.expr.pseudos, { -- 2.39.5