Re:HTML Web Components
by toasted-subs on Monday November 13, 2023 @03:37PM
(#38255050)
I don't understand why people use the shadow Dom. Why not edit the Dom directly?
You are correct. You don't have to use the shadow DOM, when you create a new Custom Element.
The shadow DOM provides two things:
- style encapsulation (as well as `id` attributes) - ability to use `<slot>` for templating
You should use it if you require one of the above or both.
My personal problem with these "native" components is, that the shadow DOM is pretty restricted compared to component frameworks like React, Vue or Svelte.