var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/,
- rxhtmlTag = /(<(\w+)[^>]*?)\/>/g,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i,
- rtagName = /<(\w+)/,
+ rtagName = /<([\w:]+)/,
rtbody = /<tbody/i,
rhtml = /</,
fcloseTag = function(all, front, tag){
});
},
+ 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 ) {
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 );
}
},
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;
}
},
// See if we can take a shortcut and just use innerHTML
} else if ( typeof value === "string" && !/<script/i.test( value ) &&
- this[0] && !jQuery.isXMLDoc( this[0] ) &&
+ (!jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- // Remove element nodes and prevent memory leaks
- if ( this[i].nodeType === 1 ) {
- cleanData( this[i].getElementsByTagName("*") );
- this[i].innerHTML = value;
+ try {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( this[i].nodeType === 1 ) {
+ cleanData( this[i].getElementsByTagName("*") );
+ this[i].innerHTML = value;
+ }
}
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {
+ this.empty().append( value );
}
} else {