[jQuery] strange slice and eq behavior with star ratings + jQuery 1.2.1
There is a line in the (Wil Stuckey's) star ratings plugin that looks
like this:
stars.eq(averageIndex).addClass('on').children('a').css('width',
percent + "%");
I found that the eq() function was not returning 1 item, but rather
all matching items from averageIndex to the end of the items.
My first thought was that perhaps a bug was introduced when eq() was
removed then readded. so I changed it to use a slice:
stars.slice(averageIndex, averageIndex +
1).addClass('on').children('a').css('width', percent + "%");
To my dismay, slice() was also refusing to return a single item!
I decided at this point to try implementing this functionality via a
selector:
$('div.star:eq('+averageIndex
+')').addClass('on').children('a').css('width', percent + "%");
This worked and only returned the single item I cared about.
It seems like something is very wrong for eq() and slice(x, x+1) to
both return more than a single element? How can this possibly occur?
- Jim