From b13405bb34bfbb9dd090de71c9dfa1a655286324 Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Thu, 8 Dec 2022 11:01:41 +0100 Subject: [PATCH] Always target the web events at the currentTarget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, when the event bubbles, all of the events are targeted at the 'target', which is not the behavior we observe in browsers. For an event, the following should happen: - Targeting phase (we don't use this for firing events) - The found target should have its event handler fired - If the event's propagation is not prevented, it should bubble. All of the element's parent elements should get a chance to handle the event. These are called 'currentTarget' and this is therefore the actual element we should run the callback on. Change-Id: I6bf8903431c6dea3097a4582acad22c9a4f12469 Reviewed-by: Morten Johan Sørvig --- src/corelib/platform/wasm/qstdweb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/platform/wasm/qstdweb.cpp b/src/corelib/platform/wasm/qstdweb.cpp index 69ed8fe34f4..3d72481a957 100644 --- a/src/corelib/platform/wasm/qstdweb.cpp +++ b/src/corelib/platform/wasm/qstdweb.cpp @@ -642,7 +642,7 @@ EventCallback::EventCallback(emscripten::val element, const std::string &name, c void EventCallback::activate(emscripten::val event) { - emscripten::val target = event["target"]; + emscripten::val target = event["currentTarget"]; std::string eventName = event["type"].as(); emscripten::val property = target[contextPropertyName(eventName)]; // This might happen when the event bubbles