Bug 10472 - REGRESSION: "add" method of <select> object does not put the <option> object in the correct position
Summary: REGRESSION: "add" method of <select> object does not put the <option> object ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 420+
Hardware: Macintosh OS X 10.4
: P1 Normal
Assignee: Nobody
URL:
Keywords: HasReduction, InRadar, Regression
Depends on:
Blocks:
 
Reported: 2006-08-17 13:39 PDT by Sebastian Celis
Modified: 2007-01-21 09:37 PST (History)
2 users (show)

See Also:


Attachments
Test case reduction (2.56 KB, text/html)
2006-08-17 13:40 PDT, Sebastian Celis
no flags Details
Reset the options collection info for non-in-document <select>s (3.94 KB, patch)
2007-01-19 03:02 PST, mitz
no flags Details | Formatted Diff | Diff
Reset the options collection info for non-in-document <select>s (3.94 KB, patch)
2007-01-19 04:52 PST, mitz
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.