#87 closed bug (fixed)
$() bug!
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | 1.0 |
Component: | core | Version: | 1.0a |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
See test case code @ http://www.webunity.nl/_test/jquery/formbug/
Change History (4)
comment:1 Changed 17 years ago by
comment:2 Changed 17 years ago by
The problem seems to be here in the jQuery constructor:
// Watch for when an array is passed in this.get( a.constructor == Array || a.length && a[0] != undefined && a[0].nodeType ?
The select element has a length property, it has a "0" property (the first option), and the first option naturally has a nodeType. However, it isn't an array so it should go to the non-array case. Ugh.
comment:3 Changed 17 years ago by
Reverting to 110 code seems to fix the problem:
// Watch for when an array is passed in this.get( a.constructor == Array ?
instead of:
// Watch for when an array is passed in this.get( a.constructor == Array || a.length && a[0] != undefined && a[0].nodeType ?
It's pretty logical, since when it is an array, all other checks are true. I have even tested submitting multiple checkboxes with thesame name ( name="items[]" ) and serializing of this also still works.
comment:4 Changed 17 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Resolved in SVN. I added an additional nodeType check to make sure that 'a' was, in fact, not a node.
I really really want to be able to pass in an array of elements (including non-standard arrays) to jQuery. Essentially, it's all for this:
$( form.elements )
Greatest browser feature ever.
This seems to be the same problem, but another testcase: http://fuzz.bassistance.de/jQueryFormValidation/selectBug.html
For a simple select element: <select id="select1">
</select>
var selectElement = $("#select1").get(0); both outputs should be the same console.debug($("#select1")); console.debug($(selectElement)); actually, the first contains the select, but the second contains the three options
Console output is this: [<select id="select1">] [<option value="1">,<option value="2">,<option value="3">]