Skip to content

Conversation

ledsun
Copy link
Contributor

@ledsun ledsun commented Jul 19, 2023

The following is an example of using Ruby to generate a JavaScript object:

JS.eval 'return new URLSearchParams(location.search)'

In this pull request, you can write

JS.global[:URLSearchParams].new(JS.global[:location][:search])

So when the new method of the JavaScript object is called from Ruby, the constructor of the JavaScript runtime is called.

When the new method of a JavaScript object is called by Ruby, it calls the constructor of the JavaScript runtime.
ledsun added 2 commits July 21, 2023 22:02
We do not want to define a wrapper class like JS::Array to avoid complex type conversion round trips.
Copy link
Member

@kateinoigakukun kateinoigakukun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 3: Thank you for your patience in advance 🙏

It's very close to merging! I added several comments.

Copy link
Member

@kateinoigakukun kateinoigakukun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks a lot

@kateinoigakukun kateinoigakukun enabled auto-merge (rebase) July 22, 2023 08:46
@kateinoigakukun kateinoigakukun merged commit 96447f8 into ruby:main Jul 22, 2023
This was referenced Jul 23, 2023
@ledsun ledsun deleted the create_javascript_object_with_the_new_method branch August 11, 2023 09:06
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.

2 participants