Problem
Void Elements
From https://html.spec.whatwg.org/multipage/syntax.html#start-tags:
Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS character (/). This character has no effect on void elements, but on foreign elements it marks the start tag as self-closing.
The "/" of <br/> is optional per the spec however Yew's html! macro requires it.
Questionnaire
From the specification you're linking, the void elements are the following:
Void elements
area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr
Personally, I'm not a big fan of allowing this, because it looks to me that it's pure laziness that became standard. IMO implementing this would complicate the html! macro implementation. But I think that printing helpful error in the case of unclosed void elements could be a pragmatic and easy solution. What do you think @kellytk?
@totorigolo
Personally, I'm not a big fan of allowing this, because it looks to me that it's pure laziness that became standard.
As I understand it, XHTML was oriented toward XML and HTML5(tm) is oriented toward SGML, wherein subtle differences in void and element closing exist. https://stackoverflow.com/a/3558200 is a primer. Irrespective, questioning the spec is out of scope here at least for myself.
I don't know if the intent of the html! macro is to completely conform to the HTML spec. I would defer to documentation or a comment by @jstarry. If complete conformance is the intent, a fix should be implemented, otherwise whatever the intent of the macro is should guide how the issue is addressed.
A more helpful error message would be appreciated.
We can revisit the trailing slash issue later I think.
For now, we should not allow void elements to have children. We can compile time check this with the proc macro.
Related: #1217
Most helpful comment
From the specification you're linking, the void elements are the following:
Personally, I'm not a big fan of allowing this, because it looks to me that it's pure laziness that became standard. IMO implementing this would complicate the
html!macro implementation. But I think that printing helpful error in the case of unclosed void elements could be a pragmatic and easy solution. What do you think @kellytk?