See https://html.spec.whatwg.org/multipage/forms.html#the-label-element "The for attribute may be specified to indicate a form control with which the caption is to be associated. If the attribute is specified, the attribute's value must be the ID of a labelable element in the same Document as the label element. If the attribute is specified and there is an element in the Document whose ID is equal to the value of the for attribute, and the first such element is a labelable element, then that element is the label element's labeled control." When a label element is not in the document, it should not be associated with any form control element. This bug was found by the newly added test: LayoutTests/http/tests/w3c/html/semantics/forms/the-label-element/label-attributes.html
<rdar://problem/22589300>
Created attachment 263860 [details] Patch
Comment on attachment 263860 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263860&action=review > Source/WebCore/html/HTMLLabelElement.cpp:81 > // Find the first element whose id is controlId. If it is found and it is a labelable form control, > - // return it, otherwise return 0. > + // return it, otherwise return nullptr. This is a very wordy comment. Why don't we just remove this comment and rename nodeAsSupportedLabelableElement to firstLabelableFormControl?
Created attachment 263931 [details] Patch
Comment on attachment 263931 [details] Patch Clearing flags on attachment: 263931 Committed r191497: <http://trac.webkit.org/changeset/191497>
All reviewed patches have been landed. Closing bug.