Bug 48193

Summary: HTMLFormElement.elements doesn't include fieldsets
Product: WebKit Reporter: Ms2ger (he/him; ⌚ UTC+1/+2) <Ms2ger>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, yael
Priority: P3    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
URL: http://www.whatwg.org/html/#category-listed
Attachments:
Description Flags
Patch. darin: review+

Description Ms2ger (he/him; ⌚ UTC+1/+2) 2010-10-23 13:30:24 PDT
Fieldset is a listed element (see $URL). Test: <http://software.hixie.ch/utilities/js/live-dom-viewer/saved/674>

Tested with:

Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.11 Safari/534.10
Comment 1 Ms2ger (he/him; ⌚ UTC+1/+2) 2010-10-23 13:31:25 PDT
In particular, the test should log "[object HTMLFieldSetElement]" or some such, rather than "undefined".
Comment 2 Yael 2010-11-29 13:35:29 PST
Created attachment 75054 [details]
Patch.

Added filedset and keygen to HTMLFormElement.elements by making them enumeratable.
object element should be listed as well and I will file a separate bug for that.
Comment 3 Darin Adler 2010-11-29 13:40:55 PST
Comment on attachment 75054 [details]
Patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=75054&action=review

> WebCore/html/HTMLKeygenElement.h:39
> -    virtual bool isEnumeratable() const { return false; }
> +    virtual bool isEnumeratable() const { return true; }

You should instead just remove this member function entirely. The function inherited from HTMLSelectElement already returns true, there is no need to override.

> LayoutTests/fast/forms/script-tests/form-collection-elements.js:2
> +debug("This test does not add object element as a listed element. Separate bug will be filed for that.");

I don’t think “separate bug will be filed” makes sense in a comment in the test. Maybe you mean we’ll test that with a separate test?
Comment 4 Alexey Proskuryakov 2010-11-29 13:41:21 PST
Do the test results match Firefox and/or IE exactly?
Comment 5 Yael 2010-11-29 13:45:11 PST
(In reply to comment #4)
> Do the test results match Firefox and/or IE exactly?

Firefox and Opera do list keygen, fieldset and object. I am still testing on IE. Will have the results before committing this patch.
Firefox does not list output element though.
Comment 6 Yael 2010-11-29 13:46:26 PST
(In reply to comment #3)
> (From update of attachment 75054 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=75054&action=review
> 
> > WebCore/html/HTMLKeygenElement.h:39
> > -    virtual bool isEnumeratable() const { return false; }
> > +    virtual bool isEnumeratable() const { return true; }
> 
> You should instead just remove this member function entirely. The function inherited from HTMLSelectElement already returns true, there is no need to override.
> 
> > LayoutTests/fast/forms/script-tests/form-collection-elements.js:2
> > +debug("This test does not add object element as a listed element. Separate bug will be filed for that.");
> 
> I don’t think “separate bug will be filed” makes sense in a comment in the test. Maybe you mean we’ll test that with a separate test?
Thank you for the review. I will make the adjustments before committing. Since object elemnt is not as straightforward as keygen and fieldset, I filed https://bugs.webkit.org/show_bug.cgi?id=50179 to fix that.
Comment 7 Yael 2010-11-29 14:21:01 PST
(In reply to comment #4)
> Do the test results match Firefox and/or IE exactly?

IE9 Beta does not support keygen element, but it does list fieldset in HTMLFormElement.elements .
Comment 8 Yael 2010-11-29 14:46:58 PST
Committed r72835: <http://trac.webkit.org/changeset/72835>