Re: [WICG/webcomponents] [dom-parts] Creation API (Issue #1010)

> I'm interesting in particular in what happens if the nodes the `ChildNodePart` is referring to changes, either removed or otherwise.

Yeah this is something I've never understood with this API idea, it seems like it'd be simpler instead of the proposed `ChildNodePart` to do a [similar thing to attributes](https://github.com/WICG/webcomponents/issues/1011) and just have a part that sets the full list of child nodes.

i.e. If we had a template like:

```html
<div>
   <b>Hello </b>{{name}}!
</div>
```

then some template parser would just generate this:

```js
const namePart = new NodeListPart();
const childPart = new ChildListNodePart(divElement, [bElement, namePart, "!"]);
namePart.value = "Bob";
```

committing a change would *effectively* just be the same as setting the child list of the div. (Though internally committing would deal with the `previousSibling`/`nextSibling` stuff which it can derive from the list passed to `ChildListNodePart`).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/1010#issuecomment-1612439340
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/1010/1612439340@github.com>

Received on Thursday, 29 June 2023 05:10:20 UTC