Opened 12 years ago
Closed 12 years ago
#9026 closed bug (invalid)
bug in "inArray"
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | core | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
this function "$.inArray" does not work properly in IE, it returns "undefined" instead of "-1". to correct, you just need to put "Array.indexOf" instead of "array.indexOf" that's all.
Change History (5)
comment:1 Changed 12 years ago by
Component: | unfiled → misc |
---|---|
Owner: | set to anas1305@… |
Priority: | undecided → low |
Status: | new → pending |
comment:2 follow-up: 3 Changed 12 years ago by
There is no occurrence of "array.indexOf" in the entire jQuery code base.
comment:3 Changed 12 years ago by
Status: | pending → new |
---|
Replying to rwaldron:
There is no occurrence of "array.indexOf" in the entire jQuery code base.
you can find this in lines 677 & 678. And below the code snippet found in jquery version 1.5.2:
inArray: function( elem, array ) { if ( array.indexOf ) { return array.indexOf( elem ); } for ( var i = 0, length = array.length; i < length; i++ ) { if ( array[ i ] === elem ) { return i; } } return -1; },
comment:4 Changed 12 years ago by
Component: | misc → core |
---|---|
Status: | new → pending |
Your correction would not fix the problem. As long as array is an Array, and indexOf is supported, it will be used and it returns -1 if elem is not present in the array. I have verified that inArray is working correctly: http://jsfiddle.net/timmywil/62tF9/. So we still need a test case showing where inArray returns undefined.
comment:5 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
As you can see, in the _most recent_ version of the source, there is no "array.indexOf":
https://github.com/jquery/jquery/blob/master/src/core.js#L665-677
Additionally, your recommendation to change this to Array.indexOf is wrong - there is no static "indexOf" method on the Array object.
Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on http://jsFiddle.net that reproduces the issue experienced to help us assess your ticket!
Additionally, test against the
jQuery (edge)
version to ensure the issue still exists.