wip: fix styling for ssr
This commit is contained in:
1 parent
6aaad1c9ef
commit
f14d4ef7c2
2 files changed
+48
-6
No files matched your search
+43
-2
@@ -86,9 +86,31 @@ impl<'a> TextRenderer<'a> {
|
||||
}
|
||||
|
||||
write!(f, "<{}", el.tag_name)?;
|
||||
for attr in el.attributes {
|
||||
write!(f, " {}=\"{}\"", attr.name, attr.value)?;
|
||||
let mut attr_iter = el.attributes.iter().peekable();
|
||||
|
||||
while let Some(attr) = attr_iter.next() {
|
||||
match attr.namespace {
|
||||
None => write!(f, " {}=\"{}\"", attr.name, attr.value)?,
|
||||
|
||||
Some(ns) => {
|
||||
// write the opening tag
|
||||
write!(f, " {}=\"", ns)?;
|
||||
let mut cur_ns_el = attr;
|
||||
'ns_parse: loop {
|
||||
write!(f, "{}:{};", cur_ns_el.name, cur_ns_el.value)?;
|
||||
match attr_iter.peek() {
|
||||
Some(next_attr) if next_attr.namespace == Some(ns) => {
|
||||
cur_ns_el = attr_iter.next().unwrap();
|
||||
}
|
||||
_ => break 'ns_parse,
|
||||
}
|
||||
}
|
||||
// write the closing tag
|
||||
write!(f, "\"")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match self.cfg.newline {
|
||||
true => write!(f, ">\n")?,
|
||||
false => write!(f, ">")?,
|
||||
@@ -224,4 +246,23 @@ mod tests {
|
||||
file.write_fmt(format_args!("{}", TextRenderer::new(&dom)))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn styles() {
|
||||
const STLYE_APP: FC<()> = |cx| {
|
||||
//
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
style: {
|
||||
color: "blue",
|
||||
font_size: "46px"
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let mut dom = VirtualDom::new(STLYE_APP);
|
||||
dom.rebuild_in_place().expect("failed to run virtualdom");
|
||||
dbg!(render_root(&dom));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user