

Github [selectors] :focus-visible and Shadow DOM · Issue #5893 · w3c/csswg-draft...
source link: https://github.com/w3c/csswg-drafts/issues/5893
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

The spec doesn't mention anything of what happen on a ShadowRoot
is the root of an element that is focused. The ShadowRoot
matches :focus
(see HTML spec but I believe it shouldn't match :focus-visible
or you'll get 2 outlines.
WebKit has implemented a :-webkit-direct-focus
internal pseudo-class to avoid this issue (see bug #202432)
Example:
<div id="host" style="width: 200px; height: 100px; padding: 1em;"></div> <script> const shadowRoot = host.attachShadow({mode: 'open', delegatesFocus: true}); shadowRoot.innerHTML = '<input autofocus value="Focus me">'; </script>
Here if you focus the <input>
you'll get 2 outlines right now in Chromium (one in the host
and another in the <input>
, both match :focus
which is right, and also :focus-visible
). That won't happen in WebKit thanks to that special UA stylesheet rule. In Firefox it looks like there are other problems because the host
doesn't match :focus
.
So the question is, should the :focus-visible
spec include some text about this and describe WebKit's behavior?
Recommend
-
6
Three Topics For Jan 2020 CSSWG MeetingCSSWG Meeting Jan 2020, SpainV...
-
9
Collaborator frivoal commented
-
9
222028 – [selectors] :focus-visible implementation Status: RESOLVED FIXED
-
7
Conversation Copy link Member ...
-
10
224598 – [selectors] Script focus and :focus-visible Status: RESOLVED FIXED
-
13
225075 – [selectors] Using a modifier key on an element makes it stop matching :focus-visible Status: RESOLVED FIXED...
-
12
225148 – [selectors] :focus-visible and keyboard events WebKit Bugzilla Bug 225148: [selectors] :focus-visible and keyboard events ...
-
8
Copy link Collaborator
-
8
Back in the CSSWG Published 2 days past As you might have noticed, I recently wrote about
-
4
Code Triage HomeThe easiest way to get started contributing to Open Source html projects like csswg-draftsPick your favorite repos to receive a different open issue in your inbox...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK