tor-browser

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

ParentNode-querySelector-scope.html (1057B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>querySelector(All) scoped to a root element</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <div><h1 id="test"></h1><p><span>hello</span></p></div>
      8 
      9 <script>
     10 "use strict";
     11 const div = document.querySelector("div");
     12 const p = document.querySelector("p");
     13 
     14 test(() => {
     15  assert_equals(div.querySelector(":scope > p"), p);
     16  assert_equals(div.querySelector(":scope > span"), null);
     17 }, "querySelector with :scope");
     18 
     19 test(() => {
     20  assert_equals(div.querySelector("#test + p"), p);
     21  assert_equals(p.querySelector("#test + p"), null);
     22 }, "querySelector with id and sibling");
     23 
     24 test(() => {
     25  assert_array_equals(div.querySelectorAll(":scope > p"), [p]);
     26  assert_array_equals(div.querySelectorAll(":scope > span"), []);
     27 }, "querySelectorAll with :scope");
     28 
     29 test(() => {
     30  assert_array_equals(div.querySelectorAll("#test + p"), [p]);
     31  assert_array_equals(p.querySelectorAll("#test + p"), []);
     32 }, "querySelectorAll with id and sibling");
     33 </script>