Avoid calling any listeners for events whose stop propagation flag is set prior to dispatching.

This commit is contained in:
Ms2ger 2015-09-16 14:54:26 +02:00
parent b342dff07d
commit a5925020ce
3 changed files with 8 additions and 10 deletions

View file

@ -13,6 +13,9 @@ use dom::node::Node;
use dom::virtualmethods::vtable_for;
fn dispatch_to_listeners(event: &Event, target: &EventTarget, chain: &[&EventTarget]) {
assert!(!event.stop_propagation());
assert!(!event.stop_immediate());
let type_ = event.Type();
/* capturing */
@ -98,6 +101,11 @@ pub fn dispatch_event(target: &EventTarget, pseudo_target: Option<&EventTarget>,
Some(pseudo_target) => pseudo_target,
None => target.clone(),
});
if event.stop_propagation() {
return !event.DefaultPrevented();
}
event.set_dispatching(true);
//TODO: no chain if not participating in a tree

View file

@ -1,5 +0,0 @@
[stopPropagation.dispatchEvent.html]
type: testharness
[Test Description: If Event.stopPropagation() has been called prior to the dispatch, all phases must be skipped.]
expected: FAIL

View file

@ -1,5 +0,0 @@
[stopPropagation.dispatchEvent.html]
type: testharness
[Test Description: If Event.stopPropagation() has been called prior to the dispatch, all phases must be skipped.]
expected: FAIL