Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Web components provide a clean abstraction boundary. You can add additional methods to your own tags which can encapsulate the logic for updating the data in the component.



They let you encapsulate the logic pretty much however you want, same as not using web components.


When you call document.querySelector("something") in the main HTML document, it will not find "something" inside the internal HTML of a web component.


You can use the shadow DOM outside of custom elements, and can use custom elements without a shadow DOM.

Edit: I just added a shadow root to a div in your comment, saving its content beforehand, moved its content inside the shadow root, and added a style with * { all: initial } and your comment text got Times New Roman.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: