Skip to content

Commit 2ac7708

Browse files
Initial pass at appending style
1 parent 9118b64 commit 2ac7708

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

components/script/dom/element.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! Element nodes.
66
77
use app_units::Au;
8+
use core::ops::Deref;
89
use cssparser::Color;
910
use devtools_traits::AttrInfo;
1011
use dom::activation::Activatable;
@@ -670,6 +671,30 @@ impl Element {
670671
pub fn update_inline_style(&self,
671672
property_decl: PropertyDeclaration,
672673
style_priority: StylePriority) {
674+
675+
let style_to_append = format!("{}: {}; ", property_decl.name(), property_decl.value());
676+
if let Some(style_attr) = self.attrs.borrow().iter().find(|a| a.name() == &atom!("style")) {
677+
let mut style_string = DOMString::from(style_attr.deref().value().deref().deref());
678+
style_string.push_str(&style_to_append);
679+
680+
let new_value = AttrValue::String(style_string);
681+
style_attr.set_value(new_value, self);
682+
}
683+
else {
684+
let style_string = DOMString::from_string(style_to_append);
685+
let window = window_from_node(self);
686+
687+
let attr = Attr::new(&window,
688+
atom!("style"),
689+
AttrValue::String(style_string),
690+
atom!("style"),
691+
ns!(),
692+
Some(atom!("style")),
693+
Some(self));
694+
695+
self.attrs.borrow_mut().push(JS::from_rooted(&attr));
696+
}
697+
673698
let mut inline_declarations = self.style_attribute().borrow_mut();
674699
if let &mut Some(ref mut declarations) = &mut *inline_declarations {
675700
let existing_declarations = if style_priority == StylePriority::Important {

0 commit comments

Comments
 (0)