- var oldData = jQuery.data( orig[i++] ),
- curData = jQuery.data( this, oldData ),
- events = oldData && oldData.events;
+ // XXX remove for 1.5 RC or merge back in if there is actually a reason for this check that has been
+ // unexposed by unit tests
+ if ( this.nodeName !== (orig[nodeIndex] && orig[nodeIndex].nodeName) ) {
+ throw "Cloned data mismatch";
+ }
+
+ var internalKey = jQuery.expando,
+ oldData = jQuery.data( orig[nodeIndex] ),
+ curData = jQuery.data( this, oldData );
+
+ // Switch to use the internal data object, if it exists, for the next
+ // stage of data copying
+ if ( (oldData = oldData[ internalKey ]) ) {
+ var events = oldData.events;
+ curData = curData[ internalKey ] = jQuery.extend({}, oldData);