Netflix / x-element

A dead simple starting point for custom elements.
Apache License 2.0
28 stars 12 forks source link

Improve style sheet adoption ergonomics. #166

Open theengineear opened 8 months ago

theengineear commented 8 months ago

One common pattern for element authors (now that import attributes enable folks to import css files directly) is to adopt imported style sheets into a shadow root at custom element initialization time.

This adds two static getters — shadowRootInit and styleSheets. The goal is to make shadow root initialization as declarative as possible. Note that we still expose createRenderRoot so we don’t get in the way if folks need to do something more advanced (it’s also still the only way to forgo the creation of a shadow root at all).

Closes #52.

theengineear commented 8 months ago

@klebba — This is more-or-less what I figured we’d do here. It’s pretty straightforward, just a way to declare things in isolation as an ergonomic benefit.