From 86a958d3aa04a5928484d16b27a4d3eea39142e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 23 Oct 2012 15:12:54 -0400 Subject: [PATCH] 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. --- tests/unit/core/core.html | 5 +++++ tests/unit/core/selector.js | 12 ++++++++++++ ui/jquery.ui.core.js | 8 ++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index e259f3270d7..41c8db82738 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -112,6 +112,11 @@

. +
+ + +
+
.
diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js index 7876cdd07fd..f30ad17bec0 100644 --- a/tests/unit/core/selector.js +++ b/tests/unit/core/selector.js @@ -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); diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index e569eea423f..2e9d53ae349 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -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[ ":" ], {