- From: Garrett Smith <dhtmlkitchen@gmail.com>
- Date: Thu, 1 Jan 2015 13:47:40 -0800
- To: Michael Gratton <mike@vee.net>
- Cc: whatwg@whatwg.org, Ian Hickson <ian@hixie.ch>
On 12/30/14, Michael Gratton <mike@vee.net> wrote: > On Tue, 30 Dec, 2014 at 5:12 PM, Garrett Smith <dhtmlkitchen@gmail.com> > wrote: >> [snip] > >> >> - alerts false >> >> This result, in a way, seems to contradict the following:- >> >> | The disabled attribute, when specified, causes all >> | the form control descendants of the fieldset element, >> | excluding those that are descendants of the fieldset >> | element's first legend element child, if any, to be disabled. >> >> http://www.w3.org/TR/html5/forms.html#the-fieldset-element > > This behaviour is useful from the user's perspective: If a user first > disables then re-enables a fieldset, the disabled state of descendant > controls should persist. E.g. if the fieldset contains a control that > is not disabled, then on re-enabling the fieldset the control should > one again be not disabled. > Yes. > The behaviour of the disabled attribute you find above makes sense > under those circumstances: It reflects the disabled state of the > control were its ancestor fieldsets (if any) not disabled - it doesn't > reflect if it would included in a submission or not. > No. The disabled attribute about is about FIELDSET element. The `disabled` property of the FIELDSET reflects the attribute. And if its value is true - `fieldset.disabled = true` - then the descendant elements of that feildset are not going to be submitted. http://jsfiddle.net/wmu9jg7s/1/ <form action="http://www.example.net" target="_blank"> <fieldset id="a"> <table><tr><td><input name="b" id="b"/></table> </fieldset> <input type="submit"> </form> <script> // Disable the fieldset to make all its form control // descendants to be disabled // [1] // document.getElementById("a").disabled = true; // Are they? Lets see: // alert(document.getElementById("b").disabled); </script> If the form is submitted as is, the target location is http://www.example.net/?b= Uncomment [1] and you'll see no ?b= http://www.example.net/ > Given the variety of conditions in both the spec and in browser > implementations that would make a control eligible for success, maybe > it would be useful it have an attribute like 'enabled' - but what's the > use case? > element.matches(":disabled") - does what I want. The way to determine if a control is disabled has always been to check its disabled property, `el.disabled`. Code that uses this approach instead of matches(":disabled") won't work, and that is most code and most libraries. To determine if a form control is enabled, use: element.matches(":disabled") where supported; `disabled` elsewhere. -- Garrett @xkit ChordCycles.com garretts.github.io
Received on Thursday, 1 January 2015 21:48:05 UTC