Skip to content

Commit

Permalink
Core: Update :focsable and :tabbable to handle parents with no height…
Browse files Browse the repository at this point in the history
…/width, but visible overflow. Fixes #8643 - :focusable pseudo-selector does not find elements if parent has 0x0 dimension.
  • Loading branch information
scottgonzalez committed Oct 23, 2012
1 parent 97b4813 commit 86a958d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tests/unit/core/core.html
Expand Up @@ -112,6 +112,11 @@ <h2 id="qunit-userAgent"></h2>
<span id="spanTabindex-50" tabindex="-50">.</span>
</div>

<div style="width: 0; height: 0;">
<input id="dimensionlessParent">
<input id="dimensionlessParent-dimensionless" style="height: 0; width: 0;">
</div>

<div id="zIndex100" style="z-index: 100; position: absolute">
<div id="zIndexAutoWithParent">.</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/core/selector.js
Expand Up @@ -157,6 +157,12 @@ test("focusable - area elements", function() {
isNotFocusable('#areaNoImg', 'not associated with an image');
});

test( "focusable - dimensionless parent with overflow", function() {
expect( 1 );

isFocusable( "#dimensionlessParent", "input" );
});

test("tabbable - visible, enabled elements", function() {
expect(18);

Expand Down Expand Up @@ -236,4 +242,10 @@ test("tabbable - area elements", function() {
isNotTabbable('#areaNoImg', 'not associated with an image');
});

test( "tabbable - dimensionless parent with overflow", function() {
expect( 1 );

isTabbable( "#dimensionlessParent", "input" );
});

})(jQuery);
8 changes: 4 additions & 4 deletions ui/jquery.ui.core.js
Expand Up @@ -198,10 +198,10 @@ function focusable( element, isTabIndexNotNaN ) {
}

function visible( element ) {
return !$( element ).parents().andSelf().filter(function() {
return $.css( this, "visibility" ) === "hidden" ||
$.expr.filters.hidden( this );
}).length;
return $.expr.filters.visible( element ) &&
!$( element ).parents().andSelf().filter(function() {
return $.css( this, "visibility" ) === "hidden";
}).length;
}

$.extend( $.expr[ ":" ], {
Expand Down

0 comments on commit 86a958d

Please sign in to comment.