-
Notifications
You must be signed in to change notification settings - Fork 756
Open
Labels
cssom-1Current WorkCurrent Work
Description
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?
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
}Metadata
Metadata
Assignees
Labels
cssom-1Current WorkCurrent Work