Mutation Observer API

This commit is contained in:
Sumit 2017-05-14 01:44:14 -04:00 committed by Josh Matthews
parent fa251ec96b
commit 3ca89204ff
15 changed files with 432 additions and 180 deletions

View file

@ -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);