summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/selectors/invalidation/has-invalidation-after-removing-non-first-element.html
blob: 482f07b8af616cf90def93180af6a1e30437c188 (plain)
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
<!DOCTYPE html>
<meta charset="utf-8">
<title>:has() invalidation after removing non-first element</title>
<link rel="author" title="Byungwoo Lee" href="mailto:blee@igalia.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://drafts.csswg.org/selectors/#relational">
<style>
div, main { color: grey }
#subject:has(descendant) { color: red }
</style>
<main id="main">
  <div id="subject">
    <div></div>
    <descendant id="descendant"></descendant>
  </div>
</main>
<script>
  let grey = 'rgb(128, 128, 128)';
  let red = 'rgb(255, 0, 0)';

  function test_div(test_name, el, color) {
    test(function() {
      assert_equals(getComputedStyle(el).color, color);
    }, test_name + ': div#' + el.id + '.color');
  }

  test_div('initial_color', subject, red);
  subject.removeChild(descendant);
  test_div('remove descendant', subject, grey);
</script>