Commit 528c0f29 authored by Michael Droettboom's avatar Michael Droettboom

Fix #261: Support named arguments when calling a JS function

parent de7dd4be
......@@ -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);
......
......@@ -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(
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment