Skip to content

Commit bba21d7

Browse files
fix aset js value conversion
1 parent 2016ffd commit bba21d7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ext/js/js-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static VALUE _rb_js_global_this(VALUE _) {
164164
* JS.global[:console][:log]
165165
*/
166166
static VALUE _rb_js_obj_aref(VALUE obj, VALUE key) {
167-
struct jsvalue *p = check_jsvalue(_rb_js_try_convert(rb_mJS, obj));
167+
struct jsvalue *p = check_jsvalue(obj);
168168
rb_js_abi_host_string_t key_abi_str;
169169
key = rb_obj_as_string(key);
170170
rstring_to_abi_string(key, &key_abi_str);
@@ -182,7 +182,7 @@ static VALUE _rb_js_obj_aref(VALUE obj, VALUE key) {
182182
*/
183183
static VALUE _rb_js_obj_aset(VALUE obj, VALUE key, VALUE val) {
184184
struct jsvalue *p = check_jsvalue(obj);
185-
struct jsvalue *v = check_jsvalue(val);
185+
struct jsvalue *v = check_jsvalue(_rb_js_try_convert(rb_mJS, val));
186186
rb_js_abi_host_string_t key_abi_str;
187187
key = rb_obj_as_string(key);
188188
rstring_to_abi_string(key, &key_abi_str);

packages/npm-packages/ruby-wasm-wasi/test/js_from_rb.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ describe("Manipulation of JS from Ruby", () => {
105105
test.each([
106106
{ key: "foo", rvalue: `JS.eval("return 1")`, rvalue_js: 1 },
107107
{ key: "bar", rvalue: `JS.eval("return {}")`, rvalue_js: {} },
108+
{ key: "bar", rvalue: `42`, rvalue_js: 42 },
109+
{ key: "bar", rvalue: `"str"`, rvalue_js: "str" },
108110
])(`JS::Object#[]= (%s)`, async (props) => {
109111
const vm = await initRubyVM();
110112
const result = vm.eval(`

0 commit comments

Comments
 (0)