X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=330e05adceddeddb646740b5e286fd2086cc1381;hb=30dc79f1d0aca3ead3980f890a546bc245feb5d5;hp=554726e3dfbbc7c86c947def5df11aa156ad3eef;hpb=18e330741f7e80aaa38ca700ab8a5884d6e671eb;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 554726e..330e05a 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -162,6 +162,8 @@ var $ = jQuery; * technically, chainable - there really isn't much use for chaining against it. * You can have as many $(document).ready events on your page as you like. * + * See ready(Function) for details about the ready event. + * * @example $(function(){ * // Document is ready * }); @@ -988,33 +990,27 @@ jQuery.fn = jQuery.prototype = { * @private * @name domManip * @param Array args - * @param Boolean table - * @param Number dir + * @param Boolean table Insert TBODY in TABLEs if one is not found. + * @param Number dir If dir<0, process args in reverse order. * @param Function fn The function doing the DOM manipulation. * @type jQuery * @cat Core */ domManip: function(args, table, dir, fn){ - var clone = this.size() > 1; + var clone = this.length > 1; var a = jQuery.clean(args); + if ( dir < 0 ) + a.reverse(); return this.each(function(){ var obj = this; - if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() != "THEAD" ) { - var tbody = this.getElementsByTagName("tbody"); + if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" ) + obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody")); - if ( !tbody.length ) { - obj = document.createElement("tbody"); - this.appendChild( obj ); - } else - obj = tbody[0]; - } + for ( var i=0; i < a.length; i++ ) + fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] ); - for ( var i = ( dir < 0 ? a.length - 1 : 0 ); - i != ( dir < 0 ? dir : a.length ); i += dir ) { - fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] ); - } }); }, @@ -1029,8 +1025,8 @@ jQuery.fn = jQuery.prototype = { * @cat Core */ pushStack: function(a,args) { - var fn = args && args[args.length-1]; - var fn2 = args && args[args.length-2]; + var fn = args && args.length > 1 && args[args.length-1]; + var fn2 = args && args.length > 2 && args[args.length-2]; if ( fn && fn.constructor != Function ) fn = null; if ( fn2 && fn2.constructor != Function ) fn2 = null; @@ -1337,26 +1333,44 @@ jQuery.extend({ return ret; }, - clean: function(a) { + clean: function(a) { var r = []; for ( var i = 0; i < a.length; i++ ) { var arg = a[i]; if ( typeof arg == "string" ) { // Convert html string into DOM nodes // Trim whitespace, otherwise indexOf won't work as expected - var s = jQuery.trim(arg), div = document.createElement("div"), wrap = [0,"",""]; + var s = jQuery.trim(arg), s3 = s.substring(0,3), s6 = s.substring(0,6), + div = document.createElement("div"), wrap = [0,"",""]; - if ( !s.indexOf("", ""]; - else if ( !s.indexOf("", ""]; - else if ( !s.indexOf("", ""]; // tbody auto-inserted - else if ( !s.indexOf("", ""]; + else if ( s3 == " matched above wrap = [3, "", "
"]; // Go to html and back, then peel off extra wrappers div.innerHTML = wrap[1] + s + wrap[2]; while ( wrap[0]-- ) div = div.firstChild; + + // Remove IE's autoinserted from table fragments + if ( jQuery.browser.msie ) { + var tb = null; + // String was a , *may* have spurious + if ( s6 == " or + else if ( wrap[1] == "
" && s.indexOf("= 0 ; --n ) + if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length ) + tb[n].parentNode.removeChild(tb[n]); + } + } + arg = div.childNodes; } @@ -1373,7 +1387,7 @@ jQuery.extend({ expr: { "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()", - "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]", + "#": "a.getAttribute('id')==m[2]", ":": { // Position Checks lt: "i * @result @@ -2464,6 +2472,9 @@ jQuery.macros = { /** * Set the html contents of every matched element. * + * A wrapper for the innerHTML property of DOM elements, therefore + * not available for XML documents. + * * @example $("div").html("new stuff"); * @before
* @result
new stuff