diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-07-22 10:33:42 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-07-22 10:33:42 -0400 |
commit | fe13fbadd45b59fb67ce6b47c5aea6231596a7c7 (patch) | |
tree | aad597bb9672e623bd7f0f085cd8703c30a8b204 /ui/jquery.ui.core.js | |
parent | 4deb824699b025d74d6849a73ec47c182df93fa0 (diff) | |
download | jquery-ui-fe13fbadd45b59fb67ce6b47c5aea6231596a7c7.tar.gz jquery-ui-fe13fbadd45b59fb67ce6b47c5aea6231596a7c7.zip |
Core: Better support for areas in :focusable and :tabbable selectors. Partial fix for #4488 - :focusable and :tabbable are broken with jQuery 1.3.2.
Diffstat (limited to 'ui/jquery.ui.core.js')
-rw-r--r-- | ui/jquery.ui.core.js | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 0804edab7..49b5c003b 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -231,6 +231,13 @@ $.each( [ "Width", "Height" ], function( i, name ) { }); //Additional selectors +function visible( element ) { + return !$(element).parents().andSelf().filter(function() { + return $.curCSS( this, "visibility" ) === "hidden" || + $.expr.filters.hidden( this ); + }).length; +} + $.extend($.expr[':'], { data: function(elem, i, match) { return !!$.data(elem, match[3]); @@ -239,17 +246,23 @@ $.extend($.expr[':'], { focusable: function(element) { var nodeName = element.nodeName.toLowerCase(), tabIndex = $.attr(element, 'tabindex'); + if ( "area" === nodeName ) { + var map = element.parentNode, + mapName = map.name, + img; + if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { + return false; + } + img = $( "img[usemap=#" + mapName + "]" )[0]; + return !!img && visible( img ); + } return (/input|select|textarea|button|object/.test(nodeName) ? !element.disabled - : 'a' == nodeName || 'area' == nodeName + : 'a' == nodeName ? element.href || !isNaN(tabIndex) : !isNaN(tabIndex)) // the element and all of its ancestors must be visible - // the browser may report that the area is hidden - && !$(element).parents().andSelf().filter(function() { - return $.curCSS( this, "visibility" ) === "hidden" || - $.expr.filters.hidden( this ); - }).length; + && visible( element ); }, tabbable: function(element) { |