From 55e319aa52eb828a3a4c2298aa75b6d15cfa06f8 Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Wed, 24 Apr 2013 16:07:15 -0400 Subject: Fixes #13815: Ensure each element has its own private data object - Tests by @rwldrn --- src/data.js | 9 +++------ src/manipulation.js | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/data.js b/src/data.js index 0fd35033a..344dae25f 100644 --- a/src/data.js +++ b/src/data.js @@ -90,13 +90,9 @@ Data.prototype = { // Handle: [ owner, { properties } ] args } else { - // Support an expectation from the old data system where plain - // objects used to initialize would be set to the cache by - // reference, instead of having properties and values copied. - // Note, this will kill the connection between - // "this.cache[ unlock ]" and "cache" + // Fresh assignments by object are shallow copied if ( jQuery.isEmptyObject( cache ) ) { - this.cache[ unlock ] = data; + jQuery.extend( this.cache[ unlock ], data ); // Otherwise, copy the properties one-by-one to the cache object } else { for ( prop in data ) { @@ -104,6 +100,7 @@ Data.prototype = { } } } + return cache; }, get: function( owner, key ) { // Either a valid cache is found, or will be created. diff --git a/src/manipulation.js b/src/manipulation.js index e323a10ec..55d6e8510 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -527,11 +527,9 @@ function cloneCopyEvent( src, dest ) { // 1. Copy private data: events, handlers, etc. if ( data_priv.hasData( src ) ) { pdataOld = data_priv.access( src ); - pdataCur = jQuery.extend( {}, pdataOld ); + pdataCur = data_priv.set( dest, pdataOld ); events = pdataOld.events; - data_priv.set( dest, pdataCur ); - if ( events ) { delete pdataCur.handle; pdataCur.events = {}; -- cgit v1.2.3