This is because structuredClone throws an error for functions: https://web.dev/structured-clone/#features-and-limitations. While the article mentions drawbacks for using JSON.parse(JSON.stringify(...)), I believe that this component does not produce any non-primitive properties, so this is a valid strategy for removing offending properties.
Tested by placing a breakpoint and testing directly on the browser and then building a local ipyleaflet in Jupyter Lab.
Fixes #1119 1119
The main issue is that a
style()
function is added to the GeoJSON objectstyle
property increate_obj()
, which triggers an error when thedata
attribute is serialized here: https://github.com/jupyter-widgets/ipywidgets/blob/e1718c2b3bf0b143580ef87f71c55fbc6ed50a77/packages/base/src/widget.ts#L587This is because
structuredClone
throws an error for functions: https://web.dev/structured-clone/#features-and-limitations. While the article mentions drawbacks for usingJSON.parse(JSON.stringify(...))
, I believe that this component does not produce any non-primitive properties, so this is a valid strategy for removing offending properties.Tested by placing a breakpoint and testing directly on the browser and then building a local ipyleaflet in Jupyter Lab.