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 {
524524 * binary array buffers.
525525 */
526526 serialize ( state : Dict < any > ) : JSONObject {
527+ const deepcopy =
528+ globalThis . structuredClone || ( ( x : any ) => JSON . parse ( JSON . stringify ( x ) ) ) ;
527529 const serializers =
528530 ( this . constructor as typeof WidgetModel ) . serializers || { } ;
529531 for ( const k of Object . keys ( state ) ) {
@@ -532,7 +534,7 @@ export class WidgetModel extends Backbone.Model {
532534 state [ k ] = serializers [ k ] . serialize ! ( state [ k ] , this ) ;
533535 } else {
534536 // the default serializer just deep-copies the object
535- state [ k ] = JSON . parse ( JSON . stringify ( state [ k ] ) ) ;
537+ state [ k ] = deepcopy ( state [ k ] ) ;
536538 }
537539 if ( state [ k ] && state [ k ] . toJSON ) {
538540 state [ k ] = state [ k ] . toJSON ( ) ;
You can’t perform that action at this time.
0 commit comments