mastodontech.de ist einer von vielen unabhängigen Mastodon-Servern, mit dem du dich im Fediverse beteiligen kannst.
Offen für alle (über 16) und bereitgestellt von Markus'Blog

Serverstatistik:

1,5 Tsd.
aktive Profile

#declarativeshadowdom

0 Beiträge0 Beteiligte0 Beiträge heute

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
Antwortete im Thread

@ryantownsend In github.com/WICG/webcomponents/ we're theorizing the declarative sharing of repeat <style> tags. Structured initially for #declarativeShadowDOM, but feels like something that could apply to prelude-less @​scope, too. I wonder if that would make it practical/productive to blend test no. 1 and no. 3 in your demo css-scope-test.netlify.app/ and whether an approach that like that could even further reduce the paint times these tests are clocking...

GitHubDeclarative CSS Module Scripts · Issue #939 · WICG/webcomponentsVon justinfagnani

So many great encapsulation strategies, so little time!

<style>
p {
color: blue;
font-size: 2rem;
}
</style>

<my-el>
<style>
@Scope {
:scope {
&, * {
all: revert-layer;
color: red;
}
}
}
</style>
<p>This text is red & small!</p>
</my-el>

<my-el>
<template shadowrootmode="open">
<style>
* {
color: red;
}
</style>
<p>This text is red & small!</p>
</template>
</my-el>

codepen.io/Westbrook/pen/vYMgO

codepen.ioEncapsulation Part!...

So I got nerd-sniped by @passle and their very cool out of order #HTML streaming demo with #DeclarativeShadowDom and no client-side #JavaScript.

techhub.social/@passle@mastodo

I spent yesterday playing around with this idea and came away with a `streamOutOfOrder` tagged template literal which is able to apply this optimization to any interpolations. It even composes itself correctly and can load the whole page optimally out of order, no matter how large or complex it is.

Take a look and "View Source" to see how it works!

dsd-out-of-order-streaming.dwa

#shadowDOM partners with the likes of `:not(:defined)` to make progressive enhancement a more natural part of component development than ever.

#declarativeShadowDOM builds on top of that, and once Firefox ships things powerful API the distance between "page load" and "page needs JS" can be even further apart.

It's powerful to lean into the existing web APIs to learn new and exciting ways to support our clients while continuing to push the boundaries of those APIs at the spec level.