Allow fragment to be created dynamically with the empty string
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 32.8k
- Forks
- 1.5k
- Avg merge
- 5h 34m
- Merged PRs (30d)
- 2
Description
Problem
Intuitively, <@{tag_name}> </@> should create a fragment when tag_name is the empty string. Or at least, when tag_name is an empty string literal, the html! macro should panic at compile-time, which is consistent behavior with existing code (unexpected string literal input as a dynamic tag name panics at compile time):
Steps To Reproduce
// main.rs
use yew::{prelude::*};
#[function_component(MyComponent)]
fn my_component() -> Html {
html! {
<@{""}/>
}
}
fn main() {
yew::start_app::<MyComponent>();
}
Then run trunk serve with the template index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>New Title</title>
</head>
</html>
This passes compilation and panics at runtime on app start.
from the developer console in the browser:

Environment:
- Yew version: [
master]
Questionnaire
- I'm interested in fixing this myself but don't know where to start
- I would like to fix and I have a solution
- I don't have time to fix this right now, but maybe later
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/yew-macro/tests/html_macro_test.rs, especially the existing dynamic-tag cases linked in the issue, and reproduce the example using an empty string tag. Trace how the html! macro handles that input and add coverage showing the chosen consistent behavior: fragment creation or compile-time panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100