-
Notifications
You must be signed in to change notification settings - Fork 756
Open
Description
(Edit: fixed some details on settings)
I'm proposing extending the CSSStyleSheet interface with a new attribute, layer.
On getting, it should return the layer name if the sheet is entirely in some cascade layer. In particular:
- If this is an
@import-ed stylesheet, return thelayerNameattribute value of theCSSImportRule - If this stylesheet is added via a
<link>element (depending on Allow authors to apply new css features (like cascade layers) while linking stylesheets whatwg/html#7540), then return the name of that layer - If this is a constructed stylesheet with a layer name previous set by JS (see below), return that layer name
- Otherwise, return
null
On setting:
- If this is a constructed stylesheet and the new value is a non-null string, then the attribute value can be modified, and the stylesheet is treated as entirely in the given layer
- If this is a constructed stylesheet and the new value is null, then the attribute value can be modified, and the stylesheet is treated as unlayered
- Otherwise, throws a NotAllowedError DOMException
The primary use case is to allow adding layered constructed stylesheets, especially if the stylesheet is a 3rd party CSS module, and we want to use that to set up a web component (which we currently don't have a good way to make it layered):
import sheet from 3p-foo.css;
sheet.layer = 'new-layer';
shadowRoot.adoptedStylesheets = [sheet];SebastianZ, tabatkins, jonjohnjohnson and bb010g