281

Original post: fedi.aria.dog (~~fat Yoshi~~ Akkoma?)

you are viewing a single comment's thread
view the rest of the comments
[-] Ephera@lemmy.ml 9 points 12 hours ago

The browser has an internal model for representing the HTML document, called the Document Object Model (DOM). This DOM happens to be tree-shaped, because HTML is tree-shaped. And certain logic in a browser gets applied to subtrees, like e.g. most CSS rules.

Sometimes, however, you want a subtree to not get affected by what's going on in the main tree, for example when including an SVG into that tree, or if you're offering JavaScript library with a pre-built component.
And yeah, that is what the Shadow DOM does. It also shields the rest of the DOM from what you're doing inside the Shadow DOM. And there's certain mechanisms to selectively allow interaction across the shadow boundary, e.g. when providing a pre-built component, you might still want the user to be able to style parts of it.

this post was submitted on 22 Jan 2025
281 points (100.0% liked)

Microblog Memes

6212 readers
2658 users here now

A place to share screenshots of Microblog posts, whether from Mastodon, tumblr, ~~Twitter~~ X, KBin, Threads or elsewhere.

Created as an evolution of White People Twitter and other tweet-capture subreddits.

Rules:

  1. Please put at least one word relevant to the post in the post title.
  2. Be nice.
  3. No advertising, brand promotion or guerilla marketing.
  4. Posters are encouraged to link to the toot or tweet etc in the description of posts.

Related communities:

founded 2 years ago
MODERATORS