diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/focusable.js | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/ui/focusable.js b/ui/focusable.js index b8355b96c..cf4f728b8 100644 --- a/ui/focusable.js +++ b/ui/focusable.js @@ -26,8 +26,9 @@ // Selectors $.ui.focusable = function( element, hasTabindex ) { - var map, mapName, img, + var map, mapName, img, focusableIfVisible, fieldset, nodeName = element.nodeName.toLowerCase(); + if ( "area" === nodeName ) { map = element.parentNode; mapName = map.name; @@ -37,12 +38,28 @@ $.ui.focusable = function( element, hasTabindex ) { img = $( "img[usemap='#" + mapName + "']" ); return img.length > 0 && img.is( ":visible" ); } - return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ? - !element.disabled : - "a" === nodeName ? - element.href || hasTabindex : - hasTabindex ) && - $( element ).is( ":visible" ) && visible( $( element ) ); + + if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) { + focusableIfVisible = !element.disabled; + + if ( focusableIfVisible ) { + + // Form controls within a disabled fieldset are disabled. + // However, controls within the fieldset's legend do not get disabled. + // Since controls generally aren't placed inside legends, we skip + // this portion of the check. + fieldset = $( element ).closest( "fieldset" )[ 0 ]; + if ( fieldset ) { + focusableIfVisible = !fieldset.disabled; + } + } + } else if ( "a" === nodeName ) { + focusableIfVisible = element.href || hasTabindex; + } else { + focusableIfVisible = hasTabindex; + } + + return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) ); }; // Support: IE 8 only |