forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[selectors4] Add one more test for :focus-within and Shadow DOM
This test is similar to the example in w3c/csswg-drafts#1135. It checks that when the slotted element is focused, ":focus-within" pseudo-class affects to the ancestors in the flat tree.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Selectors Level 4: focus-within with shadow DOM</title> | ||
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> | ||
<link rel="help" href="https://drafts.csswg.org/selectors-4/#focus-within-pseudo"> | ||
<link rel="help" href="https://dom.spec.whatwg.org/#shadow-trees"> | ||
<link rel="match" href="focus-within-shadow-001-ref.html"> | ||
<meta name="flags" content="interact dom"> | ||
<meta name="assert" content="Checks that ':focus-within' is propagated to the flat tree ancestors, even if it comes from a slotted element."> | ||
<style> | ||
/* Suppress things that cannot be reproduced in the reference file */ | ||
:focus { | ||
outline: none; | ||
} | ||
:focus-within { | ||
border-color: green; | ||
} | ||
</style> | ||
<p>Test passes if there is a green rectangle below.</p> | ||
|
||
<div id="log"></div> | ||
<script> | ||
if (!document.body.attachShadow) | ||
document.getElementById("log").innerHTML = "<strong>Skip this test, shadow DOM is not supported.</strong>"; | ||
</script> | ||
|
||
<div id="shadow-host"> | ||
<div id="focusme" tabindex="1"></div> | ||
</div> | ||
|
||
<script> | ||
var shadowHost = document.getElementById("shadow-host"); | ||
shadowHost.attachShadow({ mode: "open"}).innerHTML = | ||
"<style>" + | ||
" #shadow-div:focus-within { border: solid 15px green; }" + | ||
"</style>" + | ||
"<div id='shadow-div'>" + | ||
" <slot></slot>" + | ||
"</div>"; | ||
var focusme = document.getElementById("focusme"); | ||
focusme.focus(); | ||
</script> |