File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,35 @@ bot.dom.isEnabled = function(el) {
330
330
goog . dom . TagName . OPTION == tagName ) {
331
331
return bot . dom . isEnabled ( ( /**@type {!Element }*/ el . parentNode ) ) ;
332
332
}
333
+
334
+ // Is there an ancestor of the current element that is a disabled fieldset
335
+ // and whose child is also an ancestor-or-self of the current element but is
336
+ // not the first legend child of the fieldset. If so then the element is
337
+ // disabled.
338
+ if ( goog . dom . getAncestor ( el , function ( e ) {
339
+ var parent = e . parentNode ;
340
+
341
+ if ( parent &&
342
+ bot . dom . isElement ( parent , goog . dom . TagName . FIELDSET ) &&
343
+ bot . dom . getProperty ( parent , 'disabled' ) ) {
344
+ if ( ! bot . dom . isElement ( e , goog . dom . TagName . LEGEND ) ) {
345
+ return true ;
346
+ }
347
+
348
+ var sibling = e ;
349
+ // Are there any previous legend siblings? If so then we are not the
350
+ // first and the element is disabled
351
+ while ( sibling = goog . dom . getPreviousElementSibling ( sibling ) ) {
352
+ if ( bot . dom . isElement ( sibling , goog . dom . TagName . LEGEND ) ) {
353
+ return true ;
354
+ }
355
+ }
356
+ }
357
+ return false ;
358
+ } , true ) ) {
359
+ return false ;
360
+ }
361
+
333
362
return true ;
334
363
} ;
335
364
Original file line number Diff line number Diff line change 47
47
assertDisabled ( 'inherits-disabled-2' ) ;
48
48
}
49
49
50
+ function testDisabledShouldInheritFromFieldsetUnlessInLegend ( ) {
51
+ assertDisabled ( 'disabled-fieldset-button-g' ) ;
52
+ assertEnabled ( 'legend-button-f' ) ;
53
+ }
54
+
50
55
function testEnabledShouldRespondToDisabledProperty ( ) {
51
56
var element = goog . dom . $ ( 'enabled-button-a' ) ;
52
57
element . disabled = true ;
79
84
< option id ="inherits-disabled-2 "> baz</ option >
80
85
</ optgroup >
81
86
</ select >
87
+
88
+ < fieldset id ="disabled-fieldset " disabled ="disabled ">
89
+ < legend >
90
+ < button id ="legend-button-f " value ="Enabled F "> </ button >
91
+ </ legend >
92
+ < button id ="disabled-fieldset-button-g " value ="Enabled G "> </ button >
93
+ </ fieldset >
82
94
</ form >
83
95
</ body >
84
96
</ html >
You can’t perform that action at this time.
0 commit comments