tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

has-invalidation-for-wiping-an-element.html (1412B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>:has() invalidation for wiping an element by means of innerHTML</title>
      4 <link rel="author" title="Byungwoo Lee" href="mailto:blee@igalia.com">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <link rel="help" href="https://drafts.csswg.org/selectors/#relational">
      8 <style>
      9 div, main { color: grey }
     10 .subject:has(.descendant) { color: green}
     11 </style>
     12 <main id=main>
     13  <div id="subject" class="subject"></div>
     14 </main>
     15 <script>
     16  let grey = 'rgb(128, 128, 128)';
     17  let green = 'rgb(0, 128, 0)';
     18 
     19  function test_div(test_name, el, color) {
     20    test(function() {
     21      assert_equals(getComputedStyle(el).color, color);
     22    }, test_name + ': div#' + el.id + '.color');
     23  }
     24 
     25  test_div('initial color', subject, grey);
     26 
     27  subject.innerHTML = "This is a text <div><div class='descendant'></div></div>";
     28 
     29  test_div('color after inserting text and div > .descendant', subject, green);
     30 
     31  subject.innerHTML = "This is a text";
     32 
     33  test_div('color after wiping #child to remove div > .descendant', subject, grey);
     34 
     35  subject.innerHTML = "<div id='child'> This is a text <div class='descendant'></div></div>";
     36 
     37  test_div('color after inserting text and #child > .descendant', subject, green);
     38 
     39  child.innerHTML = "This is a text";
     40 
     41  test_div('color after wiping #child to remove .descendant', subject, grey);
     42 </script>