diff options
author | rwldrn <waldron.rick@gmail.com> | 2011-01-20 15:25:04 -0500 |
---|---|---|
committer | rwldrn <waldron.rick@gmail.com> | 2011-01-20 15:25:04 -0500 |
commit | 6458885881e7badb99c70c24843c31d13064a167 (patch) | |
tree | ee89ed3af44b5516d7ab1bb31c1b86b8cb5ac2e8 | |
parent | 49cd9c66bf6097ced133971a82fa9bd7b2f73e1a (diff) | |
download | jquery-6458885881e7badb99c70c24843c31d13064a167.tar.gz jquery-6458885881e7badb99c70c24843c31d13064a167.zip |
Cleaned up; fixes per review
-rw-r--r-- | src/core.js | 2 | ||||
-rw-r--r-- | src/manipulation.js | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/core.js b/src/core.js index f116ef4d1..9af2882d7 100644 --- a/src/core.js +++ b/src/core.js @@ -130,7 +130,7 @@ jQuery.fn = jQuery.prototype = { } else { ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); - selector = (ret.cacheable ? jQuery(ret.fragment).clone()[0] : ret.fragment).childNodes; + selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; } return jQuery.merge( this, selector ); diff --git a/src/manipulation.js b/src/manipulation.js index af71ff62c..d758d803f 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -183,9 +183,12 @@ jQuery.fn.extend({ return this; }, - clone: function( events, deepData ) { + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? true : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + return this.map( function () { - return jQuery.clone( this, events == null ? true : events, deepData == null ? true : deepData ); + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); }); }, @@ -480,13 +483,12 @@ jQuery.each({ }); jQuery.extend({ - clone: function( elem, dataAndEvents, deepCloneDataAndEvents ) { - + clone: function( elem, dataAndEvents, deepDataAndEvents ) { var clone = elem.cloneNode(true), srcElements, destElements; - if ( !jQuery.support.noCloneEvent && ( elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { + if ( !jQuery.support.noCloneEvent && (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 @@ -509,17 +511,17 @@ jQuery.extend({ } // Copy the events from the original to the clone - if ( dataAndEvents === true ) { + if ( dataAndEvents ) { - cloneCopyEvent( elem , clone ); + cloneCopyEvent( elem, clone ); - if ( deepCloneDataAndEvents === true && "getElementsByTagName" in elem ) { + if ( deepDataAndEvents && "getElementsByTagName" in elem ) { srcElements = elem.getElementsByTagName("*"); destElements = clone.getElementsByTagName("*"); if ( srcElements.length ) { - for ( var i = 0; i < srcElements.length; ++i ) { + for ( var i = 0; srcElements[i]; ++i ) { cloneCopyEvent( srcElements[i], destElements[i] ); } } |