diff options
author | Scott González <scott.gonzalez@gmail.com> | 2016-05-25 08:37:28 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2016-05-25 15:32:18 -0400 |
commit | 50d910b84844367b0bcf324b5bb50ce70b43f9c2 (patch) | |
tree | ee27a71a8e939bd18ebc733ecdeac0a78c7cf1c4 /ui | |
parent | fbc79e1bda2b58f980b9c6fedf3f8ddbce294d7b (diff) | |
download | jquery-ui-50d910b84844367b0bcf324b5bb50ce70b43f9c2.tar.gz jquery-ui-50d910b84844367b0bcf324b5bb50ce70b43f9c2.zip |
Focusable: Detect disabled fieldsets
Fixes #14970
Closes gh-1705
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 |