Skip to content

Commit ac64a2a

Browse files
fix: use old JSON clone instead of children: pack_models
1 parent 8a9f9cf commit ac64a2a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/base/src/widget.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ const IPY_MODEL_ = 'IPY_MODEL_';
3737
/**
3838
* A best-effort method for performing deep copies.
3939
*/
40-
const deepcopy =
41-
globalThis.structuredClone || ((x: any) => JSON.parse(JSON.stringify(x)));
40+
const deepcopyJSON = (x: JSONValue) => JSON.parse(JSON.stringify(x));
41+
42+
const deepcopy = globalThis.structuredClone || deepcopyJSON;
4243

4344
/**
4445
* Replace model ids with models recursively.
@@ -572,7 +573,7 @@ export class WidgetModel extends Backbone.Model {
572573

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

578579
if (serialize) {

0 commit comments

Comments
 (0)