-
Notifications
You must be signed in to change notification settings - Fork 302
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
Expose document fragment serialization algorithm #965
Comments
Hmm I transferred this to whatwg/dom but maybe it really belongs in https://w3c.github.io/DOM-Parsing/, at least until we finish merging that spec into HTML. Sorry about that. As you say, I have the feeling this has been previously discussed, and maybe there were web compatibility reasons why it hasn't been added. We added In w3c/DOM-Parsing#21 there's some discussion of the problem of the context element, but I believe that only impacts the setter, not the getter. Maybe we could add a getter to |
When building the prototype Sanitizer API in Gecko, I have actually thought the same, but didn't think of (dare thinking of?) suggesting this for wider implementation. I even used this as a short-cut in Gecko. We currently have an internal, C++-only getter for innerHTML that we could easily expose to the web (added in bug 1653232). I'm a bit unsure about the compat bit and how to resolve it though.. |
Probably for the same reason as The current proposal for declarative shadow dom contains a |
See the following public-webapps threads:
This wasn't really prevented / motivated by the compatibility concern. It was because |
Yeah, I think this is a problem with the sanitizer API. The fragment parser takes a string and a context element. Both are significant. |
I'm not sure how to parse this comment. Are you saying the serialization algorithm shouldn't be exposed because it's Sanitizer API's problem, or that it shouldn't accept a context element as a parameter? Or something else? |
I think (willing to be convinced otherwise) HTML string sanitization needs to account for the same input parameters as HTML string parsing, i.e., the string and the context element. Otherwise it might be tricky to insert into |
I'm still confused. Are you saying the algorithm shouldn't be exposed on the DOM side, or making a comment to inform the API shape? |
API shape / model. |
The sanitize API question moved (back) to WICG/sanitizer-api#42. With regards to OP, having considered the sanitization API more carefully, I don't think we should expose the serialization of a (As a simple example, consider So I'll leave this open for a bit to see if there is a compelling counterargument, but I'm inclined to close this given the above. |
It might be a separate issue, but could we get a way to serialize a whole document? (other than Serializing a |
Yeah, that seems like a reasonable request to me as an issue against either DOM Parsing or the HTML Standard. Ideally it would come with some use cases. (Browsers are already forced to implement it for |
@annevk This argues that the serialization function needs to accept a (mandatory?) context parameter, not that there shouldn't be a serialization function at all, no? |
@LeaVerou the serialization doesn't depend on the context, but the parsing of it does. Given that mismatch, offering context-free serialization (i.e., |
Does this mean the sanitizer API should not be offering methods that only accept the string to sanitize as input? |
Yeah, I discussed that with @mozfreddyb yesterday and that's why he reopened WICG/sanitizer-api#42 for further discussion. |
This came up during TAG review of Sanitizer API.
They have a
sanitize()
method that returns aDocumentFragment
and asanitizeToString()
which merely callssanitize()
and then serializes the fragment.Instead of adding ad hoc methods in various Web Platform APIs to invoke the HTML fragment serialization algorithm, there should be a way to serialize document fragments directly. I imagine there are reasons not to add
innerHTML
to document fragments, otherwise it would already be there. Perhaps a new getter, or a method that also accepts an optional context type?The text was updated successfully, but these errors were encountered: