Added fix for :nth-child(n).
[jquery.git] / src / selector / selector.js
index 13fd094..94af81e 100644 (file)
@@ -16,7 +16,7 @@ jQuery.extend({
                        // Child Checks
                        "first-child": "a.parentNode.getElementsByTagName('*')[0]==a",
                        "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
-                       "only-child": "a.parentNode.getElementsByTagName('*').length==1",
+                       "only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",
 
                        // Parent Checks
                        parent: "a.firstChild",
@@ -377,7 +377,7 @@ jQuery.extend({
                                        var add = false;
 
                                        if ( first == 1 ) {
-                                               if ( node.nodeIndex == last )
+                                               if ( last == 0 || node.nodeIndex == last )
                                                        add = true;
                                        } else if ( (node.nodeIndex + last) % first == 0 )
                                                add = true;