Re: [whatwg/dom] Declarative Shadow DOM (#831)

> @nolanlawson ,
> 
> > Why is it a problem for the template not to be separated from the component?
> 
> Because 1-time use of template is nonsense. It defeats the sole purpose of template: be reused multiple times. Only scenario where inline template could be applied is on server side rendering where you have to CLONE same template in order to be used for several components. Which is reducing efficiency as server as client ( due to cloned spaghetti DOM structure)

Keep in mind, the `<template>` element was used out of convenience for DSD, not because it is functioning as a "normal" template. A regular template *can* contain a declarative shadow root, and be stamped out in multiple places.

Shadow roots are no different than all other HTML. In HTML, if you want your page to contain 10 `<p>` elements, you write this: `<p><p><p><p><p><p><p><p><p><p>`. This is no different than having your HTML contain 10 web components with 10 shadow roots that are identical. You write them all down in HTML. If you want to stamp out repeated bits of content, then you use a (normal, non-DSD) `<template>` element, and call `template.cloneNode()` to stamp it out. That works for all content, including DSD.

I know it's a bit confusing that `<template shadowroot>` means a declarative shadow root, but it's important to keep the two things (DSD and "normal" templates) separate in your mind.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/831#issuecomment-1264136240
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/831/1264136240@github.com>

Received on Friday, 30 September 2022 23:54:37 UTC