diff options
author | Sumit <srivassumit@gmail.com> | 2017-05-14 01:44:14 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2017-05-15 18:15:38 -0400 |
commit | 3ca89204ffcdcabcf7bb1a343497bdae860c72b2 (patch) | |
tree | bb775040dde9f58f5ad424e39f10eda8ebbb4f1b /components/script/dom/attr.rs | |
parent | fa251ec96b445b9ba8439d76e05870a88c2caa0f (diff) | |
download | servo-3ca89204ffcdcabcf7bb1a343497bdae860c72b2.tar.gz servo-3ca89204ffcdcabcf7bb1a343497bdae860c72b2.zip |
Mutation Observer API
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r-- | components/script/dom/attr.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 3c775ffdf57..af5f0107ae4 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -10,6 +10,8 @@ use dom::bindings::js::{LayoutJS, MutNullableJS, Root, RootedReference}; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::element::{AttributeMutation, Element}; +use dom::mutationobserver::{Mutation, MutationObserver}; +use dom::node::Node; use dom::virtualmethods::vtable_for; use dom::window::Window; use dom_struct::dom_struct; @@ -170,6 +172,12 @@ impl AttrMethods for Attr { impl Attr { pub fn set_value(&self, mut value: AttrValue, owner: &Element) { + let name = self.local_name().clone(); + let namespace = self.namespace().clone(); + let old_value = DOMString::from(&**self.value()); + let mutation = Mutation::Attribute { name, namespace, old_value }; + MutationObserver::queue_a_mutation_record(owner.upcast::<Node>(), mutation); + assert!(Some(owner) == self.owner().r()); owner.will_mutate_attr(self); self.swap_value(&mut value); |