mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Refactor clone a bit to only create one clone on any given codepath
This commit is contained in:
parent
95cd2009f6
commit
f0e43fad37
@ -578,7 +578,10 @@ jQuery.extend({
|
|||||||
var srcElements,
|
var srcElements,
|
||||||
destElements,
|
destElements,
|
||||||
i,
|
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) &&
|
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
|
||||||
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
||||||
@ -588,11 +591,6 @@ jQuery.extend({
|
|||||||
// proprietary methods to clear the events. Thanks to MooTools
|
// proprietary methods to clear the events. Thanks to MooTools
|
||||||
// guys for this hotness.
|
// 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 );
|
cloneFixAttributes( elem, clone );
|
||||||
|
|
||||||
// Using Sizzle here is crazy slow, so we use getElementsByTagName instead
|
// Using Sizzle here is crazy slow, so we use getElementsByTagName instead
|
||||||
|
@ -28,10 +28,10 @@ var testText = function(valueObj) {
|
|||||||
|
|
||||||
// Blackberry 4.6 doesn't maintain comments in the DOM
|
// 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()" );
|
equal( jQuery("#nonnodes")[0].childNodes.length < 3 ? 8 : j[2].nodeType, 8, "Check node,textnode,comment with text()" );
|
||||||
}
|
};
|
||||||
|
|
||||||
test("text(String)", function() {
|
test("text(String)", function() {
|
||||||
testText(bareObj)
|
testText(bareObj);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("text(Function)", function() {
|
test("text(Function)", function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user