- From: Guillaume via GitHub <sysbot+gh@w3.org>
- Date: Thu, 13 Jan 2022 05:28:36 +0000
- To: public-css-archive@w3.org
cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts: == [cssom] Missing step to set `parentStyleSheet` == In Chrome/Firefox, a `CSSStyleRule` added to `CSSStyleSheet.cssRules` by using `CSSStyleSheet.insertRule()`, will not have a [`parentStyleSheet`](https://drafts.csswg.org/cssom/#dom-cssrule-parentstylesheet): > The parentStyleSheet attribute must return the parent CSS style sheet. > > Note: The only circumstance where null is returned when a rule has been removed. Should it be *...or when a rule has been inserted*? Below is how I read an undefined `parentStyleSheet` for this new rule. ```html <style> div { color: red } </style> <script> const { styleSheets: [styleSheet] } = document const { cssRules } = styleSheet const [{ parentStyleSheet }] = cssRules console.log(styleSheet === parentStyleSheet) styleSheet.insertRule('p { color: red }') console.log(cssRules.length) const [, { parentStyleSheet2 }] = cssRules console.log((styleSheet === parentStyleSheet2) || parentStyleSheet2) // undefined </script> ``` > **parent CSS style sheet:** a reference to a parent CSS style sheet or null. This item is initialized to reference an associated style sheet when the rule is created. It can be changed to null. It may be missing either in [*parse a CSS rule*](https://drafts.csswg.org/cssom/#parse-a-css-rule) or [*insert CSS rule*](https://drafts.csswg.org/cssom/#insert-a-css-rule). I'm curious to learn the answer. Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6945 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 13 January 2022 05:28:38 UTC