From 48c5e80b3182624fbdeb73def20f5129d6a5a327 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 10 Mar 2024 18:43:32 +0100 Subject: [PATCH] [spidermonkey] handle second argument for Event constructor --- src/ecmascript/spidermonkey/event.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ecmascript/spidermonkey/event.cpp b/src/ecmascript/spidermonkey/event.cpp index bf0713651..c6dbfba17 100644 --- a/src/ecmascript/spidermonkey/event.cpp +++ b/src/ecmascript/spidermonkey/event.cpp @@ -138,6 +138,21 @@ event_constructor(JSContext* ctx, unsigned argc, JS::Value* vp) event->type_ = jsval_to_string(ctx, args[0]); } + if (argc > 1) { + JS::RootedValue v(ctx); + JS::RootedObject v_obj(ctx, &args[1].toObject()); + + if (JS_GetProperty(ctx, v_obj, "bubbles", &v)) { + event->bubbles = (unsigned int)v.toBoolean(); + } + if (JS_GetProperty(ctx, v_obj, "cancelable", &v)) { + event->cancelable = (unsigned int)v.toBoolean(); + } + if (JS_GetProperty(ctx, v_obj, "composed", &v)) { + event->composed = (unsigned int)v.toBoolean(); + } + } + args.rval().setObject(*newObj); return true;