-
Notifications
You must be signed in to change notification settings - Fork 376
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
HTML parser: align custom elements with the template element #630
Comments
Can we close this issue, and use whatwg/html#2432 ? |
I think we should use this issue instead. The problem is more specific to web components than a generic ol / li behavior. |
Now I'm confused. Are we hoping for a one-off parser fix for ol/li, or are we hoping to revisit #59? |
I think we should revisit #113 and #624. We've seen dozens of issues with not having any mechanism to change the parser behavior in custom elements. I'm pretty convinced that we should at least re-examine the way to allow a custom element to be parsed as a self-closing element or a template-like element. |
OK! Well I'm very excited about such a possibility, and it sounds like now we have at least one implementer interested. Thoughts from @hsivonen, @dominiccooney, or @travisleithead for introducing new parser behavior into their engines? |
It seems much safer to go down the route of XML-with-defined-error-handling and have folks use that. That's much less likely to break things and a much less constrained environment. |
I don't follow what you mean by "the route of XML-with-defined-error-handling". Can you elaborate? |
@rniwa something I worked on a long time ago: https://annevankesteren.nl/2007/10/xml5 and more recently at https://github.com/Ygg01/xml5_draft. |
I don't think we want to introduce yet another parser. We can hardly maintain XML and HTML parsers. Using a special character like |
It's not a new parser, it would replace the XML parser with something that's backwards compatible (except if you rely on errors). |
Well, we use libxml for parsing XML so having to support this parser would likely mean that we'd have to implement it ourselves since libxml is unlikely to adopt that new parser behavior anytime soon. And then we'd have to reimplement XPath, XSLT, etc... for backwards compatibility. In practice, that's never gonna happen. |
I don't see why you'd have to reimplement those though, you'd still generate the same kind of tree. In any event, such a change would automatically make all kinds of difficult situations in HTML extensible while being much more safe to execute. |
I don't think that approach is acceptable to us due to the immense implementation cost. If that's the only path Mozilla would agree to, then we should just not do this. |
I can't really say for Mozilla as a whole, but a couple folks are rather worried about any HTML parser churn. In particular with regards to security and also the wider ecosystem. Whenever the HTML parser changes, it's not just browsers that are affected, but also all kinds of libraries that might be harder to get updated. See e.g., whatwg/html#919 (comment). That's why I'm trying to find alternatives, since I don't think our parser problems will go away. |
From a user, and framework-author perspective, how would allowing lists to contain custom elements be a breaking change to the parser (or for a custom list to contain native list items)? The same question goes for tables. From a consumer perspective, this appears to be relaxing the current parsing restrictions. |
I think you're looking at it the wrong way. The parser handles all input and produces a certain output. Any kind of change is risky with such a setup, especially given that most content has validity errors and thereby trigger all the various branches of the parser. It's very different from no longer throwing an exception somewhere. |
There is some interest in aligning custom element parsing with the way |
I'm sorry I missed the @ mention the first time round. Like @annevk says, I'm very reluctant to tweak the HTML parsing algorithm. It's not just a matter of browsers tearing open at something that's well-tested and that we've achieved interop on. It's also a matter of various other pieces of software being able to trust that their implementation of the HTML parsing algorithm matches what browsers do. This may even have security implications. It's hard enough to get Web developers to believe that the right way to sanitize HTML is to use a real HTML parser that implements the algorithm from the spec. It's even worse if that's a moving target. As for the use case shown in the initial report, isn't that what the |
Just wanted to note that the edge folks have no hesitation in changing the parser. We'd be 100% fine with it |
I think this is easy to dismiss, but <p>
<my-element>
<div>caption</div>
</my-element>
</p> gets parsed as: <p>
<my-element>
</my-element>
</p>
<div>caption</div> I don't like the idea of not being able to create inline custom-elements inside a paragraph. For example, a custom picture or video element. Even if the output was the following, it would have worked for most cases: <p>
</p>
<my-element>
<div>caption</div>
</my-element> There may be no appetite to change the HTML parser, but if you are thinking of Web Components, this is pretty sucky parse behavior. |
I don't think the contents of |
I respectfully disagree, @domenic. The whole idea of having Take the I could tell people using I understand the reasons why solving this is hard, but I do not think it's poor design, or something that WCs should not strive to solve. The whole idea of extending the HTML should not only be for blocked content. |
BTW, I like the idea of treating custom elements like |
Video has no light DOM children. If you only have shadow children there is no problem. |
I understand that. Just saying there are technical limitations to my ability to create certain kind of custom elements (e.g. an inline video player example described above), which I wouldn't like to have. |
Sure, and I'm saying the goal is not to allow no restrictions, but to allow new elements which obey the semantics of HTML. The semantics of HTML do not contain or allow children of p elements to contain divs, and we've designed custom elements to respect that invariant. |
Fair point. Just for the sake of argument though - the limitation of I do not want to harp on this for no reason, I have seen these issues in real and it's hard to explain people who use my components. Also, I was trying to show support for the title of the issue about dealing with custom elements akin to templates for parsing purposes. |
Yeah, you can definitely break the HTML content model using JavaScript :). |
Promise, last comment on this (tonight) :P The spec for
The last bit about custom elements is interesting, since in practice, most custom elements act like blocked elements like div, figure, etc which it explicitly doesn't allow. Not sure about the reasoning of including custom-elements in the There would have been no major issues if the custom element was rejected and the |
It allows custom elements so that you can create things like custom-strong etc. The ECMAScript spec has a series of emu-* custom elements which are used in this manner. |
I understand that and have created similar elements myself; that was the whole point for my-video as well. My question was more related to being less restrictive in an otherwise very restrictive spec. |
For a
By applying the above approach
Additionally it will give access to the slotted content to the custom-element author via JavaScript. |
F2F Resolution: We can't change the HTML parser behavior at this point |
http://jsbin.com/haceseqabi/edit?html,output
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36
Steps to reproduce the problem:
<ol>
or<ul>
What is the expected behavior?
Render a nested list.
What went wrong?
The list becomes flat.
Did this work before? No
Does this work in other browsers? N/A
Chrome version: 57.0.2987.98 Channel: stable
OS Version: OS X 10.12.3
Flash Version:
The text was updated successfully, but these errors were encountered: