Side navigation
#3520 closed bug (duplicate)
Opened October 24, 2008 06:14PM UTC
Closed October 27, 2008 12:19PM UTC
.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.
Attachments (0)
Change History (4)
Changed October 24, 2008 10:11PM UTC by comment:1
cc: | → sorpigal, flesler |
---|
Changed October 27, 2008 10:25AM UTC by comment:3
Confirmed, works as expected with nightly.
Sorry, if I had known about that I would have tested before filing.
Changed October 27, 2008 12:19PM UTC by comment:4
resolution: | → duplicate |
---|---|
status: | new → closed |
No problem.
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.