option element in datalist is wrong
Julow opened this issue · 4 comments
I get Error: option should have exactly one child
for
<datalist>
<option value="foo"></option>
</datalist>
Also, if I don't close the option
tag (like here), I get a strange error, which I guess is because it put the newline inside option
instead of datalist
Unclosed elements like in your link are improper HTML and only work because of sloppy parsing. In general, you should avoid w3school, it's not a good source, prefer MDN.
As for datalist, I think that's a new instance of whitespaces!
I don't think its a problem with whitespace. I think it's because it interprets the option
tag as if it's in a select (or optgroup
) which require some text. option
in a datalist
doesn't require a body.
I agree with you that it is not important to handle every special case in the ppx, as a user I'll understand.
MDN also do not close option tags, should markup
handle this case ? It is not very important here but this case might happen in real websites.
I see. We should definitely handle that. The smart constructors in the ppx are made in a way that should allow us to handle that, even if it might be a bit annoying.
The parsing aspect is handled by markup, so I'll let @aantron handle it.
Markup.ml is doing the right thing. I added two tests, for unclosed <option>
in <datalist>
with and without whitespace: https://github.com/aantron/markup.ml/blob/c0085e432699c5a0208858850824f8e9ab7f83c6/test/test_html_parser.ml#L448-L479.