Skip to content
Permalink
Browse files

Core: Update :focsable and :tabbable to handle parents with no height…

…/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 86a958d3aa04a5928484d16b27a4d3eea39142e4
Showing with 21 additions and 4 deletions.
  1. +5 −0 tests/unit/core/core.html
  2. +12 −0 tests/unit/core/selector.js
  3. +4 −4 ui/jquery.ui.core.js
@@ -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>
@@ -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);

@@ -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);
@@ -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[ ":" ], {

0 comments on commit 86a958d

Please sign in to comment.
You can’t perform that action at this time.