File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -524,6 +524,8 @@ export class WidgetModel extends Backbone.Model {
524
524
* binary array buffers.
525
525
*/
526
526
serialize ( state : Dict < any > ) : JSONObject {
527
+ const deepcopy =
528
+ globalThis . structuredClone || ( x : any ) => JSON . parse ( JSON . stringify ( x ) ) ;
527
529
const serializers =
528
530
( this . constructor as typeof WidgetModel ) . serializers || { } ;
529
531
for ( const k of Object . keys ( state ) ) {
@@ -532,7 +534,7 @@ export class WidgetModel extends Backbone.Model {
532
534
state [ k ] = serializers [ k ] . serialize ! ( state [ k ] , this ) ;
533
535
} else {
534
536
// the default serializer just deep-copies the object
535
- state [ k ] = JSON . parse ( JSON . stringify ( state [ k ] ) ) ;
537
+ state [ k ] = deepcopy ( state [ k ] ) ;
536
538
}
537
539
if ( state [ k ] && state [ k ] . toJSON ) {
538
540
state [ k ] = state [ k ] . toJSON ( ) ;
You can’t perform that action at this time.
0 commit comments