]> source.dussan.org Git - jquery-ui.git/commitdiff
Focusable: Fix handling of `visibility: collapse`
authorPaul Capron <PaulCapron@users.noreply.github.com>
Wed, 14 Oct 2020 21:53:11 +0000 (23:53 +0200)
committerGitHub <noreply@github.com>
Wed, 14 Oct 2020 21:53:11 +0000 (23:53 +0200)
"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
tests/unit/core/selector.js
ui/focusable.js

index 31a5bb579d5e4c8effb1082f4b18c84440594b84..7434a1e1fd406a54a9a2617a1f065ec318cbf890 100644 (file)
 
        <span tabindex="1" id="displayNone-span" style="display: none;">.</span>
        <span tabindex="1" id="visibilityHidden-span" style="visibility: hidden;">.</span>
+       <span tabindex="1" id="visibilityCollapse-span" style="visibility: collapse;">.</span>
 
        <input id="displayNone-input" style="display: none;">
        <input id="visibilityHidden-input" style="visibility: hidden;">
+       <input id="visibilityCollapse-input" style="visibility: collapse;">
+
+       <table>
+               <tr>
+                       <td tabindex="1" id="visibilityCollapse-td" style="visibility: collapse;">.</td>
+               </tr>
+       </table>
 </div>
 
 <div>
index f8b9f20c3601b567d4c55c85f4bbd3759982d753..6d867f63479b7407af80b8f2dd3157e082cf9779 100644 (file)
@@ -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 ) {
index b1a7b61e2443799c4529f451b3a4c53cd881a8af..433474fcd7bba863c0994e50aeb8b2c3c5fb6733 100644 (file)
@@ -70,7 +70,7 @@ function visible( element ) {
                element = element.parent();
                visibility = element.css( "visibility" );
        }
-       return visibility !== "hidden";
+       return visibility === "visible";
 }
 
 $.extend( $.expr.pseudos, {