X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fmanipulation.js;h=ef4eb3e09ade88f5e419075ecb2ad6e7b72d4a50;hb=4b5a680f776ee2582e2c1f85b7b0cd9a95254dc3;hp=2a1e9237f4f03c6e4885ba6d2c66671d3e8fa656;hpb=fc4c6915344625fadf55ca25d3cf9094544d301a;p=jquery.git diff --git a/src/manipulation.js b/src/manipulation.js index 2a1e923..ef4eb3e 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -90,6 +90,14 @@ jQuery.fn.extend({ }); }, + unwrap: 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){ if ( this.nodeType === 1 ) { @@ -111,12 +119,10 @@ jQuery.fn.extend({ return this.domManip(arguments, false, function(elem){ this.parentNode.insertBefore( elem, this ); }); - } else { - var set = jQuery.isFunction(arguments[0]) ? - jQuery( arguments[0]() ) : - jQuery.apply(jQuery, arguments); - - return this.pushStack( set.add( this ), "before", arguments ); + } else if ( arguments.length ) { + var set = jQuery(arguments[0]); + set.push.apply( set, this.toArray() ); + return this.pushStack( set, "before", arguments ); } }, @@ -125,10 +131,10 @@ jQuery.fn.extend({ return this.domManip(arguments, false, function(elem){ this.parentNode.insertBefore( elem, this.nextSibling ); }); - } else { - return jQuery.isFunction(arguments[0]) ? - this.add( arguments[0]() ) : - this.add.apply( this, arguments ); + } else if ( arguments.length ) { + var set = this.pushStack( this, "after", arguments ); + set.push.apply( set, jQuery(arguments[0]).toArray() ); + return set; } },