mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Use an early return in dispatch_to_listeners.
This commit is contained in:
parent
b7a0440f91
commit
e85b1e4e89
1 changed files with 14 additions and 13 deletions
|
@ -106,9 +106,11 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, chain: &[&EventTar
|
||||||
assert!(!event.stop_immediate());
|
assert!(!event.stop_immediate());
|
||||||
|
|
||||||
/* bubbling */
|
/* bubbling */
|
||||||
if event.bubbles() {
|
if !event.bubbles() {
|
||||||
event.set_phase(EventPhase::Bubbling);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.set_phase(EventPhase::Bubbling);
|
||||||
for cur_target in chain {
|
for cur_target in chain {
|
||||||
if let Some(listeners) = cur_target.get_listeners_for(&type_, ListenerPhase::Bubbling) {
|
if let Some(listeners) = cur_target.get_listeners_for(&type_, ListenerPhase::Bubbling) {
|
||||||
event.set_current_target(cur_target);
|
event.set_current_target(cur_target);
|
||||||
|
@ -126,7 +128,6 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, chain: &[&EventTar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// See https://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm
|
// See https://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm
|
||||||
pub fn dispatch_event(target: &EventTarget, pseudo_target: Option<&EventTarget>,
|
pub fn dispatch_event(target: &EventTarget, pseudo_target: Option<&EventTarget>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue