Re: [WICG/webcomponents] DOM parts use outside of <template> seems unlikely (Issue #1035)

@otabek-git Thanks for your input, this is exactly why I raise the issue. The goal of having a declarative way to do DOM updates is a good goal, but the solution of templating is a dead-end because it is incompatible with the way the web works.

Templating is a one-way operation, you have a template and some data and something comes out the the other end (html, text, whatever). You *cannot* reverse that operation. But reversing is a requirement on the web, as much of your templating has already occurred on the server.

----

@bahrus Thanks for bringing up that post, which I have read in the past, let's talk about it:

```html
<section>
  <h1 id="name"><?child-node-part?><?/child-node-part?></h1>
  Email: 
  <?node-part?><a id="link"><?child-node-part?><?/child-node-part?></a>
</section>
```

The fact that this is the proposed solution to the problem should be a red flag for why we should not pursue templating.

1. Does anyone think this looks, in any way, good?
2. Would anyone want to hand-write this? The implication of going this route is that HTML becomes a compile target. Do we really want to go down that route? HTML is no longer something you write yourself?
3. I am highly skeptical that browsers would want to modify the HTML parser in order to support this. Historically HTML parser changes have a very high bar. You can look at other issues in this repo to see proposals that require parser changes and see the reasons why they have been denied. That's not to say that it's impossible, but releasing DOM parts to later have this idea be denied for parser technical/security/whatever reasons feels like wasted time.

----

There are other ways to support declarative DOM updates outside of templating, and those are the things that we should be pursing. CSS is a good example of a DSL that allows modification of DOM (through its styles) while being detached from how the DOM is produced. See this blog post for a good review of CSS' potential as it continues to get better: https://bkardell.com/blog/CSSLike.html

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

Message ID: <WICG/webcomponents/issues/1035/1803874990@github.com>

Received on Thursday, 9 November 2023 13:54:32 UTC