X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=jquery%2Fjquery.js;h=b8a8b4a3379d0f2e671d9b07fb9025f009950f2d;hb=193866de0aabe1a86d9cd2c4ff147f5dda626872;hp=475ca5608e9f324adac89a183d2306786d730568;hpb=aee5a0fe70baedc71ca3b6f87d80a88f794e6d31;p=jquery.git diff --git a/jquery/jquery.js b/jquery/jquery.js index 475ca56..b8a8b4a 100644 --- a/jquery/jquery.js +++ b/jquery/jquery.js @@ -3,8 +3,8 @@ * By John Resig (http://ejohn.org/) * Under an Attribution, Share Alike License * - * $Date: $ - * $Rev: $ + * $Date$ + * $Rev$ */ function $(a,c) { @@ -212,21 +212,27 @@ function $(a,c) { this.cur = this.old; return this; }, - - parent: function(a) { - if ( a == null ) a = 1; - this.cur = $.map(this.cur,function(d){ - var b = $.parents(d); - if ( a == 0 ) - return b; - else if ( a.constructor == String ) { - var c = $.filter(a,b); - return c.length > 0 ? c[0] : null; - } else - return b.length >= a ? b[a-1] : null; - }); - return this; - }, + + parent: function(a) { + this.cur = $.map(this.cur,function(d){ + return d.parentNode; + }); + if ( a ) this.cur = $.filter(a,this.cur).r; + return this; + }, + + parents: function(a) { + this.cur = $.map(this.cur,$.parents); + if ( a ) this.cur = $.filter(a,this.cur).r; + return this; + }, + + siblings: function(a) { + // Incorrect, need to exclude current element + this.cur = $.map(this.cur,$.sibling); + if ( a ) this.cur = $.filter(a,this.cur).r; + return this; + }, parents: function(a) { return this; @@ -573,7 +579,7 @@ $.filter = function(t,r,not) { $.parents = function(a){ var b = []; var c = a.parentNode; - while ( c != null && c != c.documentElement ) { + while ( c != null && c != document ) { b[b.length] = c; c = c.parentNode; }