lustre-labs / lustre

An Elm-inspired framework for building HTML templates, single page applications, and server-rendered components in Gleam!
https://hexdocs.pm/lustre
MIT License
744 stars 53 forks source link

♻️ Handle void elements and self-closing tags. #11

Closed hayleigh-dot-dev closed 6 months ago

hayleigh-dot-dev commented 9 months ago

Right now void HTML elements like <br> and <img> are generated with closing tags when rendering to string or string builder. This is incorrect.

I'm about to push an ad-hoc fix that checks the tag against the list of known HTML void elements (it's finite) and renders them without the closing tag, but this doesn't scale because certain SVG and MathML elements are required to be self-closing like <circle />. We'll want a better way to deal with this than maintaining a list of hardcoded tags.