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

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: