-
-
Notifications
You must be signed in to change notification settings - Fork 773
Description
Describe the bug
When using unquoted text, extra whitespace is added around some punctuation characters. For example,
view! {
<p>A:B?C.D;E</p>
}
is rendered to <p>A : B ? C.D; E</p>
.
That is:
- Colon and question mark seem to have spaces added either side
- Semicolon has an additional trailing space
- Period has no whitespace added.
I haven't taken the time to find a full list of punctuation where this happens - using quoted text is a fair workaround for me.
I did try to see if this was a bug in rstml and I don't think it is, although I don't have the expertise to know for sure. In my investigation I added this test to rstml/examples/html-to-string-macro/tests/test.rs
and it passes - that is, html!
is not adding extra whitespace.
#[test]
fn basic_test() {
use rstml_to_string_macro::html;
assert_eq!(html!(<div>A:B</div>), "<div>A:B</div>");
}
Like I say though, I don't really understand the workings of either Leptos's view!
or the rstml html!
example macro, so I apologise if I've misunderstood.
Leptos Dependencies
Just the main leptos crate:
[dependencies]
leptos = { version = "0.8.2", features = ["csr"] }
To Reproduce
Steps to reproduce the behavior:
- Add the following code to
main.rs
in the most simple Leptos project you can make:
use leptos::prelude::*;
#[component]
pub fn App() -> impl IntoView {
view! {
<p>A:B?C.D;E</p>
}
}
fn main() {
mount_to_body(App);
}
- Run
trunk serve
- Observe strange whitespace in browser (including in dev tools)
I've tested recent Firefox and Edge builds.
Screenshots
n/a
Next Steps
- I will make a PR
- I would like to make a PR, but need help getting started
- I want someone else to take the time to fix this
- This is a low priority for me and is just shared for your information
Additional context
This is using stable Rust, I haven't tested Nightly.
Quoted text nodes are a reasonable workaround. I see that the leptos book quotes text but I don't think it says why, I assume it comes from a time before unquoted text support was added.
I stumbled across this because I wrote unquoted text without even thinking about it - probably because that's what I'm used to from my time using React. (Old habits die hard!)
Aside: Thanks to everyone who contributes to Leptos - I'm a newcomer but a big fan.