dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

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

Open mrgzi opened this issue 9 months ago • 0 comments

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.

mrgzi avatar May 07 '24 22:05 mrgzi