diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index c44cfd4367d..29c3279ad08 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -170,7 +170,7 @@ impl AttrMethods for Attr { impl Attr { pub fn set_value(&self, mut value: AttrValue, owner: &Element) { assert!(Some(owner) == self.owner().r()); - owner.will_mutate_attr(); + owner.will_mutate_attr(self); self.swap_value(&mut value); if self.identifier.namespace == ns!() { vtable_for(owner.upcast()) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 9ae34f52fcf..0af5bdfc83a 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2157,7 +2157,7 @@ impl Document { } } - pub fn element_attr_will_change(&self, el: &Element) { + pub fn element_attr_will_change(&self, el: &Element, _attr: &Attr) { let mut snapshot = self.ensure_snapshot(el); if snapshot.attrs.is_none() { let attrs = el.attrs() diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index f85baf3811e..100d1ea18d0 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -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.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);