You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Chrome/Firefox, a CSSStyleRule added to CSSStyleSheet.cssRules by using CSSStyleSheet.insertRule(), will not have a 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.
<style>div { color: red }
</style><script>const{styleSheets: [styleSheet]}=documentconst{ cssRules }=styleSheetconst[{ parentStyleSheet }]=cssRulesconsole.log(styleSheet===parentStyleSheet)styleSheet.insertRule('p { color: red }')console.log(cssRules.length)const[,{ parentStyleSheet2 }]=cssRulesconsole.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.
In Chrome/Firefox, a
CSSStyleRule
added toCSSStyleSheet.cssRules
by usingCSSStyleSheet.insertRule()
, will not have aparentStyleSheet
:Should it be ...or when a rule has been inserted?
Below is how I read an undefined
parentStyleSheet
for this new rule.It may be missing either in parse a CSS rule or insert CSS rule. I'm curious to learn the answer.
The text was updated successfully, but these errors were encountered: