Implement support for style attributes.

If a style attribute is given for a node, it is parsed and attached to the
Element. When selector matching runs on the Element, the style attribute's
stylesheet is passed in.

Fixes #86.
This commit is contained in:
Jack Moffitt 2013-08-06 14:40:30 -06:00
parent 1337583878
commit 4d71918366
5 changed files with 30 additions and 15 deletions

View file

@ -314,6 +314,13 @@ pub fn parse_html(cx: *JSContext,
do node.as_mut_element |element| {
for tag.attributes.iter().advance |attr| {
element.attrs.push(Attr::new(attr.name.clone(), attr.value.clone()));
if "style" == attr.name {
element.style_attribute = Some(
Stylesheet::from_attribute(
url::from_str("http://www.example.com/").unwrap(),
attr.value));
}
}
}
@ -374,7 +381,6 @@ pub fn parse_html(cx: *JSContext,
}
}
//TODO (Issue #86): handle inline styles ('style' attr)
_ => {}
}