Opened 14 years ago
Closed 14 years ago
#3520 closed bug (duplicate)
.eq(n) acts funny
Reported by: | sorpigal | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.3 |
Component: | core | Version: | 1.2.6 |
Keywords: | Cc: | sorpigal, flesler | |
Blocked by: | Blocking: |
Description
When passing .eq() a variable containing an integer parsed out of a string the results are strange. In my case I was passing 0, 1 or 2 based on the values found in a string. When passing 0 and 2 I got expected results, when passing 1 I found that .eq(n).length == 2, which is very wrong.
I do not have a simple test case for this, but the fix is:
eq: function( i ) {
return this.slice( +i, +i + 1 );
},
The unary + forces i to be a number. I think there is no possible harm to this and it will save many people frustration. Technically, of course, it is user error.
Change History (4)
comment:1 Changed 14 years ago by
Cc: | sorpigal flesler added |
---|
comment:3 Changed 14 years ago by
Confirmed, works as expected with nightly.
Sorry, if I had known about that I would have tested before filing.
This should be fixed in trunk.
Can you try with this file ? http://code.jquery.com/jquery-nightly.js
Do post back even if it works so that I can close this.