Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[selectors-4] Can an element with no boxes and no child elements be in :hover state? #1141

Open
bzbarsky opened this issue Mar 29, 2017 · 4 comments
Labels
selectors-4 Current Work

Comments

@bzbarsky
Copy link

Consider this testcase:

<style>
  div { display: contents }
  div:hover { color: purple }
</style>
<div>This is some text</div>

When hovering over the text, does it turn purple? The spec is pretty unclear on when an element is actually "designated with a pointing device" and what that means for display:contents elements, exactly. Note that in this case there are no descendants of any sort matching :hover, because text nodes do not match :hover themselves.

@ghost
Copy link

ghost commented Mar 29, 2017

If I read the current draft[1] correctly, it says that that the deepest node in the chain of nodes that gets the :hover state must be an element, and must generate a box. There is no requirement that the ancestors need to generate boxes to get the :hover state, though. So for this case:

<div style="display:contents">
  <div>
    <div style="display:contents">Hover me</div>
  </div>
</div>

The inner display:contents does not match :hover, but the outer does.

#1135 is related.

[1] https://drafts.csswg.org/selectors/#the-hover-pseudo

@bzbarsky
Copy link
Author

I think the current draft leaves this totally undefined because "user designates an element" is totally undefined... I would like us to come closer to having it be defined.

I agree that in your testcase the outer display:contents should match :hover no matter how we slice this. The question is what should happen for the inner one.

@ghost
Copy link

ghost commented Mar 29, 2017

Right, I was too focused on the "hovers over a box generated by the element" part ignoring "For example".

@tabatkins
Copy link
Member

Intention is definitely that it gets the hover styles, whether it's the direct parent of a text node or a grandparent. Guess I need to rephrase the "if a shadow-inclusive descendant matches :hover" to instead say "is designated by a pointing device".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
selectors-4 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants