diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2013-01-03 20:39:15 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2013-01-03 20:43:01 -0500 |
commit | 445dbd9d95e2df2f3cb454cb20ba3ae7a84e7eaf (patch) | |
tree | c51fe7011a7811287d0b16a7547afe25154c2556 /src/manipulation.js | |
parent | 0d540c3750bd5d702ec5cc425fd4eebd1089fa52 (diff) | |
download | jquery-445dbd9d95e2df2f3cb454cb20ba3ae7a84e7eaf.tar.gz jquery-445dbd9d95e2df2f3cb454cb20ba3ae7a84e7eaf.zip |
Revert data.js rewrite.
Reverts the following commits:
commit f717226b3a44f918eec30b2d59ab257270189bc3
Author: Rick Waldron <waldron.rick@gmail.com>
Date: Mon Dec 31 18:06:38 2012 -0500
Only splice from internal arrays when item actually exists.
commit b9cdc4136b688963d1dc4befb169be02a0216ba9
Author: Rick Waldron <waldron.rick@gmail.com>
Date: Mon Dec 31 16:20:35 2012 -0500
Updates to data.js re-write to pass events and manipulation
commit d1de3000c6d50c298de14fb1ae3381d75c303723
Author: Rick Waldron <waldron.rick@gmail.com>
Date: Mon Dec 31 15:09:45 2012 -0500
2.0: Rewrite data.js
Diffstat (limited to 'src/manipulation.js')
-rw-r--r-- | src/manipulation.js | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index a121ccbc7..9aea16f9d 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -327,7 +327,7 @@ jQuery.fn.extend({ for ( i = 0; i < hasScripts; i++ ) { node = scripts[ i ]; if ( rscriptType.test( node.type || "" ) && - !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { + !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) { if ( node.src ) { // Hope ajax is available... @@ -514,16 +514,20 @@ jQuery.extend({ }, cleanData: function( elems, /* internal */ acceptData ) { - var data, elem, type, + var id, data, elem, type, l = elems.length, i = 0, + internalKey = jQuery.expando, + cache = jQuery.cache, special = jQuery.event.special; for ( ; i < l; i++ ) { elem = elems[ i ]; if ( acceptData || jQuery.acceptData( elem ) ) { - data = data_priv.access( elem ); + + id = elem[ internalKey ]; + data = id && cache[ id ]; if ( data ) { for ( type in data.events ) { @@ -535,12 +539,14 @@ jQuery.extend({ jQuery.removeEvent( elem, type, data.handle ); } } + + // Remove cache only if it was not already removed by jQuery.event.remove + if ( cache[ id ] ) { + delete cache[ id ]; + delete elem[ internalKey ]; + } } } - - // Discard any remaining `private` and `user` data - // (Splices the data objects out of the internal cache arrays) - data_discard( elem ); } } }); @@ -574,45 +580,35 @@ function setGlobalEval( elems, refElements ) { i = 0; for ( ; i < l; i++ ) { - data_priv.set( - elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) - ); + jQuery._data( elems[ i ], "globalEval", !refElements || jQuery._data( refElements[ i ], "globalEval" ) ); } } function cloneCopyEvent( src, dest ) { - var i, l, type, pOld, pCur, uOld, uCur, events; - if ( dest.nodeType !== 1 ) { + if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { return; } - // 1. Copy private data: events, handlers, etc. - if ( data_priv.hasData( src ) ) { - pOld = data_priv.access( src ); - pCur = jQuery.extend( {}, pOld ); - events = pOld.events; + var i, l, type, + oldData = jQuery._data( src ), + curData = jQuery._data( dest, oldData ), + events = oldData.events; - data_priv.set( dest, pCur ); + if ( events ) { + delete curData.handle; + curData.events = {}; - if ( events ) { - delete pCur.handle; - pCur.events = {}; - - for ( type in events ) { - for ( i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type, events[ type ][ i ] ); - } + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); } } } - // 2. Copy user data - if ( data_user.hasData( src ) ) { - uOld = data_user.access( src ); - uCur = jQuery.extend( {}, uOld ); - - data_user.set( dest, uCur ); + // make the cloned public data object a copy from the original + if ( curData.data ) { + curData.data = jQuery.extend( {}, curData.data ); } } |