Re: [WICG/webcomponents] Addressable comments (a very small DOM parts subset) (Issue #1116)

noamr left a comment (WICG/webcomponents#1116)

> Apologies for the upcoming long post...
> 
> In the event that it helps this discussion, I thought I would show what my template compiler takes as input and what its code emitters (roughly) produce as output. I'll demonstrate with a basic todo app template, which most folks should be familiar with, and which provides the opportunity to show a variety of templating constructs.
> 
> Here's the input template:
> 
> <template>
>   <form @submit="this.addTodo($event)">
>     <input type="text" ref="description" placeholder="description">
>     <button type="submit">Add Todo</button>
>   </form>
> 
>   <ul>
>     {#for todo of this.todos}
>       <li>
>         <input type="checkbox" ?checked="todo.done" @change="todo.done = !todo.done" title="done">
>         <span class="{todo.done && 'done'}">{todo.description}</span>
>         <button type="button" @click="this.removeTodo(todo)">X</button>
>       </li>
>     {/}
>     {#empty}
>       No todos...
>     {/}
>   </ul>
> </template>

In the end, you have two types of locators here:
- An element locator (e.g. for `<form @submit>`, `<input ?checked>` etc.
- A loose range locator (e.g. for `{#for}` and `{#empty}`

Element locators are already quite optimized in the platform.
Addressable comments give you an efficient locator for loose ranges.

All the rest are definitely useful/important, but I am struggling in what's the added value of doing them in the platform.
Also, perhaps this can be structured iteratively, when we solve range-markers/comments first, and then see if the higher level semantics can be an enhancement on top of that.

> 
> Comments play a critical role in today's browser rendering though. And they typically also have metadata associated with them so that behavior can be attached. But they aren't the optimal way to handle everything.

Everything? No. They only solve efficient locating of non-element parts of the document, and thus help with live ranges.

> Regarding this proposal, I don't know that it's sufficient to replace all location-related code shown here. It may help, but it's less likely if I need to create a tree walker to find the comments. 

Why would you need that? The whole premise of this proposal is that you can locate comments efficiently without walking the tree.


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

Message ID: <WICG/webcomponents/issues/1116/3551941058@github.com>

Received on Wednesday, 19 November 2025 10:24:35 UTC