diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2024-01-22 22:13:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 22:13:23 -0500 |
commit | 805cdb43fd02c3a5783c06b5ec2c9519be0682ab (patch) | |
tree | e5a914f0b1ddf5cd18e37d3310b1afe438bdd31a /src/manipulation.js | |
parent | af79c99939628255f46f30bced000eba9aa6711f (diff) | |
download | jquery-805cdb43fd02c3a5783c06b5ec2c9519be0682ab.tar.gz jquery-805cdb43fd02c3a5783c06b5ec2c9519be0682ab.zip |
Data: Refactor to reduce size
* Return the new value from `set(owner, key, value)`.
* Use `set(owner, key, value)` rather than `access(owner, key, value)`.
Close gh-5392
Diffstat (limited to 'src/manipulation.js')
-rw-r--r-- | src/manipulation.js | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index c4bda4b5a..41cb8eadb 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -35,34 +35,26 @@ function manipulationTarget( elem, content ) { } function cloneCopyEvent( src, dest ) { - var i, l, type, pdataOld, udataOld, udataCur, events; + var type, i, l, + events = dataPriv.get( src, "events" ); if ( dest.nodeType !== 1 ) { return; } // 1. Copy private data: events, handlers, etc. - if ( dataPriv.hasData( src ) ) { - pdataOld = dataPriv.get( src ); - events = pdataOld.events; - - if ( events ) { - dataPriv.remove( dest, "handle events" ); - - for ( type in events ) { - for ( i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type, events[ type ][ i ] ); - } + if ( events ) { + dataPriv.remove( dest, "handle events" ); + 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 ( dataUser.hasData( src ) ) { - udataOld = dataUser.access( src ); - udataCur = jQuery.extend( {}, udataOld ); - - dataUser.set( dest, udataCur ); + dataUser.set( dest, jQuery.extend( {}, dataUser.get( src ) ) ); } } |