getludic / ludic

🌳 Web Development in Pure Python with Type-Guided Components.
https://getludic.dev
MIT License
754 stars 14 forks source link

Elements with no children "eating" following elements #54

Closed johanfforsberg closed 6 months ago

johanfforsberg commented 6 months ago

Not sure I am understanding things correctly, but it seems that e.g. this code:

html.div(id="a")
html.div(id="b")

results in the second div "b" being nested within the first, "a". This does not happen if I put some children in the divs:

html.div("", id="a")
html.div("", id="b")

Is this intended behavior? In particular when using HTMX to load things, it makes sense to have elements that are empty at first. I found it pretty confusing to have to put in empty placeholders.

paveldedik commented 6 months ago

Hi @johanfforsberg

thank you for reporting the issue. You are correct, handling of div and other elements (which are not void like <input>, <hr>, etc.) is incorrect when they don't have any content. I just opened a PR to fix that. I will release the fix today.

paveldedik commented 6 months ago

Fixed in 0.4.10

Thank you again for reporting the issue :)