X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fmanipulation.js;h=7500730f9d699b27d63f9f22e0a5462b99b48e5f;hb=61e37d41490aed319a176c6ca7feb95e5505059c;hp=930b3d9b92c97703e1ede4e1234c8ed973dc94ad;hpb=4b70f006f579fba24a882d80ca67f1971dbb4922;p=jquery.git diff --git a/src/manipulation.js b/src/manipulation.js index 930b3d9..7500730 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -1,12 +1,12 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rleadingWhitespace = /^\s+/, rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, - rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, + rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i, rtagName = /<([\w:]+)/, rtbody = /"; }, @@ -32,6 +32,12 @@ if ( !jQuery.support.htmlSerialize ) { jQuery.fn.extend({ text: function( text ) { + if ( jQuery.isFunction(text) ) { + return this.each(function() { + return jQuery(this).text( text.call(this) ); + }); + } + if ( typeof text !== "object" && text !== undefined ) { return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); } @@ -54,7 +60,7 @@ jQuery.fn.extend({ wrap.insertBefore( this[0] ); } - wrap.map(function(){ + wrap.map(function() { var elem = this; while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { @@ -69,27 +75,27 @@ jQuery.fn.extend({ }, wrapInner: function( html ) { - return this.each(function(){ + return this.each(function() { jQuery( this ).contents().wrapAll( html ); }); }, wrap: function( html ) { - return this.each(function(){ + return this.each(function() { jQuery( this ).wrapAll( html ); }); }, unwrap: function() { - return this.parent().each(function(){ + return this.parent().each(function() { if ( !jQuery.nodeName( this, "body" ) ) { jQuery( this ).replaceWith( this.childNodes ); } }).end(); }, - + append: function() { - return this.domManip(arguments, true, function(elem){ + return this.domManip(arguments, true, function( elem ) { if ( this.nodeType === 1 ) { this.appendChild( elem ); } @@ -97,7 +103,7 @@ jQuery.fn.extend({ }, prepend: function() { - return this.domManip(arguments, true, function(elem){ + return this.domManip(arguments, true, function( elem ) { if ( this.nodeType === 1 ) { this.insertBefore( elem, this.firstChild ); } @@ -106,7 +112,7 @@ jQuery.fn.extend({ before: function() { if ( this[0] && this[0].parentNode ) { - return this.domManip(arguments, false, function(elem){ + return this.domManip(arguments, false, function( elem ) { this.parentNode.insertBefore( elem, this ); }); } else if ( arguments.length ) { @@ -118,7 +124,7 @@ jQuery.fn.extend({ after: function() { if ( this[0] && this[0].parentNode ) { - return this.domManip(arguments, false, function(elem){ + return this.domManip(arguments, false, function( elem ) { this.parentNode.insertBefore( elem, this.nextSibling ); }); } else if ( arguments.length ) { @@ -130,7 +136,7 @@ jQuery.fn.extend({ clone: function( events ) { // Do the clone - var ret = this.map(function(){ + var ret = this.map(function() { if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { // IE copies events bound via attachEvent when // using cloneNode. Calling detachEvent on the @@ -198,7 +204,7 @@ jQuery.fn.extend({ replaceWith: function( value ) { if ( this[0] && this[0].parentNode ) { - return this.each(function(){ + return this.each(function() { var next = this.nextSibling, parent = this.parentNode; jQuery(this).remove(); @@ -272,8 +278,8 @@ jQuery.fn.extend({ function cloneCopyEvent(orig, ret) { var i = 0; - ret.each(function(){ - if ( this.nodeName !== orig[i].nodeName ) { + ret.each(function() { + if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) { return; } @@ -281,7 +287,7 @@ function cloneCopyEvent(orig, ret) { }); } -function buildFragment(args, nodes, scripts){ +function buildFragment( args, nodes, scripts ) { var fragment, cacheable, cached, cacheresults, doc; if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf(" or - wrap[1] == "" && !hasBody ? + wrap[1] === "
" && !hasBody ? div.childNodes : [];