-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathdefined-in-has.html
More file actions
37 lines (35 loc) · 1.16 KB
/
defined-in-has.html
File metadata and controls
37 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<title>:has() invalidation with :defined pseudo-class</title>
<link rel="author" title="Tim Nguyen" href="https://github.com/nt1m">
<link rel="help" href="https://un5n798jx6qx6j0rmf2verhh.julianrbryant.com/selectors/#relational">
<link rel="help" href="https://un5nj90kzk5vf152hgyfw29h1eja2.julianrbryant.com/multipage/semantics-other.html#selector-defined">
<style>
#subject {
background-color: red;
width: 100px;
height: 100px;
}
#subject:has(:defined) {
background-color: green;
}
</style>
<body>
Test :defined pseudo-class invalidation with :has()
<div id="subject">
<my-element></my-element>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const GREEN = "rgb(0, 128, 0)";
const RED = "rgb(255, 0, 0)";
function assert_matches_defined(defined) {
assert_equals(getComputedStyle(subject).backgroundColor, defined ? GREEN : RED);
}
test(() => {
assert_matches_defined(false);
customElements.define("my-element", class MyElement extends HTMLElement { });
assert_matches_defined(true);
}, "Test :has() invalidation with :defined pseudo-class");
</script>
</body>