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

yew-macro: Make self-closing slash optional for void elements #990

Closed
1 of 3 tasks
kellytk opened this issue Mar 2, 2020 · 4 comments
Closed
1 of 3 tasks

yew-macro: Make self-closing slash optional for void elements #990

kellytk opened this issue Mar 2, 2020 · 4 comments
Labels
feature-request A feature request

Comments

@kellytk
Copy link
Contributor

kellytk commented Mar 2, 2020

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

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@kellytk kellytk added the bug label Mar 2, 2020
@jstarry jstarry added feature-request A feature request and removed bug labels Mar 2, 2020
@jstarry jstarry changed the title Self-closing is not required for void elements by the HTML5 spec yew-macro: Make self-closing slash optional for void elements Mar 2, 2020
@totorigolo
Copy link
Contributor

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?

@kellytk
Copy link
Contributor Author

kellytk commented Mar 2, 2020

@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.

@jstarry
Copy link
Member

jstarry commented Apr 25, 2020

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.

@jstarry jstarry changed the title yew-macro: Make self-closing slash optional for void elements yew-macro: Do not allow void elements to have children Apr 25, 2020
@jstarry jstarry changed the title yew-macro: Do not allow void elements to have children yew-macro: Make self-closing slash optional for void elements Apr 30, 2020
@teymour-aldridge
Copy link
Contributor

Related: #1217

@kellytk kellytk closed this as completed Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature request
Projects
None yet
Development

No branches or pull requests

4 participants