WICG / webcomponents

Web Components specifications
Other
4.34k stars 373 forks source link

[templates] Parts APIs surface concerns #680

Open domenic opened 6 years ago

domenic commented 6 years ago

I have a few minor issues with the template parts APIs:

Shared

Attribute parts

Node parts

rniwa commented 6 years ago

Not having the top-level TemplatePart interface seems fine.

I do like the idea of being able to iterate over all the parts and just assign value however. In fact, I wanted to make value setter do the same right thing based on whether it's true / false instead of having a separate booleanValue. I didn't do it simply because there wasn't a way to express it in WebIDL. However, you can't really assign a string to InnerTemplatePart anyway, this might be already a moot point. In that world, it's probably better to have an explicit add/remove methods on AttributeTemplatePart instead.

We're not tied to just having perviousSibling or nextSibling. It's just that we do need some API to know where those template parts belong, and those two properties felt the simplest one we could add.

My original thought was that we didn't want to use live NodeList but in this case, the liveness is cheap (e.g. mutating DOM tree doesn't have to invalidate this list) so we can just use [SameObject] instead. Using FrozenArray<Node> or sequence<Node> would be fine as well. We're not tied to the specifics of this API.

Sure, I think just having textContent, replaceWith, and replaceWithHTML would be good. We don't want to use innerHTML since it gets confusing with the semantics of outerHTML (the semantics of replaceWithHTML is closer to outerHTML although the template part is never really in a DOM tree).