#shadowRoot

2025-03-18

New Kitten release

• Now leaves <style> tags within <template> tags alone when collating and normalising the CSS on a page so as not to interfere with scoped styles in declarative shadow DOM.

(Kitten’s Streaming HTML workflow¹ – which uses htmx and WebSockets under the hood – combined with built-in support for slots, etc., in Kitten components² means the use of declarative shadow DOM is mostly useful if you want scoped styles. Ideally, of course, use classes to scope styles to your components and be specific in your CSS selectors in general so as not to pollute elements in your components. Although that’s a bit like saying you should floss everyday. Yeah, we all know we should…) :)

Update: All that said, I’d highly recommend you don’t use Shadow DOM in your Kitten apps. For one thing, htmx’s WebSocket extension doesn’t seem to play well with it. And for another, you really don’t need it and definitely not just to get scoped CSS.

Enjoy!

:kitten:💕

¹ kitten.small-web.org/tutorials
² kitten.small-web.org/tutorials

#Kitten #SmallWeb #SmallTech #CSS #CSSScoping #ShadowDOM #shadowRoot #DOM #HTML #JavaScript #JS #style #template #declarativeShadowDOM #NodeJS #web #dev

Screenshot of code (left) and browser output (right).

Code:

<p>I am regular root</p>
<div>
  <template shadowrootmode='open'>
    <p>I am shadow root</p>
    <slot></slot>
    <style>
      p { color: red; }
    </style>
  </template>
</div>
<p>I am also regular root</p>
<style>
  p { color: blue; }
</style>

Browser output shows “I am regular root” in blue, “I am shadow root” in red, and “I am also regular root” in blue.
2024-08-09

Is it possible to access a closed #ShadowRoot on a non-custom element?

```
<div>
<template shadowrootmode="closed">
...
</template>
</div>
```

The only ways I'm aware of are `HTMLElement.prototype.attachInternals` which requires a custom element or to manually attach the root with `Element.prototype.attachShadow` and save the result. Are those the only two ways to get at a closed root?

2024-03-19

I 💜 #webComponents but I'm not a fan of the #shadowRoot bc I usually _want_ styles to be inherited. I've read that you can include the same stylesheet again inside the SR but that's got to add a lot of processing. I read lots of other hackish solutions too.

Anyway, I've had some success just using the light side - regular #dom nodes. I built a wrapper around <progress> to do nice animations & reporting current task, too. And another to make #privacy friendly social media share btns.
#webDev

westbrookwestbrook
2024-02-28

Oh, you say you're interested in expanded APIs around controlling the way styles flow into your ? Well, have I got some meeting notes for you!

github.com/w3c/webcomponents-c

Checkout the discussion by the about styling in new and more fluent ways. We're gathering use cases to share with browser implementors, so if you've got one, join the conversation in Discord discord.gg/ZT7QDsG2kT or in a future breakout to support getting it addressed. 🧑🏼‍🎤

Brandon Zhang 🇨🇳heybran@mastodon.online
2023-11-20

Is there any browser form filler extension that can auto fill random data into inputs that live inside #shadowroot?

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst