Side navigation
#87 closed bug (fixed)
Opened July 22, 2006 04:39PM UTC
Closed July 28, 2006 03:34AM UTC
Last modified June 20, 2007 01:39AM UTC
$() bug!
Reported by: | gilles@webunity.nl | 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/
Attachments (0)
Change History (4)
Changed July 23, 2006 04:17PM UTC by comment:1
Changed July 24, 2006 09:35PM UTC by comment:2
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.
Changed July 25, 2006 11:50AM UTC by comment:3
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.
Changed July 28, 2006 03:34AM UTC by comment:4
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">
<option value="1">option1</option>
<option value="2">option2</option>
<option value="3">option3</option>
</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">]