Skip to content

Commit

Permalink
Clarify support for ::slotted(:has(...)) as established by WebKit (#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook authored Jan 28, 2025
1 parent ed2d678 commit 1b476ff
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
26 changes: 26 additions & 0 deletions css/css-scoping/slotted-has-001.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!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;
}
::slotted(:has(:first-child)) {
display: block;
width: 100px;
height: 100px;
background-color: green;
}
</style>
<slot></slot>
</template>
<div><div></div></div>
</div>
26 changes: 26 additions & 0 deletions css/css-scoping/slotted-has-002.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!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;
}
::slotted(:has(:last-child)) {
display: block;
width: 100px;
height: 100px;
background-color: green;
}
</style>
<slot></slot>
</template>
<div><div></div></div>
</div>
26 changes: 26 additions & 0 deletions css/css-scoping/slotted-has-003.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!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;
}
::slotted(:has(:first-child:last-child)) {
display: block;
width: 100px;
height: 100px;
background-color: green;
}
</style>
<slot></slot>
</template>
<div><div></div></div>
</div>
26 changes: 26 additions & 0 deletions css/css-scoping/slotted-has-004.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!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;
}
::slotted(:not(:has(:first-child:last-child))) {
display: block;
width: 100px;
height: 100px;
background-color: green;
}
</style>
<slot></slot>
</template>
<div></div>
</div>
1 change: 1 addition & 0 deletions css/selectors/parsing/parse-slotted.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
test_valid_selector('::slotted(:not(:nth-last-of-type(2)):not([slot="foo"]))');
test_valid_selector("::slotted(:first-child)");
test_valid_selector("::slotted(:hover)");
test_valid_selector("::slotted(:has(:first-child:last-child))");
test_invalid_selector("::slotted");
test_invalid_selector("::slotted()");
test_invalid_selector("::slotted(0)");
Expand Down

0 comments on commit 1b476ff

Please sign in to comment.