-
Notifications
You must be signed in to change notification settings - Fork 31
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
positioned counterparts of setHTML
?
#184
Comments
DOM has:
It seems kinda attractive to give these (safe) HTML counterparts:
Giving them dedicated method names matches the precedent we set in DOM when we added all those convenience methods. |
Can you explain a bit more about the problems this is trying to solve? The feedback I've gotten so far is that sanitizer users would prefer APIs that return a sanitized value, rather than one that combines sanitization and tree insertion. Asking for more, different ways to sanitize + insert has literally never come up for me. |
Providing a safe replacement for all HTML insertion APIs in a way that is consistent with the DOM library to date. |
I'm happy to read about the "safe" part; particularly in light of #185. The replacement aspect is new to me, and would come with some new requirements.
|
In order of appearance:
|
Re 3: This came up in our spec meeting earlier today. The main issue is that if you insert e.g., |
For that case the combination of how context is set in https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml and is handled at https://wicg.github.io/sanitizer-api/#sanitizeandset (it would be the "this" equivalent) we'd be in the clear I think. You'd get an exception and that's that. |
Edit: see whatwg/html#8759 (comment) sorry for the noise. |
I think a "safe replacement for all HTML insertion APIs" is a question of how to evolve the DOM APIs, and is substantially out of scope for the Sanitizer API WICG. I think this discussion should be moved to the HTML WG. I'm rather thankful for this comment, which provides much needed clarity, and also moves the discussion to the right place. |
I suggest we close this in favor of whatwg/html#10122. This is not really an enhancement that needs to be tracked here. (Though if we do decide to add these we obviously need to involve this community to ensure safety.) |
Agreed. Let's move this to HTML. |
Hi friends,
CC: @otherdaniel @annevk @evilpie
@annevk raised the question whether we want to have different insertion mechanisms than replacing children (as
setHTML()
currently does - likeinnerHTML
assignments).The existing pattern he wants to address exists in the first parameter to
insertAdjacentHTML()
(beforeend
,afterend
,beforebegin
andafterbegin
) or theirprepend()
,append()
andreplaceChildren
in the DOM (though the DOM functions do not parse).Anne suggested we might want to look at providing similarly-named functions e.g.,
prependHTML()
,appendHTML()
etc. that work just likesetHTML()
but with a different insertion point (and maybe different parsing context, if you do the equivalent ofouterHTML
).In counter, I highlighted that the name
setHTML
does side-step the position of the insertion completely.Would this mean that the existing
setHTML
options-bag could simply take aposition:
key with values likeafterend
,beforebegin
orprepend
or whatever color you'd prefer the bikes shed to be🚲 🏠The benefit of specific, positioned insertion is that you wouldn't re-parse the whole subtree, as people currently do with
innerHTML+=
.P.S: Let's keep this discussion solely on the point of whether we want positioned insertion at all and if so, which of these two options we would prefer: Another option or more additional functions.
The text was updated successfully, but these errors were encountered: