diff --git a/src/jsproxy.c b/src/jsproxy.c index 70def0bea..621d86e9f 100644 --- a/src/jsproxy.c +++ b/src/jsproxy.c @@ -110,6 +110,12 @@ JsProxy_Call(PyObject* o, PyObject* args, PyObject* kwargs) hiwire_decref(idarg); } + if (PyDict_Size(kwargs)) { + int idkwargs = python2js(kwargs); + hiwire_push_array(idargs, idkwargs); + hiwire_decref(idkwargs); + } + int idresult = hiwire_call(self->js, idargs); hiwire_decref(idargs); PyObject* pyresult = js2python(idresult); diff --git a/test/test_python.py b/test/test_python.py index a097324a3..017ab4dd4 100644 --- a/test/test_python.py +++ b/test/test_python.py @@ -342,6 +342,22 @@ def test_jsproxy_implicit_iter(selenium): "list(Object.values(ITER))") == [1, 2, 3] +def test_jsproxy_kwargs(selenium): + selenium.run_js( + """ + window.kwarg_function = ({ a = 1, b = 1 }) => { + return a / b; + }; + """ + ) + assert selenium.run( + """ + from js import kwarg_function + kwarg_function(b = 2, a = 10) + """ + ) == 5 + + def test_open_url(selenium): assert selenium.run( """