X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=175da47029b081bfa6b1ac2e396bac96ff6fc425;hb=bcc8a837055fe720579628d758b7034d6b520f2e;hp=63d795c0c81724ffa59beafae78d79765e9af5d2;hpb=48ec10044f011ccfe9bd232d629682b59cccbd97;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 63d795c..175da47 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -69,7 +69,7 @@ function jQuery(a,c) { } // Map over the $ in case of overwrite -if ( $ ) +if ( typeof $ != "undefined" ) jQuery._$ = $; // Map the jQuery namespace to the '$' one @@ -193,7 +193,15 @@ jQuery.fn = jQuery.prototype = { * argument representing the position of the element in the matched * set. * - * @example $("img").each(function(){ this.src = "test.jpg"; }); + * @example $("img").each(function(){ + * this.src = "test.jpg"; + * }); + * @before + * @result + * + * @example $("img").each(function(i){ + * alert( "Image #" + i + " is " + this ); + * }); * @before * @result * @@ -370,8 +378,9 @@ jQuery.fn = jQuery.prototype = { for ( var j = 0; j < e.length; j++ ) { var r = e[j].childNodes; for ( var i = 0; i < r.length; i++ ) - t += r[i].nodeType != 1 ? - r[i].nodeValue : jQuery.fn.text([ r[i] ]); + if ( r[i].nodeType != 8 ) + t += r[i].nodeType != 1 ? + r[i].nodeValue : jQuery.fn.text([ r[i] ]); } return t; }, @@ -629,6 +638,7 @@ jQuery.fn = jQuery.prototype = { * @example $("p").not("#selected") * @before

Hello

Hello Again

* @result [

Hello

] + * @test cmpOK($("#main > p#ap > a").not("#google").length, "==", 2, ".not") * * @name not * @type jQuery @@ -666,7 +676,7 @@ jQuery.fn = jQuery.prototype = { * @name add * @type jQuery * @param Array els An array of Elements to add - * @cat jQuery + * @cat DOM/Traversing */ /** @@ -680,7 +690,7 @@ jQuery.fn = jQuery.prototype = { * @name add * @type jQuery * @param Element el An Element to add - * @cat jQuery + * @cat DOM/Traversing */ add: function(t) { return this.pushStack( jQuery.merge( this, t.constructor == String ? @@ -695,7 +705,7 @@ jQuery.fn = jQuery.prototype = { * @member jQuery * @param {String} expr The expression with which to filter * @type Boolean - * @cat jQuery + * @cat DOM/Traversing */ is: function(expr) { return expr ? jQuery.filter(expr,this).r.length > 0 : this.length > 0; @@ -1016,6 +1026,7 @@ jQuery.extend({ odd: "i%2", // Child Checks + "nth-child": "jQuery.sibling(a,m[3]).cur", "first-child": "jQuery.sibling(a,0).cur", "last-child": "jQuery.sibling(a,0).last", "only-child": "jQuery.sibling(a).length==1", @@ -1099,7 +1110,7 @@ jQuery.extend({ * @test t( "Adjacent", "p + p", ["ap","en","sap"] ); * @test t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] ); * @test t( "First Child", "p:first-child", ["firstp","sndp"] ); - * @test t( "Attribute Exists", "a[@title]", ["google"] ); + * @test t( "Attribute Exists", "a[@title]", ["google"] ); * @test t( "Attribute Exists", "*[@title]", ["google"] ); * @test t( "Attribute Exists", "[@title]", ["google"] ); * @test t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] ); @@ -1188,6 +1199,8 @@ jQuery.extend({ var foundToken = false; for ( var i = 0; i < jQuery.token.length; i += 2 ) { + if ( foundToken ) continue; + var re = new RegExp("^(" + jQuery.token[i] + ")"); var m = re.exec(t); @@ -1224,8 +1237,9 @@ jQuery.extend({ ); } } - } + } + if ( t ) { var val = jQuery.filter(t,r); ret = r = val.r; @@ -1256,7 +1270,9 @@ jQuery.extend({ "class": "className", "float": "cssFloat", innerHTML: "innerHTML", - className: "className" + className: "className", + value: "value", + disabled: "disabled" }; if ( fix[name] ) { @@ -2201,7 +2217,7 @@ jQuery.macros = { /** * Get a set of elements containing the unique ancestors of the matched - * set of elements. + * set of elements (except for the root element). * * @example $("span").ancestors() * @before

Hello

Hello Again
@@ -2229,7 +2245,7 @@ jQuery.macros = { /** * Get a set of elements containing the unique ancestors of the matched - * set of elements. + * set of elements (except for the root element). * * @example $("span").ancestors() * @before

Hello

Hello Again
@@ -2374,7 +2390,7 @@ jQuery.macros = { * @param String expr An expression to filter the child Elements with * @cat DOM/Traversing */ - children: "a.childNodes" + children: "jQuery.sibling(a.firstChild)" }, each: { @@ -2540,7 +2556,7 @@ jQuery.macros = { * @cat DOM/Manipulation */ remove: function(a){ - if ( !a || jQuery.filter( [this], a ).r ) + if ( !a || jQuery.filter( a, [this] ).r ) this.parentNode.removeChild( this ); }, @@ -2655,4 +2671,4 @@ jQuery.macros = { } }; -jQuery.init(); \ No newline at end of file +jQuery.init();