- From: Guillaume via GitHub <noreply@w3.org>
- Date: Sat, 25 Oct 2025 11:53:18 +0000
- To: public-css-archive@w3.org
In hindsight, I am pretty sure a style sheet is attached to a document if it is included in `document.styleSheets` or `document.adoptedStyleSheets`, ie. if it is a non-constructed style sheet (`<link>`, `<style>`), or a constructed style sheet included in `document.adoptedStyleSheets`.
```js
const sheet = new CSSStylesheet
sheet.insertRule('@media all {}')
const rule = sheet.cssRules[0]
rule.matches // false (even if it is "associated" to the document)
document.adoptedStyleSheets.push(rule)
rule.matches // true
```
So an *style sheet attached to the document* is a style sheet included in the [*document or shadow root CSS style sheets*](https://drafts.csswg.org/cssom-1/#documentorshadowroot-document-or-shadow-root-css-style-sheets). I do not know what is the difference with the [*final CSS style sheets*](https://drafts.csswg.org/cssom-1/#documentorshadowroot-final-css-style-sheets).
Also tagging @SebastianZ, which said:
> If it's attached to a document, it is always evaluated against that document, even when accessed from another document.
--
GitHub Notification of comment by cdoublev
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10612#issuecomment-3446589134 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Saturday, 25 October 2025 11:53:19 UTC