Skip to content

Commit

Permalink
Fix dispatch event in BUBBLING_PHASE
Browse files Browse the repository at this point in the history
As per the standard dispatch event should only invoke the handler if
event's buubles is true:
if event’s bubbles is true, all the object’s inclusive ancestor event listeners whose capture is false are invoked, now in reverse tree order.
https://dom.spec.whatwg.org/#events

Signed-off-by: Francis Bouvier <[email protected]>
  • Loading branch information
francisbouvier committed Jan 18, 2024
1 parent f95a739 commit fa989c7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/events/event_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,13 @@ dom_exception _dom_event_target_dispatch(dom_event_target *et,
if (dom_string_isequal(le->type, evt->type)) {
assert(le->listener->handler != NULL);

if ((le->capture &&
phase == DOM_CAPTURING_PHASE) ||
(le->capture == false &&
phase == DOM_BUBBLING_PHASE) ||
(evt->target == evt->current &&
phase == DOM_AT_TARGET)) {
if ((le->capture &&
phase == DOM_CAPTURING_PHASE) ||
(le->capture == false &&
evt->bubble &&
phase == DOM_BUBBLING_PHASE) ||
(evt->target == evt->current &&
phase == DOM_AT_TARGET)) {
le->listener->handler(evt,
le->listener->pw);
/* If the handler called
Expand Down

0 comments on commit fa989c7

Please sign in to comment.