diff --git a/formatter/src/formatter/element.rs b/formatter/src/formatter/element.rs index 17d066e..51be2b9 100644 --- a/formatter/src/formatter/element.rs +++ b/formatter/src/formatter/element.rs @@ -69,7 +69,7 @@ impl Formatter<'_> { let is_textual = children .first() - .map(|n| matches!(n, Node::Text(_) | Node::Block(_))) + .map(|n| matches!(n, Node::Text(_) | Node::RawText(_) | Node::Block(_))) .unwrap_or_default(); let soft_break = is_textual && attribute_count <= 1; @@ -230,6 +230,12 @@ mod tests { insta::assert_snapshot!(formatted, @r###"
"hello"
"###); } + #[test] + fn child_element_single_textual_unquoted() { + let formatted = format_element_from_string!("
hello
"); + insta::assert_snapshot!(formatted, @r###"
hello
"###); + } + #[test] fn child_element_single_textual_single_attr() { let formatted = format_element! {
"hello"
}; @@ -266,19 +272,13 @@ mod tests { #[test] fn html_unquoted_text() { let formatted = format_element_from_string!(r##"
Unquoted text
"##); - insta::assert_snapshot!(formatted, @r#" -
- Unquoted text -
"#); + insta::assert_snapshot!(formatted, @"
Unquoted text
"); } #[test] fn html_unquoted_text_with_surrounding_spaces() { let formatted = format_element_from_string!(r##"
Unquoted text with spaces
"##); - insta::assert_snapshot!(formatted, @r#" -
- Unquoted text with spaces -
"#); + insta::assert_snapshot!(formatted, @"
Unquoted text with spaces
"); } #[test] diff --git a/formatter/src/source_file.rs b/formatter/src/source_file.rs index f311f4b..92ba5b4 100644 --- a/formatter/src/source_file.rs +++ b/formatter/src/source_file.rs @@ -104,11 +104,7 @@ mod tests { // Valid Rust formatted code #[component] pub(crate) fn Error(cx: Scope, message: Option) -> impl IntoView { - view! { cx, -
- Example -
- } + view! { cx,
Example
} } "###); } @@ -349,9 +345,7 @@ mod tests { fn test2(cx: Scope) -> impl IntoView { let x = view! { cx,
- - Hello - + Hello
}; }