]> source.dussan.org Git - jquery.git/commitdiff
Cleaned up; fixes per review
authorrwldrn <waldron.rick@gmail.com>
Thu, 20 Jan 2011 20:25:04 +0000 (15:25 -0500)
committerrwldrn <waldron.rick@gmail.com>
Thu, 20 Jan 2011 20:25:04 +0000 (15:25 -0500)
src/core.js
src/manipulation.js

index f116ef4d10b3e027befc18324eea9fb07a83d858..9af2882d754dfb64040aee072f1f70c8865de6c6 100644 (file)
@@ -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 );
index af71ff62cce50fd9a6471ed3a16d06913b1d64be..d758d803ff2834aba2743a9f6f5fdacf7416b777 100644 (file)
@@ -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] );
                                        }
                                }