diff --git a/ipywidgets b/ipywidgets new file mode 160000 index 0000000000..511663a563 --- /dev/null +++ b/ipywidgets @@ -0,0 +1 @@ +Subproject commit 511663a56324cea5324f49a65ebe25e2f1b04d87 diff --git a/packages/base/src/widget.ts b/packages/base/src/widget.ts index cfea6ef8fe..743b0365a8 100644 --- a/packages/base/src/widget.ts +++ b/packages/base/src/widget.ts @@ -34,12 +34,6 @@ import { KernelMessage } from '@jupyterlab/services'; */ const IPY_MODEL_ = 'IPY_MODEL_'; -/** - * A best-effort method for performing deep copies. - */ -const deepcopyJSON = (x: JSONValue) => JSON.parse(JSON.stringify(x)); - -const deepcopy = globalThis.structuredClone || deepcopyJSON; /** * Replace model ids with models recursively. @@ -577,13 +571,14 @@ export class WidgetModel extends Backbone.Model { if (serialize == null && keySerializers.deserialize === unpack_models) { // handle https://github.com/jupyter-widgets/ipywidgets/issues/3735 - serialize = deepcopyJSON; + serialize = JSONExt.deepCopy; } if (serialize) { state[k] = serialize(state[k], this); } else { // the default serializer just deep-copies the object + const deepcopy = globalThis.structuredClone || JSONExt.deepCopy; state[k] = deepcopy(state[k]); }