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.

This commit is contained in:
Scott González 2012-10-23 15:12:54 -04:00
parent 97b4813f30
commit 86a958d3aa
3 changed files with 21 additions and 4 deletions

View File

@ -112,6 +112,11 @@
<span id="spanTabindex-50" tabindex="-50">.</span> <span id="spanTabindex-50" tabindex="-50">.</span>
</div> </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="zIndex100" style="z-index: 100; position: absolute">
<div id="zIndexAutoWithParent">.</div> <div id="zIndexAutoWithParent">.</div>
</div> </div>

View File

@ -157,6 +157,12 @@ test("focusable - area elements", function() {
isNotFocusable('#areaNoImg', 'not associated with an image'); 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() { test("tabbable - visible, enabled elements", function() {
expect(18); expect(18);
@ -236,4 +242,10 @@ test("tabbable - area elements", function() {
isNotTabbable('#areaNoImg', 'not associated with an image'); isNotTabbable('#areaNoImg', 'not associated with an image');
}); });
test( "tabbable - dimensionless parent with overflow", function() {
expect( 1 );
isTabbable( "#dimensionlessParent", "input" );
});
})(jQuery); })(jQuery);

View File

@ -198,10 +198,10 @@ function focusable( element, isTabIndexNotNaN ) {
} }
function visible( element ) { function visible( element ) {
return !$( element ).parents().andSelf().filter(function() { return $.expr.filters.visible( element ) &&
return $.css( this, "visibility" ) === "hidden" || !$( element ).parents().andSelf().filter(function() {
$.expr.filters.hidden( this ); return $.css( this, "visibility" ) === "hidden";
}).length; }).length;
} }
$.extend( $.expr[ ":" ], { $.extend( $.expr[ ":" ], {