diff options
author | Corey Frang <gnarf@gnarf.net> | 2011-09-19 16:13:14 -0400 |
---|---|---|
committer | timmywil <timmywillisn@gmail.com> | 2011-09-19 16:13:14 -0400 |
commit | d5f144a7bba98212d6fe9e257f722b62baf651f0 (patch) | |
tree | 6bfa1cb665580a8172abd6b7a6dddeacac9196f0 /src/manipulation.js | |
parent | e4c48a34b4fe687d4a3b935b6c405f502dd0223e (diff) | |
download | jquery-d5f144a7bba98212d6fe9e257f722b62baf651f0.tar.gz jquery-d5f144a7bba98212d6fe9e257f722b62baf651f0.zip |
Landing pull request 500. 1.7 - "public data" stored as a key on "internal data" - Fixes #8921.
More Details:
- https://github.com/jquery/jquery/pull/500
- http://bugs.jquery.com/ticket/8921
Diffstat (limited to 'src/manipulation.js')
-rw-r--r-- | src/manipulation.js | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index 2f41feb9a..35c9544ff 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -356,27 +356,26 @@ function cloneCopyEvent( src, dest ) { return; } - var internalKey = jQuery.expando, - oldData = jQuery.data( src ), - curData = jQuery.data( dest, 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); - - if ( events ) { - delete curData.handle; - curData.events = {}; - - for ( var type in events ) { - for ( var i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); - } + var type, i, l, + oldData = jQuery._data( src ), + curData = jQuery._data( dest, oldData ), + events = oldData.events; + + if ( events ) { + delete curData.handle; + curData.events = {}; + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); } } } + + // make the cloned public data object a copy from the original + if ( curData.data ) { + curData.data = jQuery.extend( {}, curData.data ); + } } function cloneFixAttributes( src, dest ) { @@ -706,7 +705,9 @@ jQuery.extend({ }, cleanData: function( elems ) { - var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special, + var data, id, + cache = jQuery.cache, + special = jQuery.event.special, deleteExpando = jQuery.support.deleteExpando; for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { @@ -717,7 +718,7 @@ jQuery.extend({ id = elem[ jQuery.expando ]; if ( id ) { - data = cache[ id ] && cache[ id ][ internalKey ]; + data = cache[ id ]; if ( data && data.events ) { for ( var type in data.events ) { |