Re: [w3c/webcomponents] [templates] API for updating (#685)

@rniwa and I had a chance to talk about this last week. He was not in favor of most of my suggestions, although as he notes above, he is in favor of having a template's `instantiate()` call return a new type of object that's not an `HTMLTemplateElement`.

For now, let's say it's something like `HTMLUpdatableInstance`. This would have a `content` property that holds the document fragment, and an `update` method for updating those nodes.

```js
const instance = template.instantiate();
document.body.appendChild(instance.content);
instance.update({ name: 'Jane' });
```

To me, at least, having this result be a distinct class feels better. Among other things, it means that `HTMLTemplateElement` doesn't get burdened with the notion of updatability.

With such an object returned by `instantiate()`, I believe I could still get destructuring along the lines shown above:

```js
const { content, update } = template.instantiate();
document.body.appendChild(content);
update({ name: 'Jane' });
```


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

Received on Monday, 18 December 2017 17:39:31 UTC