DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.

Home Page:https://dioxuslabs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`rsx` macro should prevent any children in self-closing elements

mrgzi opened this issue · comments

commented

Feature Request

HTML includes several self-closing elements that are not designed to contain any child elements. Examples of such elements are:

<img src="image.jpg" alt="Description" />
<input type="text" name="username" />

Currently, the rsx! macro in Dioxus allows content to be placed inside these self-closing elements:

pub fn component() -> Element {
    rsx! {
        img {"This is an image"}
    }
}

Implement Suggestion

The rsx! macro should produce an error if any content is nested inside self-closing elements. This would align the behavior of the macro with standard HTML practices and prevent potential rendering issues.