- From: Jonathan Neal via GitHub <sysbot+gh@w3.org>
- Date: Tue, 22 Apr 2025 21:06:29 +0000
- To: public-css-archive@w3.org
jonathantneal has just created a new issue for https://github.com/w3c/csswg-drafts: == [cssom] allow text in CSSStyleSheet constructor == May we consider allowing [CSSStyleSheetInit](https://drafts.csswg.org/cssom/#dictdef-cssstylesheetinit) to accept a text property that synchronously assigns rules to the constructed sheet? ```idl dictionary CSSStyleSheetInit { DOMString baseURL = null; (MediaList or DOMString) media = ""; boolean disabled = false; DOMString text = ""; }; ``` Example usage: ```js new CSSStyleSheet(":host{ /* styles */ }") ``` Example in `adoptedStyleSheets`: ```js shadowRoot.adoptedStyleSheets = [ new CSSStyleSheet(":host { /* styles */ }") ] ``` The goal is to improve the authoring experience for constructed stylesheets, especially within custom elements, by enabling inline creation without needing to call `replaceSync()` separately. This would be a small but meaningful ergonomic improvement and a low-barrier enhancement that could benefit many developers working with `adoptedStyleSheets`. Would this be appropriate for inclusion in the spec, or is it better suited for discussion elsewhere? Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12110 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 22 April 2025 21:06:30 UTC