Skip to content

Commit

Permalink
Restoring node dirty calls after properties are set to trigger mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
craftytrickster authored and SimonSapin committed May 25, 2016
1 parent 8b39260 commit ff5cfb1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions components/script/dom/cssstyledeclaration.rs
Expand Up @@ -10,7 +10,7 @@ use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::element::{Element, StylePriority};
use dom::node::{Node, window_from_node};
use dom::node::{Node, NodeDamage, window_from_node};
use dom::window::Window;
use std::ascii::AsciiExt;
use std::cell::Ref;
Expand Down Expand Up @@ -246,6 +246,8 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// Step 9
element.update_inline_style(declarations, priority);

let node = element.upcast::<Node>();
node.dirty(NodeDamage::NodeStyleDamaged);
Ok(())
}

Expand Down Expand Up @@ -278,6 +280,8 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
None => element.set_inline_style_property_priority(&[&*property], priority),
}

let node = element.upcast::<Node>();
node.dirty(NodeDamage::NodeStyleDamaged);
Ok(())
}

Expand All @@ -299,19 +303,22 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// Step 3
let value = self.GetPropertyValue(property.clone());

let elem = self.owner.upcast::<Element>();
let element = self.owner.upcast::<Element>();

match Shorthand::from_name(&property) {
// Step 4
Some(shorthand) => {
for longhand in shorthand.longhands() {
elem.remove_inline_style_property(longhand)
element.remove_inline_style_property(longhand)
}
}
// Step 5
None => elem.remove_inline_style_property(&property),
None => element.remove_inline_style_property(&property),
}

let node = element.upcast::<Node>();
node.dirty(NodeDamage::NodeStyleDamaged);

// Step 6
Ok(value)
}
Expand Down

0 comments on commit ff5cfb1

Please sign in to comment.