blob: b82d43d09017955af2904f6362e858929a6d4399 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>CSS Selectors: :matches()</title>
<link rel="author" title="Victoria Su" href="mailto:victoriaytsu@google.com">
<link rel="help" href="https://drafts.csswg.org/selectors-4/#matches">
<meta name="assert" content="This tests that the :matches() selector is effective when nested">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
/* Testing that highest specificity is chosen for class outside of :matches() */
.a+.b+.c>.e+.d {
color: black;
font-size: 10px;
width: 10px;
}
.a+:matches(.b+.f, .b+:matches(*, .c>.e, .g, *))+.d {
color: red;
font-size: 20px;
}
.a+.b+.c>.e+.d {
color: yellow;
}
/* Testing specificty of a class within :matches() */
.a+.c>.e {
color: black;
}
.a+:matches(.b+.f, :matches(.c>.e, .g)) {
color: red;
}
.c>.e {
color: black;
}
</style>
</head>
<body>
<div class="a">
</div>
<div class="b" id="b2">
</div>
<div class="c" id="c2">
<div class="e">
</div>
<div class="d" id="d1">
Yellow
</div>
</div>
<div class="a">
</div>
<div class="c" id="c2">
<div class="e" id="e1">
Red
</div>
</div>
<script>
var red = "rgb(255, 0, 0)";
var yellow = "rgb(255, 255, 0)";
test(() => {
assert_equals(getComputedStyle(d1).color, yellow);
assert_equals(getComputedStyle(d1).fontSize, "20px");
assert_equals(getComputedStyle(d1).width, "10px");
}, "Test nested :matches() chooses highest specificity for class outside :matches().");
test(() => {
assert_equals(getComputedStyle(e1).color, red);
}, "Test nested :matches() specificity for class within arguments.");
</script>
</body>
</html>