Side navigation
#6867 closed bug (duplicate)
Opened August 04, 2010 03:59AM UTC
Closed May 04, 2011 02:11PM UTC
Last modified May 04, 2011 02:11PM UTC
jQuery.fn.add adds incorrect elements when given select or form DOM nodes
Reported by: | scott_h | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | traversing | Version: | 1.4.2 |
Keywords: | add, makeArray | Cc: | |
Blocked by: | Blocking: |
Description
Some DOM elements have a length property -- e.g., select box elements and forms, which alias their options and elements collections respectively -- and these cause jQuery.makeArray to consider them as arrays rather than array items. This has the effect that jQuery().add(mySelectElement) returns a list of option elements instead of a single select element.
Attachments (2)
Change History (8)
Changed August 04, 2010 04:04AM UTC by comment:1
Changed August 04, 2010 04:20AM UTC by comment:2
Fixed test - the first one is incorrect, so please use the second one.
Changed August 04, 2010 10:56AM UTC by comment:3
Here's the fix I propose for this bug:
http://github.com/shghs/jquery/commit/904ef97ed1175b6f899efe9240381c8b0638667d
Changed August 21, 2010 02:25PM UTC by comment:4
I agree with this patch, but there is a test case that fails when it is applied (Pass makeArray a form (treat as elements)) that indicates it is intended. The api docs don't specifically mention this behavior as a feature, though. Also, the one place I could think of where it might be depended upon, serializeArray, already checks for form.elements so it doesn't need makeArray to do this AFAICT.
Changed October 23, 2010 11:49PM UTC by comment:5
milestone: | 1.4.3 → 1.4.5 |
---|---|
priority: | → low |
status: | new → open |
Changed May 04, 2011 02:11PM UTC by comment:7
component: | core → traversing |
---|---|
resolution: | → duplicate |
status: | open → closed |
Thank you scott_h! You're right.
This affects Chrome, Safari, Firefox, IE7 and IE8 (Opera untested).