Skip to content

[selectors-4] About shadow-including descendants #1135

@mrego

Description

@mrego

For three pseudo-classes (:hover, :active and :focus-within) the spec has a similar text:

An element also matches :hover if one of its shadow-including descendants matches :hover.

The reference to shadow-including descendants was introduced back in April 2016 by @tabatkins.

However it seems it doesn't match the behavior in either Chrome and Safari.
Using an example from @rune-opera:

  <div id="host">
    <span>Hover me</span>
  </div>
  <script>
    host.attachShadow({mode:"open"}).innerHTML = "<style>#shadowDiv:hover { border: 5px solid green }</style><div id='shadowDiv'><slot></slot></div>";
  </script>

In both Blink and WebKit a green border appears on the shadowDiv when you hover the <span>. This seems the right behavior from the user point of view.
However, the <span> is not a shadow-including descendant of the shadowDiv. Shouldn't the spec mention the flat tree instead?

This discussion started on the blink-dev thread about :focus-within.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions