@@ -22,6 +22,8 @@ var plots = module.exports = {};
2222var animationAttrs = require ( './animation_attributes' ) ;
2323var frameAttrs = require ( './frame_attributes' ) ;
2424
25+ var relinkPrivateKeys = Lib . relinkPrivateKeys ;
26+
2527// Expose registry methods on Plots for backward-compatibility
2628Lib . extendFlat ( plots , Registry ) ;
2729
@@ -592,51 +594,6 @@ plots.cleanPlot = function(newFullData, newFullLayout, oldFullData, oldFullLayou
592594 }
593595} ;
594596
595- /**
596- * Relink private _keys and keys with a function value from one container
597- * to the new container.
598- * Relink means copying if object is pass-by-value and adding a reference
599- * if object is pass-by-ref.
600- * This prevents deepCopying massive structures like a webgl context.
601- */
602- function relinkPrivateKeys ( toContainer , fromContainer ) {
603- var isPlainObject = Lib . isPlainObject ,
604- isArray = Array . isArray ;
605-
606- var keys = Object . keys ( fromContainer || { } ) ;
607-
608- for ( var i = 0 ; i < keys . length ; i ++ ) {
609- var k = keys [ i ] ,
610- fromVal = fromContainer [ k ] ,
611- toVal = toContainer [ k ] ;
612-
613- if ( k . charAt ( 0 ) === '_' || typeof fromVal === 'function' ) {
614-
615- // if it already exists at this point, it's something
616- // that we recreate each time around, so ignore it
617- if ( k in toContainer ) continue ;
618-
619- toContainer [ k ] = fromVal ;
620- }
621- else if ( isArray ( fromVal ) && isArray ( toVal ) && isPlainObject ( fromVal [ 0 ] ) ) {
622-
623- // recurse into arrays containers
624- for ( var j = 0 ; j < fromVal . length ; j ++ ) {
625- if ( isPlainObject ( fromVal [ j ] ) && isPlainObject ( toVal [ j ] ) ) {
626- relinkPrivateKeys ( toVal [ j ] , fromVal [ j ] ) ;
627- }
628- }
629- }
630- else if ( isPlainObject ( fromVal ) && isPlainObject ( toVal ) ) {
631-
632- // recurse into objects, but only if they still exist
633- relinkPrivateKeys ( toVal , fromVal ) ;
634-
635- if ( ! Object . keys ( toVal ) . length ) delete toContainer [ k ] ;
636- }
637- }
638- }
639-
640597plots . linkSubplots = function ( newFullData , newFullLayout , oldFullData , oldFullLayout ) {
641598 var oldSubplots = oldFullLayout . _plots || { } ,
642599 newSubplots = newFullLayout . _plots = { } ;
0 commit comments