Bug 10472

Summary: REGRESSION: "add" method of <select> object does not put the <option> object in the correct position
Product: WebKit Reporter: Sebastian Celis <opendarwin>
Component: FormsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ddkilzer, mitz
Priority: P1 Keywords: HasReduction, InRadar, Regression
Version: 420+   
Hardware: Macintosh   
OS: OS X 10.4   
Attachments:
Description Flags
Test case reduction
none
Reset the options collection info for non-in-document <select>s
none
Reset the options collection info for non-in-document <select>s darin: review+

Description Sebastian Celis 2006-08-17 13:39:06 PDT
In certain circumstances, it seems as though
selectObj.add(optionObj, selectObj.options[0]);
does not actually add optionObj to the beginning of the select object.

From my testing, it looks as if this bug only occurs if the selectObj is created dynamically using document.createElement("select");

The first time the "add" method is called, it works fine.  On subsequent calls, the <option> objects are placed at lower positions in the <select> list.  It is as if selectObj.options[0] is not updated to return the correct object after the "add" is performed.  This is confirmed by calling alert(selectObj.options[0].value); after each call to the "add" method.

This issue is not present in WebKit 4.19.3.

I am attaching a test case reduction which demonstrates the issue.


Machine Details:
MacBook Pro
Mac OS X 10.4.7
WebKit-SVN-r15924.dmg -- Thu Aug 17 8:00:01 GMT 2006
Comment 1 Sebastian Celis 2006-08-17 13:40:15 PDT
Created attachment 10108 [details]
Test case reduction
Comment 2 Stephanie Lewis 2006-11-06 20:48:53 PST
radar 4823090
Comment 3 mitz 2007-01-19 03:02:45 PST
Created attachment 12553 [details]
Reset the options collection info for non-in-document <select>s
Comment 4 David Kilzer (:ddkilzer) 2007-01-19 04:14:27 PST
(In reply to comment #3)
> Created an attachment (id=12553) [edit]
> Reset the options collection info for non-in-document <select>s

In the layout test, there is a lastOption and a middleOption, but no firstOption.  Would it make more sense to rename middleOption to firstOption?
Comment 5 mitz 2007-01-19 04:52:58 PST
Created attachment 12556 [details]
Reset the options collection info for non-in-document <select>s

s/middle/first/
Thanks for pointing this out!
Comment 6 Darin Adler 2007-01-19 08:34:26 PST
Comment on attachment 12556 [details]
Reset the options collection info for non-in-document <select>s

Might want a comment indicating why it's not needed for selects that are in the document.

Or ... could just not both with the if statement since there's no harm in resetting the collection twice.

r=me
Comment 7 Sam Weinig 2007-01-21 09:37:23 PST
Landed in r19011.