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

noamr left a comment (WICG/webcomponents#1116)

> I want to mostly echo [#1116 (comment)](https://github.com/WICG/webcomponents/issues/1116#issuecomment-3525964584). It's a nice advancement if we can have a performance win by avoiding the tree walk. Just to be clear, it has to be faster than something like:
> 
> function collectComments(root: Node = document): Comment[] {
>   const walker = document.createTreeWalker(root, NodeFilter.SHOW_COMMENT);
>   const comments: Comment[] = [];
>   let node: Comment | null;
>   while (node = walker.nextNode() as Comment | null) comments.push(node);
>   return comments;
> }

Exactly, the idea is to do the above but more efficiently, and perhaps support some use cases out of the box such as selecting the range between two comments, or patching using `<template contentmethod>` (https://github.com/whatwg/html/issues/11542).

> Other than that...
> 
> * I think it's possible easily to extract any attribute/event/property info into a comment that's say the first child of an element.

I don't exactly understand.

> * Supporting ranges in text only elements (mostly style) would be really great as well, and putting the comment _after_ the entire element makes parsing the input trickier.

Is there a need to replace partial ranges inside a `<style>`, or the whole style? If it's the latter, why not address the style element itself? If the former, perhaps the caller could manage the templating?
I mean we could add something to the CSS parser that contributes to these ranges but it might make this exponentially more complicated so I would like to understand the use case better before baking it in.


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

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

Received on Tuesday, 18 November 2025 19:16:07 UTC