tor-browser

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

scope-layer.html (1374B)


      1 <!DOCTYPE html>
      2 <title>@scope - inner @layer</title>
      3 <link rel="help" href="https://drafts.csswg.org/css-cascade-6/#scope-atrule">
      4 <link rel="help" href="https://drafts.csswg.org/css-cascade-5/#layering">
      5 <link rel="help" href="https://drafts.csswg.org/css-cascade-5/#scope-scope">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <style>
      9  @scope (.a) {
     10    /* The theme layer wins over the base layer. Note that @layer statements
     11       are allowed here, but aren't affected by the enclosing @scope. */
     12    @layer base, theme;
     13 
     14    @layer theme {
     15      :scope {
     16        z-index: 1;
     17      }
     18 
     19      .b {
     20        background-color: green;
     21      }
     22    }
     23  }
     24 
     25  @layer base {
     26    .a {
     27      z-index: 0;
     28    }
     29    .a .b {
     30      background-color: red;
     31    }
     32  }
     33 </style>
     34 <main>
     35  <div class=a>
     36    <div class=b>
     37    </div>
     38  </div>
     39  <div class=b></div>
     40 </main>
     41 <script>
     42  test(() => {
     43    let a = document.querySelector('main > .a');
     44    let b = document.querySelector('main > .a > .b');
     45    assert_equals(getComputedStyle(a).zIndex, '1');
     46    assert_equals(getComputedStyle(b).backgroundColor, 'rgb(0, 128, 0)');
     47 
     48    let out_of_scope_b = document.querySelector('main > .b');
     49    assert_equals(getComputedStyle(out_of_scope_b).backgroundColor, 'rgba(0, 0, 0, 0)');
     50  }, 'Style rules within @layer are scoped');
     51 </script>