Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug with :nth-of-type(1). Forced parseInt() to resolve to base1…

…0 for non-n values.
  • Loading branch information...
commit 601ffbbfbc86ee7e57dffda03b6f123ec2a770d7 1 parent 0ace8cf
@keithclark authored
Showing with 2 additions and 5 deletions.
  1. +2 −5 jquery-extra-selectors.js
View
7 jquery-extra-selectors.js
@@ -6,7 +6,6 @@
*/
(function($) {
-
function getNthIndex(cur, dir) {
var t = cur, idx = 0;
while (cur = cur[dir] ) {
@@ -19,7 +18,6 @@
function isNthOf(elm, pattern, dir) {
var position = getNthIndex(elm, dir), loop;
-
if (pattern == "odd" || pattern == "even") {
loop = 2;
position -= !(pattern == "odd");
@@ -29,8 +27,8 @@
loop = parseInt(pattern, 10);
position -= (parseInt(pattern.substring(nth + 1), 10) || 0) - 1;
} else {
- loop = position;
- position -= parseInt(pattern) - 1;
+ loop = position + 1;
+ position -= parseInt(pattern, 10) - 1;
}
}
return (loop<0 ? position<=0 : position >= 0) && position % loop == 0
@@ -53,6 +51,5 @@
return isNthOf(elm, match[3], "nextSibling");
}
}
-
$.extend($.expr[':'], pseudos);
}(jQuery));
Please sign in to comment.
Something went wrong with that request. Please try again.