diff options
author | timmywil <timmywillisn@gmail.com> | 2011-11-08 09:48:44 -0500 |
---|---|---|
committer | timmywil <timmywillisn@gmail.com> | 2011-11-08 09:48:57 -0500 |
commit | f0e43fad376830437a3607ccc146635b8dfb4e83 (patch) | |
tree | af71ddd6e79f45539d4e1e42d30d77df899b263e | |
parent | 95cd2009f69b666efbf42f99ee0e586503575739 (diff) | |
download | jquery-f0e43fad376830437a3607ccc146635b8dfb4e83.tar.gz jquery-f0e43fad376830437a3607ccc146635b8dfb4e83.zip |
Refactor clone a bit to only create one clone on any given codepath
-rw-r--r-- | src/manipulation.js | 10 | ||||
-rw-r--r-- | test/unit/manipulation.js | 4 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index 00f417226..9baa04203 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -578,7 +578,10 @@ jQuery.extend({ var srcElements, destElements, i, - clone = elem.cloneNode( true ); + // IE<=8 does not properly clone detached, unknown element nodes + clone = jQuery.support.html5Clone || !rnoshimcache.test( "<" + elem.nodeName ) ? + elem.cloneNode( true ) : + shimCloneNode( elem ); if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { @@ -588,11 +591,6 @@ jQuery.extend({ // proprietary methods to clear the events. Thanks to MooTools // guys for this hotness. - // IE<=8 does not properly clone detached, unknown element nodes - if ( rnoshimcache.test( "<" + elem.nodeName ) ) { - clone = shimCloneNode( elem ); - } - cloneFixAttributes( elem, clone ); // Using Sizzle here is crazy slow, so we use getElementsByTagName instead diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index fa285030f..1f0288540 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -28,10 +28,10 @@ var testText = function(valueObj) { // Blackberry 4.6 doesn't maintain comments in the DOM equal( jQuery("#nonnodes")[0].childNodes.length < 3 ? 8 : j[2].nodeType, 8, "Check node,textnode,comment with text()" ); -} +}; test("text(String)", function() { - testText(bareObj) + testText(bareObj); }); test("text(Function)", function() { |