@@ -1326,9 +1326,7 @@ plots.computeFrame = function(gd, frameName) {
13261326 // Merge, starting with the last and ending with the desired frame:
13271327 while ( ( framePtr = frameStack . pop ( ) ) ) {
13281328 if ( framePtr . layout ) {
1329- copy = Lib . extendDeepNoArrays ( { } , framePtr . layout ) ;
1330- expandedObj = Lib . expandObjectPaths ( copy ) ;
1331- result . layout = Lib . extendDeepNoArrays ( result . layout || { } , expandedObj ) ;
1329+ result . layout = plots . extendLayout ( result . layout , framePtr . layout ) ;
13321330 }
13331331
13341332 if ( framePtr . data ) {
@@ -1363,16 +1361,51 @@ plots.computeFrame = function(gd, frameName) {
13631361 result . traces [ destIndex ] = traceIndex ;
13641362 }
13651363
1366- copy = Lib . extendDeepNoArrays ( { } , framePtr . data [ i ] ) ;
1367- expandedObj = Lib . expandObjectPaths ( copy ) ;
1368- result . data [ destIndex ] = Lib . extendDeepNoArrays ( result . data [ destIndex ] || { } , expandedObj ) ;
1364+ try {
1365+ result . data [ destIndex ] = plots . extendTrace ( result . data [ destIndex ] , framePtr . data [ i ] ) ;
1366+ } catch ( e ) {
1367+ console . error ( e ) ;
1368+ }
13691369 }
13701370 }
13711371 }
13721372
13731373 return result ;
13741374} ;
13751375
1376+ plots . extendObjectWithContainers = function ( dest , src , containerPaths ) {
1377+ var copy = Lib . extendDeepNoArrays ( { } , src || { } ) ;
1378+ var expandedObj = Lib . expandObjectPaths ( copy ) ;
1379+
1380+ if ( containerPaths && containerPaths . length ) {
1381+ for ( var i = 0 ; i < containerPaths . length ; i ++ ) {
1382+ var srcProp = Lib . nestedProperty ( src , containerPaths [ i ] ) ;
1383+ var srcVal = srcProp . get ( ) ;
1384+
1385+ console . log ( 'src, containerPaths[i], srcVal:' , src , containerPaths [ i ] , srcVal ) ;
1386+
1387+
1388+ if ( ! srcVal ) continue ;
1389+
1390+ var destProp = Lib . nestedProperty ( src , containerPaths [ i ] ) ;
1391+ var destVal = destProp . get ( ) ;
1392+
1393+
1394+
1395+ }
1396+ }
1397+
1398+ return Lib . extendDeepNoArrays ( dest || { } , expandedObj ) ;
1399+ } ;
1400+
1401+ plots . extendTrace = function ( destTrace , srcTrace ) {
1402+ return plots . extendObjectWithContainers ( destTrace , srcTrace , [ 'transforms' ] ) ;
1403+ } ;
1404+
1405+ plots . extendLayout = function ( destLayout , srcLayout ) {
1406+ return plots . extendObjectWithContainers ( destLayout , srcLayout , [ ] ) ;
1407+ } ;
1408+
13761409/**
13771410 * Transition to a set of new data and layout properties
13781411 *
@@ -1411,16 +1444,7 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)
14111444
14121445 transitionedTraces . push ( traceIdx ) ;
14131446
1414- // This is a multi-step process. First clone w/o arrays so that
1415- // we're not modifying the original:
1416- var update = Lib . extendDeepNoArrays ( { } , data [ i ] ) ;
1417-
1418- // Then expand object paths since we don't obey object-overwrite
1419- // semantics here:
1420- update = Lib . expandObjectPaths ( update ) ;
1421-
1422- // Finally apply the update (without copying arrays, of course):
1423- Lib . extendDeepNoArrays ( gd . data [ traceIndices [ i ] ] , update ) ;
1447+ gd . data [ traceIndices [ i ] ] = plots . extendTrace ( gd . data [ traceIndices [ i ] ] , data [ i ] ) ;
14241448 }
14251449
14261450 // Follow the same procedure. Clone it so we don't mangle the input, then
0 commit comments