render.rs icon indicating copy to clipboard operation
render.rs copied to clipboard

Script tag portals body data when empty

Open theashguy opened this issue 5 years ago • 3 comments

Not sure whats going on here but checkout this layout function.

pub fn layout() -> content::Html<String> {
    content::Html(html!(
        <>
            <HTML5Doctype />
            <html lang={"en"}>
                <head>
                    <title>{"Test"}</title>
                    <link href={"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"} rel={"stylesheet"}></link>
                    <script src={"/assets/main.js"}></script>
                </head>
                <body>
                    <Header />
                    <Nav title={"My title"} body={"Once you have their money, you never give it back."} />
                    <div>{"Title"}</div>
                </body>
            </html>
        </>
    ))
}

When I use the above, the entire body content gets rendered inside of the

<script src={"/assets/main.js"}>{""}</script>

I'm assuming that it's not closing out empty tags.

theashguy avatar Aug 14 '20 09:08 theashguy

I think I'm seeing the same behaviour with

vpzomtrrfrt avatar Sep 14 '20 00:09 vpzomtrrfrt

I'm seeing this with both script and textarea; inserting an empty string does workaround it

wez avatar Jan 12 '21 17:01 wez

If I understand this correctly, only void elements are allowed to be self-closing in HTML, and even then it doesn't actually do anything

vpzomtrrfrt avatar Sep 29 '21 17:09 vpzomtrrfrt