Skip to content

Commit

Permalink
Simplify maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 23, 2021
1 parent c893f76 commit 63c5bd3
Showing 1 changed file with 59 additions and 52 deletions.
111 changes: 59 additions & 52 deletions docs/tests/procedural-cosmetic-filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,133 +73,133 @@ <h3>Filters</h3>
<h3>Tests</h3>
<div id="pcf" class="tests">

<div id="a1" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a1 .fail:has(b)</code>
<code> .fail:has(b)</code>
</div>

<div id="a2" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a2 .fail:has(> a > b)</code>
<code> .fail:has(> a > b)</code>
</div>

<div id="a3" class="tile">
<div class="tile">
<div class="pass"><div class="fail"></div><a><b></b></a></div>
<code>#pcf #a3 .fail:has(+ a > b)</code>
<code> .fail:has(+ a > b)</code>
</div>

<div id="a4" class="tile">
<div class="tile">
<div class="pass"><div class="fail"></div><a><b></b></a></div>
<code>#pcf #a4 .fail:has(:scope + a > b)</code>
<code> .fail:has(:scope + a > b)</code>
</div>

<div id="a5" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a5 .fail:has(:is(.pass a > b))</code>
<code> .fail:has(:is(.pass a > b))</code>
</div>

<div id="a6" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a6 .fail:not(:has(c))</code>
<code> .fail:not(:has(c))</code>
</div>

<div id="a7" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b>I am a needle!!!</b></a></div></div>
<code>#pcf #a7 .fail:has-text(needle)</code>
<code> .fail:has-text(needle)</code>
</div>

<div id="a8" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b>I am a needle!!!</b></a></div></div>
<code>#pcf #a8 .fail:has-text(/NEEDLE/i)</code>
<code> .fail:has-text(/NEEDLE/i)</code>
</div>

<div id="a9" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b>I am a needle!!!</b></a></div></div>
<code>#pcf #a9 .fail:not(:has-text(haystack))</code>
<code> .fail:not(:has-text(haystack))</code>
</div>

<div id="a10" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a10 .fail:matches-css(position: absolute)</code>
<code> .fail:matches-css(position: absolute)</code>
</div>

<div id="a11" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a11 .fail:has(a:matches-css-before(opacity: 0))</code>
<code> .fail:has(a:matches-css-before(opacity: 0))</code>
</div>

<div id="a12" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a12 .fail:has(b:matches-css-after(opacity: 0))</code>
<code> .fail:has(b:matches-css-after(opacity: 0))</code>
</div>

<div id="a13" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a13 .fail > a > b:nth-ancestor(2)</code>
<code> .fail > a > b:nth-ancestor(2)</code>
</div>

<div id="a14" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a14:xpath(.//b/../..)</code>
<code>:xpath(.//b/../..)</code>
</div>

<div id="a15" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna<b>aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</b>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</a></div></div>
<code>#pcf #a15 .fail:min-text-length(300)</code>
<code> .fail:min-text-length(300)</code>
</div>

<div id="a16" class="tile">
<div class="tile">
<div class="pass"><a><b></b></a><div class="fail"></div></div>
<code>#pcf #a16 .pass > a:has(b) + .fail</code>
<code> .pass > a:has(b) + .fail</code>
</div>

<div id="a17" class="tile">
<div class="tile">
<div class="pass"><a><b></b></a><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a17 .pass > a:has(b) + .fail:has(b)</code>
<code> .pass > a:has(b) + .fail:has(b)</code>
</div>

<div id="a18" class="tile">
<div class="tile watchattr1">
<div class="pass"><div class="pass"><a><b class="ok"></b></a></div></div>
<code>#pcf #a18 .pass:watch-attr(class) > .fail:has(b.notok)</code>
<code> .pass:watch-attr(class) > .fail:has(b.notok)</code>
<script>
self.setTimeout(( ) =>
{
document.querySelector('#a18 .pass > .pass').className = 'fail';
document.querySelector('#a18 .pass > .fail b.ok').className = 'notok';
document.querySelector('.watchattr1 .pass > .pass').className = 'fail';
document.querySelector('.watchattr1 .pass > .fail b.ok').className = 'notok';
},
500
);
</script>
</div>

<div id="a19" class="tile">
<div class="tile">
<div class="pass"><div class="fail"></div><a></a><b></b></div>
<code>#pcf #a19 .fail:has(+ a)</code>
<code> .fail:has(+ a)</code>
</div>

<div id="a20" class="tile">
<div class="tile">
<div class="pass"><div class="fail"></div><a><b></b></a></div>
<code>#pcf #a20 .fail:has(~ a:has(b))</code>
<code> .fail:has(~ a:has(b))</code>
</div>

<div id="a21" class="tile">
<div class="tile">
<div class="pass"><div class="fail"></div><a><b></b></a></div>
<code>#pcf #a21 .fail:remove()</code>
<code> .fail:remove()</code>
</div>

<div id="a22" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a22 b:upward(2)</code>
<code> b:upward(2)</code>
</div>

<div id="a23" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a23 b:upward(.fail)</code>
<code> b:upward(.fail)</code>
</div>

<div id="a24" class="tile">
<div class="tile">
<div class="pass"><div class="fail"><a><b></b></a></div></div>
<code>#pcf #a24 b:upward(.fail):style(visibility: hidden !important)</code>
<code> b:upward(.fail):style(visibility: hidden !important)</code>
</div>

</div>
Expand All @@ -208,10 +208,17 @@ <h3>Tests</h3>
const hostname = self.location.hostname;
const filters = [];
const fragment = document.createDocumentFragment();
for ( const node of document.querySelectorAll('code') ) {
let i = 1;
for ( const tile of document.querySelectorAll('.tile') ) {
const id = `a${i}`;
tile.id = id;
const code = tile.querySelector('code');
const filter = `#pcf #${id}${code.textContent}`;
code.textContent = filter;
const div = document.createElement('div');
div.textContent = `${hostname}#?#${node.textContent}`;
div.textContent = `${hostname}#?#${filter}`;
fragment.appendChild(div);
i += 1;
}
const parent = document.querySelector('.filters');
while ( parent.lastElementChild !== null ) {
Expand Down

0 comments on commit 63c5bd3

Please sign in to comment.