panel icon indicating copy to clipboard operation
panel copied to clipboard

DOMEvent support for CustomEvent

Open keul opened this issue 3 years ago • 3 comments

See #3708

keul avatar Jul 21 '22 14:07 keul

This seems completely reasonable to me. My only concern here is that detail may contain certain objects which can't be naively serialized to JSON and will therefore error, e.g. Undefined objects are one example that I've frequently seen issues with.

philippjfr avatar Jul 21 '22 15:07 philippjfr

Codecov Report

Merging #3709 (54c5a12) into master (9ca3a47) will increase coverage by 1.51%. The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3709      +/-   ##
==========================================
+ Coverage   81.92%   83.44%   +1.51%     
==========================================
  Files         206      214       +8     
  Lines       28067    31426    +3359     
==========================================
+ Hits        22994    26223    +3229     
- Misses       5073     5203     +130     
Flag Coverage Δ
ui-tests 33.81% <ø> (?)
unitexamples-tests 76.37% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
panel/tests/conftest.py 88.15% <0.00%> (-6.11%) :arrow_down:
panel/io/profile.py 19.07% <0.00%> (-4.33%) :arrow_down:
panel/widgets/player.py 78.57% <0.00%> (-1.14%) :arrow_down:
panel/tests/widgets/test_slider.py 98.89% <0.00%> (-1.11%) :arrow_down:
panel/tests/test_param.py 99.67% <0.00%> (-0.21%) :arrow_down:
panel/pipeline.py 88.71% <0.00%> (-0.06%) :arrow_down:
panel/auth.py 39.34% <0.00%> (ø)
panel/io/admin.py 0.00% <0.00%> (ø)
panel/models/widgets.py 100.00% <0.00%> (ø)
panel/tests/test_depends.py 100.00% <0.00%> (ø)
... and 40 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Jul 21 '22 16:07 codecov[bot]

This seems completely reasonable to me. My only concern here is that detail may contain certain objects which can't be naively serialized to JSON and will therefore error, e.g. Undefined objects are one example that I've frequently seen issues with.

@philippjfr uops, you are right about this. Any suggestion on how to improve? JSON.stringify/JSON.parse would fix this but maybe is not that efficient.

keul avatar Jul 21 '22 17:07 keul

This seems completely reasonable to me. My only concern here is that detail may contain certain objects which can't be naively serialized to JSON and will therefore error, e.g. Undefined objects are one example that I've frequently seen issues with.

@philippjfr uops, you are right about this. Any suggestion on how to improve? JSON.stringify/JSON.parse would fix this but maybe is not that efficient.

@philippjfr I would go for trying to serialize to JSON and abort with a console error in case it fails

keul avatar Aug 22 '22 08:08 keul

@philippjfr I would go for trying to serialize to JSON and abort with a console error in case it fails

This seems reasonable and shouldn't ever be too expensive.

philippjfr avatar Aug 22 '22 14:08 philippjfr

@philippjfr I would go for trying to serialize to JSON and abort with a console error in case it fails

This seems reasonable and shouldn't ever be too expensive.

Hi @philippjfr

I investigated the issue a little more and I misunderstood something. There's no issue on serializing an object using JSON.stringify. For example:

JSON.stringify({aaa: 555, ggg: () => {}, bbb: undefined});
'{"aaa":555}'

But if I use this same value for .detail, a JavaScript error is raised: [object Function] is not serializable. This came from bokeh itself, specifically calling a to_serializable method.

Also: not that this serializer module seems a lot different in the bokeh 3 branch

So: the only way to test detail for being valid is to import this serializer module from bokeh, but to be honest it seems too much to me.

Currently we already have a JavaScript exception with an error message. I would leave this check to bokeh internal.

keul avatar Aug 23 '22 07:08 keul

For now let's just roundtrip it through JSON.stringify and JSON.parse so it drops the unserializable parts.

philippjfr avatar Aug 23 '22 08:08 philippjfr

Thanks for your patience with this one @keul!

philippjfr avatar Aug 23 '22 10:08 philippjfr