Skip to content

Commit

Permalink
script: Propagate the attribute into the document's element_attr_will…
Browse files Browse the repository at this point in the history
…_change method.
  • Loading branch information
emilio committed Jan 30, 2017
1 parent 7a9cdbb commit d37e6f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/script/dom/attr.rs
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/document.rs
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions components/script/dom/element.rs
Expand Up @@ -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));
Expand Down Expand Up @@ -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!() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d37e6f8

Please sign in to comment.