Skip to main content

Bug Tracker

Side navigation

#3102 closed enhancement (fixed)

Opened June 30, 2008 08:09AM UTC

Closed July 01, 2008 02:05AM UTC

Last modified October 14, 2008 10:47AM UTC

jquery.eq() wrong behaviour if passed string

Reported by: stevef_ Owned by: flesler
Priority: minor Milestone: 1.3
Component: core Version: 1.2.6
Keywords: eq Cc:
Blocked by: Blocking:
Description

Copy of ticket #3051, cant believe this was closed!

This wasted a good few hous of my time, surely a string check could be done here to avoid this causing problems for other people in the future.

I would rather see an error thrown rather than a jq object containing multiple results, this is really dangerous behaviour especially if your chaining and inadvertinly set many attributes instead of the one desired.

From 1.2.6 source:

443 eq: function( i ) {

444 return this.slice( i, i + 1 );

445 }

This works fine when passed an integer. Selects a range when passed a string. For example:

.eq("1")

passes ("1", "11") to slice instead of (1, 2).

Attachments (0)
Change History (5)

Changed June 30, 2008 04:18PM UTC by flesler comment:1

owner: → flesler
status: newassigned
type: bugenhancement

Ok, just figured a small fix, only one extra byte.

Changed June 30, 2008 04:18PM UTC by flesler comment:2

resolution: → fixed
status: assignedclosed

Applied the change at [5754].

Changed June 30, 2008 04:51PM UTC by Markus.Staab comment:3

should be easy to have a unit test for this little bug..

Changed June 30, 2008 05:35PM UTC by Markus.Staab comment:4

resolution: fixed
status: closedreopened

Changed July 01, 2008 02:05AM UTC by flesler comment:5

resolution: → fixed
status: reopenedclosed

Ok, added one simple test at [5755]. That should be enough.