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

Marshalling nested JS Date to rb Time not working #121

Open
kliuless opened this issue Dec 5, 2018 · 5 comments
Open

Marshalling nested JS Date to rb Time not working #121

kliuless opened this issue Dec 5, 2018 · 5 comments
Labels

Comments

@kliuless
Copy link

kliuless commented Dec 5, 2018

Related to #12

require 'bundler/inline'
gemfile do
  gem 'mini_racer', '= 0.2.4'
end

ctx = MiniRacer::Context.new
ctx.eval( <<~JSEVAL )
  var extractDate = (nestedObj) => nestedObj.abc[0].constructor.name;
JSEVAL

# PASS: returns "Date" (rb => js conversion happens even when `Time` is nested)
p ctx.call('extractDate', {abc: [Time.now]})

# PASS: returns `Time` (js => rb conversion happens when a `Date` isn't nested)
p ctx.eval(%q|new Date()|).class

# FAIL: returns `String` (js => rb conversion doesn't happen for nested `Date`s)
p ctx.eval(%q|( {abc: new Date()} )|)['abc'].class
@SamSaffron
Copy link
Collaborator

@seanmakesgames can you have a look?

@seanmakesgames
Copy link
Contributor

yeah. I can take a look.

@seanmakesgames
Copy link
Contributor

Sorry for the lack of comms on this one. It's been a full couple weeks. I was able to take a look at it, looks like this case is traveling down a different code path which I'm less familiar with and so need some more time to dig through it. In the meantime, if you marshal it with a proc, it should work as expected. (you can take a look at https://github.com/discourse/mini_racer/blob/master/test/mini_racer_test.rb#L214 for an example)

Not sure if that works for you, but worth a shot. :)

@kliuless
Copy link
Author

No rush - this probably isn't something I'll need in the near future. I discovered the issue because I'm using the rb => js nested conversion (which works perfectly), and was curious to see whether it worked in the other direction.

@tisba tisba added the bug label May 30, 2023
@tisba
Copy link
Collaborator

tisba commented May 30, 2023

Might be related to #136

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

No branches or pull requests

4 participants