aboutsummaryrefslogtreecommitdiffstats
path: root/src/manipulation.js
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2011-02-23 13:18:44 -0500
committerjeresig <jeresig@gmail.com>2011-02-23 13:18:44 -0500
commit292acd97a226ec15af2adc069d02973d59c6bc59 (patch)
tree1226999ac7d6c8a549105ace2930478cacdb9006 /src/manipulation.js
parent3663836b0180f3a73d96ec234d5d7010e5652a4b (diff)
downloadjquery-292acd97a226ec15af2adc069d02973d59c6bc59.tar.gz
jquery-292acd97a226ec15af2adc069d02973d59c6bc59.zip
Make a new jQuery.support.noCloneChecked - splitting apart the previous feature detect relating to clone in IE, fixes the last remaining issue with IE 9 RC. Fixes #8365.
Diffstat (limited to 'src/manipulation.js')
-rw-r--r--src/manipulation.js34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index cd0732c3c..ba3169715 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -489,6 +489,18 @@ jQuery.each({
};
});
+function getAll( elem ) {
+ if ( "getElementsByTagName" in elem ) {
+ return elem.getElementsByTagName( "*" );
+
+ } else if ( "querySelectorAll" in elem ) {
+ return elem.querySelectorAll( "*" );
+
+ } else {
+ return [];
+ }
+}
+
jQuery.extend({
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var clone = elem.cloneNode(true),
@@ -496,7 +508,8 @@ jQuery.extend({
destElements,
i;
- if ( !jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
+ if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
+ (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
// IE copies events bound via attachEvent when using cloneNode.
// Calling detachEvent on the clone will also remove the events
// from the original. In order to get around this, we use some
@@ -507,8 +520,8 @@ jQuery.extend({
// Using Sizzle here is crazy slow, so we use getElementsByTagName
// instead
- srcElements = elem.getElementsByTagName("*");
- destElements = clone.getElementsByTagName("*");
+ srcElements = getAll( elem );
+ destElements = getAll( clone );
// Weird iteration because IE will replace the length property
// with an element if you are cloning the body and one of the
@@ -520,21 +533,18 @@ jQuery.extend({
// Copy the events from the original to the clone
if ( dataAndEvents ) {
-
cloneCopyEvent( elem, clone );
- if ( deepDataAndEvents && "getElementsByTagName" in elem ) {
-
- srcElements = elem.getElementsByTagName("*");
- destElements = clone.getElementsByTagName("*");
+ if ( deepDataAndEvents ) {
+ srcElements = getAll( elem );
+ destElements = getAll( clone );
- if ( srcElements.length ) {
- for ( i = 0; srcElements[i]; ++i ) {
- cloneCopyEvent( srcElements[i], destElements[i] );
- }
+ for ( i = 0; srcElements[i]; ++i ) {
+ cloneCopyEvent( srcElements[i], destElements[i] );
}
}
}
+
// Return the cloned set
return clone;
},