- From: Justin Ridgewell via GitHub <sysbot+gh@w3.org>
- Date: Fri, 22 Feb 2019 06:02:56 +0000
- To: public-css-archive@w3.org
jridgewell has just created a new issue for https://github.com/w3c/csswg-drafts:
== [cssom] Implement CSSStyleRule.p.matches ==
With style rules nested inside `@media` and `@support` conditions, it's a bit difficult to determine if a style rule applies to an element. Is it possible to expose a `matches` method that would do this for us?
```js
const div = document.querySelector('div');
const span = document.querySelector('span');
{
// Eg, `@media screen { div { color: red; } }`
const rule = document.styleSheets[0].cssRules[0].cssRules[0];
rule.matches(div);
// => true
rule.matches(span);
// => false
}
{
// Eg, `@media not screen { div { color: red; } }`
const rule = document.styleSheets[1].cssRules[0].cssRules[0];
rule.matches(div);
// => false
rule.matches(span);
// => false
}
```
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3670 using your GitHub account
Received on Friday, 22 February 2019 06:02:58 UTC