#6912 closed bug (fixed)
$().add(selectElement) adds option children instead
| Reported by: | ratbeard | Owned by: | john |
|---|---|---|---|
| Priority: | low | Milestone: | 1.6 |
| Component: | traversing | Version: | 1.4.3 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
Passing a raw dom select element to jQuery.fn.add adds all of its option children to the collection, instead of the select element itself.
Array.prototype.slice.call() inside makeArray gets confused probably due to the select element having a length property.
Tested this in Chrome 5 and FF 3.6 on osx 10.6.
Workaround is to wrap the select element in jQuery()
Attachments (1)
Change History (6)
Changed 9 years ago by
| Attachment: | test-6912.html added |
|---|
comment:1 Changed 9 years ago by
comment:2 Changed 9 years ago by
| Milestone: | 1.4.3 |
|---|---|
| Priority: | → low |
| Status: | new → open |
| Version: | 1.4.2 → 1.4.3 |
comment:3 Changed 8 years ago by
| Milestone: | → 1.6 |
|---|---|
| Owner: | set to john |
| Status: | open → assigned |
comment:4 Changed 8 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Make sure that forms and selects are added to a jQuery set correctly. Fixes #6912.
Changeset: 728a70c036dfcdc0c45c5c60c08aeade786ce195
Note: See
TracTickets for help on using
tickets.

There is a similar situation with
formelements but it seems to be by intent because there is a test case to verify that adding a form actually adds the form.elements collection.It seems that
.add("form#mine")should do the same thing as.add(getElementById("mine")), and the same goes forselect.If that was the case, it might be easiest to fix this issue in
makeArrayby not turning DOMElement with.lengthinto an array of its children.