Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script tag portals body data when empty #42

Open
theashguy opened this issue Aug 14, 2020 · 3 comments · May be fixed by #46 or #51
Open

Script tag portals body data when empty #42

theashguy opened this issue Aug 14, 2020 · 3 comments · May be fixed by #46 or #51

Comments

@theashguy
Copy link
Collaborator

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> tag. However if I add an empty template string inside the script tag it will work fine... like this...

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

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

@vpzomtrrfrt
Copy link
Contributor

I think I'm seeing the same behaviour with <textarea>

@wez
Copy link

wez commented Jan 12, 2021

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

@vpzomtrrfrt
Copy link
Contributor

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 added a commit to vpzomtrrfrt/render.rs that referenced this issue Sep 29, 2021
@vpzomtrrfrt vpzomtrrfrt linked a pull request Sep 29, 2021 that will close this issue
gkhk0 added a commit to gkhk0/render.rs that referenced this issue Oct 1, 2023
Previously empty element tags were causing other elements to be incorrectly rendered inside them.

This commit fixes the issue by ensuring that empty non self-closing tags are handeld correctly.

Closes render-rs#42
@gkhk0 gkhk0 linked a pull request Oct 1, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants