File tree Expand file tree Collapse file tree 1 file changed +3
-19
lines changed Expand file tree Collapse file tree 1 file changed +3
-19
lines changed Original file line number Diff line number Diff line change @@ -34,13 +34,6 @@ import { KernelMessage } from '@jupyterlab/services';
3434 */
3535const IPY_MODEL_ = 'IPY_MODEL_' ;
3636
37- /**
38- * A best-effort method for performing deep copies.
39- */
40- const deepcopyJSON = ( x : JSONValue ) => JSON . parse ( JSON . stringify ( x ) ) ;
41-
42- const deepcopy = globalThis . structuredClone || deepcopyJSON ;
43-
4437/**
4538 * Replace model ids with models recursively.
4639 */
@@ -572,21 +565,12 @@ export class WidgetModel extends Backbone.Model {
572565 JSONExt . emptyObject ;
573566 for ( const k of Object . keys ( state ) ) {
574567 try {
575- const keySerializers = serializers [ k ] || JSONExt . emptyObject ;
576- let { serialize } = keySerializers ;
577-
578- if ( serialize == null && keySerializers . deserialize === unpack_models ) {
579- // handle https://github.com/jupyter-widgets/ipywidgets/issues/3735
580- serialize = deepcopyJSON ;
581- }
582-
583- if ( serialize ) {
584- state [ k ] = serialize ( state [ k ] , this ) ;
568+ if ( serializers [ k ] && serializers [ k ] . serialize ) {
569+ state [ k ] = serializers [ k ] . serialize ! ( state [ k ] , this ) ;
585570 } else {
586571 // the default serializer just deep-copies the object
587- state [ k ] = deepcopy ( state [ k ] ) ;
572+ state [ k ] = JSON . parse ( JSON . stringify ( state [ k ] ) ) ;
588573 }
589-
590574 if ( state [ k ] && state [ k ] . toJSON ) {
591575 state [ k ] = state [ k ] . toJSON ( ) ;
592576 }
You can’t perform that action at this time.
0 commit comments