script: Propagate the attribute into the document's element_attr_will_change method.

This commit is contained in:
Emilio Cobos Álvarez 2017-01-26 23:05:29 +01:00
parent 7a9cdbb857
commit d37e6f8c66
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 7 additions and 7 deletions

View file

@ -962,7 +962,7 @@ impl Element {
pub fn push_attribute(&self, attr: &Attr) {
assert!(attr.GetOwnerElement().r() == Some(self));
self.will_mutate_attr();
self.will_mutate_attr(attr);
self.attrs.borrow_mut().push(JS::from_ref(attr));
if attr.namespace() == &ns!() {
vtable_for(self.upcast()).attribute_mutated(attr, AttributeMutation::Set(None));
@ -1088,8 +1088,8 @@ impl Element {
let idx = self.attrs.borrow().iter().position(|attr| find(&attr));
idx.map(|idx| {
self.will_mutate_attr();
let attr = Root::from_ref(&*(*self.attrs.borrow())[idx]);
self.will_mutate_attr(&attr);
self.attrs.borrow_mut().remove(idx);
attr.set_owner(None);
if attr.namespace() == &ns!() {
@ -1227,9 +1227,9 @@ impl Element {
self.set_attribute(local_name, AttrValue::UInt(value.to_string(), value));
}
pub fn will_mutate_attr(&self) {
pub fn will_mutate_attr(&self, attr: &Attr) {
let node = self.upcast::<Node>();
node.owner_doc().element_attr_will_change(self);
node.owner_doc().element_attr_will_change(self, attr);
}
// https://dom.spec.whatwg.org/#insert-adjacent
@ -1502,7 +1502,7 @@ impl ElementMethods for Element {
}
// Step 4.
self.will_mutate_attr();
self.will_mutate_attr(attr);
attr.set_owner(Some(self));
self.attrs.borrow_mut()[position] = JS::from_ref(attr);
old_attr.set_owner(None);