@@ -255,6 +255,15 @@ describe('annotations relayout', function() {
255
255
anno1 = Lib . extendFlat ( annos [ 1 ] ) ,
256
256
anno3 = Lib . extendFlat ( annos [ 3 ] ) ;
257
257
258
+ // store some (unused) private keys and make sure they are copied over
259
+ // correctly during relayout
260
+ var fullAnnos = gd . _fullLayout . annotations ;
261
+ fullAnnos [ 0 ] . _boo = 'hoo' ;
262
+ fullAnnos [ 1 ] . _foo = 'bar' ;
263
+ fullAnnos [ 3 ] . _cheese = [ 'gorgonzola' , 'gouda' , 'gloucester' ] ;
264
+ // this one gets lost
265
+ fullAnnos [ 2 ] . _splat = 'the cat' ;
266
+
258
267
Plotly . relayout ( gd , {
259
268
'annotations[0].text' : 'tortilla' ,
260
269
'annotations[0].x' : 3.45 ,
@@ -266,21 +275,35 @@ describe('annotations relayout', function() {
266
275
. then ( function ( ) {
267
276
expect ( countAnnotations ( ) ) . toEqual ( len ) ;
268
277
278
+ var fullAnnosAfter = gd . _fullLayout . annotations ,
279
+ fullStr = JSON . stringify ( fullAnnosAfter ) ;
280
+
269
281
assertText ( 0 , 'tortilla' ) ;
270
282
anno0 . text = 'tortilla' ;
271
283
expect ( annos [ 0 ] ) . toEqual ( anno0 ) ;
284
+ expect ( fullAnnosAfter [ 0 ] . _boo ) . toBe ( 'hoo' ) ;
285
+
272
286
273
287
assertText ( 1 , 'chips' ) ;
274
288
expect ( annos [ 1 ] ) . toEqual ( { text : 'chips' , x : 1.1 , y : 2.2 } ) ;
289
+ expect ( fullAnnosAfter [ 1 ] . _foo ) . toBeUndefined ( ) ;
275
290
276
291
assertText ( 2 , 'guacamole' ) ;
277
292
anno1 . text = 'guacamole' ;
278
293
expect ( annos [ 2 ] ) . toEqual ( anno1 ) ;
294
+ expect ( fullAnnosAfter [ 2 ] . _foo ) . toBe ( 'bar' ) ;
295
+ expect ( fullAnnosAfter [ 2 ] . _splat ) . toBeUndefined ( ) ;
279
296
280
297
assertText ( 3 , 'lime' ) ;
281
298
anno3 . text = 'lime' ;
282
299
expect ( annos [ 3 ] ) . toEqual ( anno3 ) ;
300
+ expect ( fullAnnosAfter [ 3 ] . _cheese ) . toEqual ( [ 'gorgonzola' , 'gouda' , 'gloucester' ] ) ;
301
+
302
+ expect ( fullStr . indexOf ( '_splat' ) ) . toBe ( - 1 ) ;
303
+ expect ( fullStr . indexOf ( 'the cat' ) ) . toBe ( - 1 ) ;
304
+
283
305
expect ( Loggers . warn ) . not . toHaveBeenCalled ( ) ;
306
+
284
307
} )
285
308
. catch ( failTest )
286
309
. then ( done ) ;
0 commit comments