mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
Merge pull request #301 from leptos-rs/ssr-inner-html
Fix SSR of elements with `inner_html`
This commit is contained in:
commit
7eaa36812d
1 changed files with 15 additions and 6 deletions
|
@ -382,24 +382,33 @@ impl View {
|
|||
} else {
|
||||
let tag_name = el.name;
|
||||
|
||||
let mut inner_html = None;
|
||||
|
||||
let attrs = el
|
||||
.attrs
|
||||
.into_iter()
|
||||
.map(|(name, value)| -> Cow<'static, str> {
|
||||
.filter_map(|(name, value)| -> Option<Cow<'static, str>> {
|
||||
if value.is_empty() {
|
||||
format!(" {name}").into()
|
||||
Some(format!(" {name}").into())
|
||||
} else if name == "inner_html" {
|
||||
inner_html = Some(value);
|
||||
None
|
||||
} else {
|
||||
format!(
|
||||
" {name}=\"{}\"",
|
||||
html_escape::encode_double_quoted_attribute(&value)
|
||||
Some(
|
||||
format!(
|
||||
" {name}=\"{}\"",
|
||||
html_escape::encode_double_quoted_attribute(&value)
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
.into()
|
||||
}
|
||||
})
|
||||
.join("");
|
||||
|
||||
if el.is_void {
|
||||
format!("<{tag_name}{attrs}/>").into()
|
||||
} else if let Some(inner_html) = inner_html {
|
||||
format!("<{tag_name}{attrs}>{inner_html}</{tag_name}>").into()
|
||||
} else {
|
||||
let children = el
|
||||
.children
|
||||
|
|
Loading…
Reference in a new issue