pywebview
pywebview copied to clipboard
New JS API serializer
The old implementation of JS API serializer (plain JSON.stringify
) has a number of limitations. Namely inability to serialize DOM events, nodes or circular references. I have implemented a new serializer that overcomes these limitations. This, in turn, makes possible to add a support for DOM events in Python as proposed here https://github.com/r0x0r/pywebview/discussions/1212
The code for a new serializer is now in ~~master~~ the dom
branch and the actual code can be found here
https://github.com/r0x0r/pywebview/blob/0c62ed819f74cfec5e6ead81008b20ddb8d071f2/webview/js/api.py#L82
As this is quite a big change, I would appreciate feedback and testing, before it makes to the next release. Comments are welcomed.
The new serializer is now used inevaluate_js
as well. Changes also moved from master to the dom
branch and will be released in the next major version.
- Functions are omitted altogether from serialization (previously replaced with a "function" string)
- List like objects (ie. NodeList, FileList) are converted to arrays
- Development moved to the 5.0 branch