Skip to main content

Bug Tracker

Side navigation

#6912 closed bug (fixed)

Opened August 17, 2010 02:29PM UTC

Closed April 17, 2011 05:51PM UTC

Last modified May 04, 2011 02:11PM UTC

$().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:

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. 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)
  • test-6912.html (0.6 KB) - added by dmethvin August 19, 2010 01:56AM UTC.
Change History (5)

Changed August 19, 2010 02:17AM UTC by dmethvin comment:1

There is a similar situation with

elements 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

should do the same thing as
, and the same goes for

If that was the case, it might be easiest to fix this issue in

by not turning DOMElement with
into an array of its children.

Changed October 15, 2010 04:32AM UTC by snover comment:2

milestone: 1.4.3
priority: → low
status: newopen

Changed April 17, 2011 05:50PM UTC by john comment:3

milestone: → 1.6
owner: → john
status: openassigned

Changed April 17, 2011 05:51PM UTC by John Resig comment:4

resolution: → fixed
status: assignedclosed

Make sure that forms and selects are added to a jQuery set correctly. Fixes #6912.

Changeset: 728a70c036dfcdc0c45c5c60c08aeade786ce195

Changed May 04, 2011 02:11PM UTC by timmywil comment:5

#6867 is a duplicate of this ticket.