Commit 388a00fe authored by jeresig's avatar jeresig

Skip around inserting a fragment when possible (insert the node directly).

parent b8076a91
...@@ -296,7 +296,7 @@ jQuery.fn.extend({ ...@@ -296,7 +296,7 @@ jQuery.fn.extend({
}, },
domManip: function( args, table, callback ) { 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 // We can't cloneNode fragments that contain checked, in WebKit
if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) { if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
...@@ -321,7 +321,13 @@ jQuery.fn.extend({ ...@@ -321,7 +321,13 @@ jQuery.fn.extend({
results = buildFragment( args, this, scripts ); 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 ) { if ( first ) {
table = table && jQuery.nodeName( first, "tr" ); table = table && jQuery.nodeName( first, "tr" );
...@@ -331,14 +337,14 @@ jQuery.fn.extend({ ...@@ -331,14 +337,14 @@ jQuery.fn.extend({
table ? table ?
root(this[i], first) : root(this[i], first) :
this[i], this[i],
results.cacheable || this.length > 1 || i > 0 ? i > 0 || results.cacheable || this.length > 1 ?
results.fragment.cloneNode(true) : fragment.cloneNode(true) :
results.fragment fragment
); );
} }
} }
if ( scripts ) { if ( scripts.length ) {
jQuery.each( scripts, evalScript ); jQuery.each( scripts, evalScript );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment