"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:
Created attachment 263860 [details]
Comment on attachment 263860 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=263860&action=review
> // 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]
Comment on attachment 263931 [details]
Clearing flags on attachment: 263931
Committed r191497: <http://trac.webkit.org/changeset/191497>
All reviewed patches have been landed. Closing bug.