Skip to content

Commit

Permalink
fix: use old JSON clone instead of children: pack_models
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Mar 27, 2023
1 parent 5ad35e1 commit 1c8621a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/base/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ const IPY_MODEL_ = 'IPY_MODEL_';
/**
* A best-effort method for performing deep copies.
*/
const deepcopy =
globalThis.structuredClone || ((x: any) => JSON.parse(JSON.stringify(x)));
const deepcopyJSON = (x: JSONValue) => JSON.parse(JSON.stringify(x));

const deepcopy = globalThis.structuredClone || deepcopyJSON;

/**
* Replace model ids with models recursively.
Expand Down Expand Up @@ -572,7 +573,7 @@ export class WidgetModel extends Backbone.Model {

if (serialize == null && keySerializers.deserialize === unpack_models) {
// handle https://github.com/jupyter-widgets/ipywidgets/issues/3735
serialize = pack_models;
serialize = deepcopyJSON;
}

if (serialize) {
Expand Down

0 comments on commit 1c8621a

Please sign in to comment.