Skip to content

Commit

Permalink
Speculativly test :has-slotted(), see: w3c/csswg-drafts#10586
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed Sep 23, 2024
1 parent 3f9ec61 commit 912713b
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 0 deletions.
23 changes: 23 additions & 0 deletions css/css-scoping/has-slotted-001.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<meta charset="utf-8">
<title>:has-slotted(*)</title>
<link rel="help" href="https://github.com/w3c/csswg-drafts/pull/10586">
<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
<p>Test passes if there is a filled green square.</p>
<div id="host">
<template shadowrootmode="open">
<style>
slot {
display: block;
width: 100px;
height: 100px;
background-color: red;
}
:has-slotted(*) {
background-color: green;
}
</style>
<slot></slot>
</template>
<div></div>
</div>
20 changes: 20 additions & 0 deletions css/css-scoping/has-slotted-002.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<meta charset="utf-8">
<title>:has-slotted(...) negative test: no children or white space</title>
<link rel="help" href="https://github.com/w3c/csswg-drafts/pull/10586">
<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
<p>Test passes if there is a filled green square.</p>
<div id="host"><template shadowrootmode="open">
<style>
slot {
display: block;
width: 100px;
height: 100px;
background-color: green;
}
:has-slotted(*) {
background-color: red;
}
</style>
<slot></slot>
</template></div>
22 changes: 22 additions & 0 deletions css/css-scoping/has-slotted-003.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<meta charset="utf-8">
<title>:has-slotted(...) negative test: no children, but whitespace present</title>
<link rel="help" href="https://github.com/w3c/csswg-drafts/pull/10586">
<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
<p>Test passes if there is a filled green square.</p>
<div id="host">
<template shadowrootmode="open">
<style>
slot {
display: block;
width: 100px;
height: 100px;
background-color: green;
}
:has-slotted(*) {
background-color: red;
}
</style>
<slot></slot>
</template>
</div>
23 changes: 23 additions & 0 deletions css/css-scoping/has-slotted-004.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<meta charset="utf-8">
<title>:has-slotted(.class)</title>
<link rel="help" href="https://github.com/w3c/csswg-drafts/pull/10586">
<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
<p>Test passes if there is a filled green square.</p>
<div id="host">
<template shadowrootmode="open">
<style>
slot {
display: block;
width: 100px;
height: 100px;
background-color: red;
}
:has-slotted(.slotted-element) {
background-color: green;
}
</style>
<slot></slot>
</template>
<div class="slotted-element"></div>
</div>
23 changes: 23 additions & 0 deletions css/css-scoping/has-slotted-005.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<meta charset="utf-8">
<title>:has-slotted(.class) negative test</title>
<link rel="help" href="https://github.com/w3c/csswg-drafts/pull/10586">
<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
<p>Test passes if there is a filled green square.</p>
<div id="host">
<template shadowrootmode="open">
<style>
slot {
display: block;
width: 100px;
height: 100px;
background-color: green;
}
:has-slotted(.not-slotted-element) {
background-color: red;
}
</style>
<slot></slot>
</template>
<div class="slotted-element"></div>
</div>
25 changes: 25 additions & 0 deletions css/css-scoping/has-slotted-006.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<meta charset="utf-8">
<title>:has-slotted(el) + :has-slotted(el)</title>
<link rel="help" href="https://github.com/w3c/csswg-drafts/pull/10586">
<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
<p>Test passes if there is a filled green square.</p>
<div id="host">
<template shadowrootmode="open">
<style>
[name] {
display: block;
width: 100px;
height: 100px;
background-color: red;
}
:has-slotted(div) + :has-slotted(div) {
background-color: green;
}
</style>
<slot></slot>
<slot name="after"></slot>
</template>
<div></div>
<div slot="after"></div>
</div>
32 changes: 32 additions & 0 deletions css/selectors/parsing/parse-has-slotted.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<meta charset="utf-8" />
<title>CSS Selectors: has slotted pseudo selectors</title>
<link rel="help" href="https://github.com/w3c/csswg-drafts/pull/10586" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
test_valid_selector(":has-slotted(bar)");
test_valid_selector(':has-slotted([attr="foo"])');
test_valid_selector(":has-slotted(*)");
test_valid_selector(":has-slotted(.class)");
test_valid_selector(":has-slotted(#id)");
test_valid_selector(":has-slotted(:not(foo))");
test_valid_selector(':has-slotted(:not(:nth-last-of-type(2)):not([slot="foo"]))');
test_valid_selector(":has-slotted(:first-child)");
test_valid_selector(":has-slotted(:hover)");
test_valid_selector(":has-slotted(foo):first-child");
test_valid_selector(":has-slotted(foo):hover");
test_valid_selector(":has-slotted(foo):focus");
test_valid_selector(":has-slotted(foo):lang(en)");
test_valid_selector(":has-slotted(foo):dir(ltr)");
test_valid_selector(':has-slotted(foo) + :has-slotted(bar)');
test_valid_selector(":not(:has-slotted(foo))");
test_valid_selector(":has-slotted(div + div)");
test_valid_selector(":has-slotted(div:has(> span))");
test_invalid_selector("::has-slotted(foo)");
test_invalid_selector(":has-slotted");
test_invalid_selector(":has-slotted()");
test_invalid_selector(":has-slotted(0)");
test_invalid_selector(":has-slotted(div > span)");
</script>

0 comments on commit 912713b

Please sign in to comment.