},
domManip: function( args, table, callback ) {
- var results, first, value = args[0], scripts = [];
+ var results, first, value = args[0], scripts = [], fragment;
// We can't cloneNode fragments that contain checked, in WebKit
if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
} else {
results = buildFragment( args, this, scripts );
}
-
- first = results.fragment.firstChild;
+
+ fragment = results.fragment;
+
+ if ( fragment.childNodes.length === 1 ) {
+ first = fragment = fragment.firstChild;
+ } else {
+ first = fragment.firstChild;
+ }
if ( first ) {
table = table && jQuery.nodeName( first, "tr" );
table ?
root(this[i], first) :
this[i],
- results.cacheable || this.length > 1 || i > 0 ?
- results.fragment.cloneNode(true) :
- results.fragment
+ i > 0 || results.cacheable || this.length > 1 ?
+ fragment.cloneNode(true) :
+ fragment
);
}
}
- if ( scripts ) {
+ if ( scripts.length ) {
jQuery.each( scripts, evalScript );
}
}