aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlbodyelement.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2015-11-07 17:56:16 -0500
committerJosh Matthews <josh@joshmatthews.net>2015-11-12 16:21:24 -0500
commit2340583e56a7a67dc3d15dcd2673670255694b59 (patch)
tree07d8bfe396a846575cf6d3dce3c2179b43a5010f /components/script/dom/htmlbodyelement.rs
parentb40882093a306032d38ad02e30f0095e0a49ec21 (diff)
downloadservo-2340583e56a7a67dc3d15dcd2673670255694b59.tar.gz
servo-2340583e56a7a67dc3d15dcd2673670255694b59.zip
Differentiate between error and non-error event handlers per the spec.
Diffstat (limited to 'components/script/dom/htmlbodyelement.rs')
-rw-r--r--components/script/dom/htmlbodyelement.rs29
1 files changed, 19 insertions, 10 deletions
diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index 80c3098e62f..a3c53071134 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -153,34 +153,43 @@ impl VirtualMethods for HTMLBodyElement {
}
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
- self.super_type().unwrap().attribute_mutated(attr, mutation);
- match (attr.local_name(), mutation) {
+ let do_super_mutate = match (attr.local_name(), mutation) {
(&atom!(background), _) => {
*self.background.borrow_mut() = mutation.new_value(attr).and_then(|value| {
let document = document_from_node(self);
let base = document.url();
UrlParser::new().base_url(&base).parse(&value).ok()
});
+ true
},
(name, AttributeMutation::Set(_)) if name.starts_with("on") => {
let window = window_from_node(self);
let (cx, url, reflector) = (window.get_cx(),
window.get_url(),
window.reflector().get_jsobject());
- let evtarget = match name {
+ // https://html.spec.whatwg.org/multipage/
+ // #event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-3
+ match name {
&atom!(onfocus) | &atom!(onload) | &atom!(onscroll) | &atom!(onafterprint) |
&atom!(onbeforeprint) | &atom!(onbeforeunload) | &atom!(onhashchange) |
&atom!(onlanguagechange) | &atom!(onmessage) | &atom!(onoffline) | &atom!(ononline) |
&atom!(onpagehide) | &atom!(onpageshow) | &atom!(onpopstate) | &atom!(onstorage) |
&atom!(onresize) | &atom!(onunload) | &atom!(onerror)
- => window.upcast::<EventTarget>(), // forwarded event
- _ => self.upcast::<EventTarget>(),
- };
- evtarget.set_event_handler_uncompiled(cx, url, reflector,
- &name[2..],
- DOMString((**attr.value()).to_owned()));
+ => {
+ let evtarget = window.upcast::<EventTarget>(); // forwarded event
+ evtarget.set_event_handler_uncompiled(cx, url, reflector,
+ &name[2..],
+ DOMString((**attr.value()).to_owned()));
+ false
+ }
+ _ => true, // HTMLElement::attribute_mutated will take care of this.
+ }
},
- _ => {}
+ _ => true,
+ };
+
+ if do_super_mutate {
+ self.super_type().unwrap().attribute_mutated(attr, mutation);
}
}
}