git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b8076a9
)
Skip around inserting a fragment when possible (insert the node directly).
author
jeresig
<jeresig@gmail.com>
Thu, 28 Jan 2010 22:18:27 +0000
(17:18 -0500)
committer
jeresig
<jeresig@gmail.com>
Thu, 28 Jan 2010 22:18:27 +0000
(17:18 -0500)
src/manipulation.js
patch
|
blob
|
history
diff --git
a/src/manipulation.js
b/src/manipulation.js
index
01c6b0b
..
93950de
100644
(file)
--- a/
src/manipulation.js
+++ b/
src/manipulation.js
@@
-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
if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
// We can't cloneNode fragments that contain checked, in WebKit
if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
@@
-320,8
+320,14
@@
jQuery.fn.extend({
} else {
results = buildFragment( args, this, scripts );
}
} 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" );
if ( first ) {
table = table && jQuery.nodeName( first, "tr" );
@@
-331,14
+337,14
@@
jQuery.fn.extend({
table ?
root(this[i], first) :
this[i],
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 );
}
}
jQuery.each( scripts, evalScript );
}
}