The CSSRule docs in MDN states that the CSSRule.type
property is deprecated and is not clear to me what should be used instead if one wants to check the type of CSSRule
. Adding some code for reference.
const isStyleOrImportRule = (rule: CSSRule): boolean => {
// 1 -> CSSRule.STYLE_RULE
// 3 -> CSSRule.IMPORT_RULE
return [1,3].includes(rule.type)
}
There is a better way to do this and avoiding deprecation issues referencing the constructor function name.
const isStyleOrImportRule = (rule: CSSRule): boolean => {
return ['CSSStyleRule', 'CSSImportRule'].includes(rule.constructor.name)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With