Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi: preserve arrays on javascript objects #27

Open
wants to merge 227 commits into
base: master
Choose a base branch
from
Open

ffi: preserve arrays on javascript objects #27

wants to merge 227 commits into from

Conversation

s-cork
Copy link
Owner

@s-cork s-cork commented Oct 15, 2023

Currently when we interop with javascript objects on window
If we get an array, we return a python copy of this array

I've found this to be problematic
We lose mutability
Some javascript libraries do crazy things with arrays
(See below)

When returning an Array from a proxied javascript object
This PR instead returns a ProxyList
Which is very similar to a python list
But, the internal Array is a Proxy of the original Javascript Array
Now we essentially have the same reference and mutating the ProxyList mutates the original list

I've added tests to demonstrate this interopability


Example in an app we had failing:

function(){var analytics=window.analytics=window.analytics||[];//...}

This was from segment.
They used this array as a placeholder while the real window.analytics object was loaded.
It then preceeded to do things like analytics.track=()=>{...}
But interop converted window.analytics to a pure python list so it wasn't possible to use the placeholder in python.


Considerations

Why not two way? i.e. sending a python list to a proxied javascript object should be the same reference as the original python list.
I'm happy to add support for this
But I felt it was less of a concern
It probably wouldn't be too hard

biomedtech and others added 30 commits September 20, 2021 00:53
…-on-specific-module

feat: select module to run unit tests on
make circular import errors work with current import implementation
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
…ing in v8 - tests currently broken on latest version of Node
…nimist-1.2.6

build(deps): bump minimist from 1.2.5 to 1.2.6
…requires constant folding to be fully inline with cpython for -ve numbers
s-cork and others added 26 commits June 6, 2023 12:57
fix not possible for null to be an attribute
Fix lookbehind assertion browser test.
dict: fix setattr should not call mp$ass_subscript on the `__dict__`
Copy link
Owner Author

s-cork commented Oct 15, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants