Cleaned up; fixes per review

This commit is contained in:
rwldrn 2011-01-20 15:25:04 -05:00
parent 49cd9c66bf
commit 6458885881
2 changed files with 12 additions and 10 deletions

View file

@ -130,7 +130,7 @@ jQuery.fn = jQuery.prototype = {
} else { } else {
ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); 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 ); return jQuery.merge( this, selector );

View file

@ -183,9 +183,12 @@ jQuery.fn.extend({
return this; 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 this.map( function () {
return jQuery.clone( this, events == null ? true : events, deepData == null ? true : deepData ); return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
}); });
}, },
@ -480,8 +483,7 @@ jQuery.each({
}); });
jQuery.extend({ jQuery.extend({
clone: function( elem, dataAndEvents, deepCloneDataAndEvents ) { clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var clone = elem.cloneNode(true), var clone = elem.cloneNode(true),
srcElements, srcElements,
destElements; destElements;
@ -509,17 +511,17 @@ jQuery.extend({
} }
// Copy the events from the original to the clone // 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("*"); srcElements = elem.getElementsByTagName("*");
destElements = clone.getElementsByTagName("*"); destElements = clone.getElementsByTagName("*");
if ( srcElements.length ) { if ( srcElements.length ) {
for ( var i = 0; i < srcElements.length; ++i ) { for ( var i = 0; srcElements[i]; ++i ) {
cloneCopyEvent( srcElements[i], destElements[i] ); cloneCopyEvent( srcElements[i], destElements[i] );
} }
} }