Closed Bug 1682207 Opened 3 years ago Closed 3 years ago

Element.matches(":hover") returns false even when element is hovered

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

RESOLVED INVALID

People

(Reporter: Jamie, Unassigned)

References

Details

STR:

  1. Open this:
    data:text/html,<div id="div"><button id="button">text
  2. Move the mouse over the button.
  3. Open the web console with the keyboard (e.g. control+shift+k on Windows). Do not move the mouse.
  4. Enter this:
    div.matches(":hover")
    • Expected: true
    • Actual: false
  5. Enter this:
    button.matches(":hover")
    • Expected: true
    • Actual: false
  6. Enter this:
    div.matches("div:hover")
    • Correct result: true
  7. Enter this:
    button.matches("button:hover")
    • Correct result: true

Discovered while working on bug 494175; see Phabricator comment. However, I might be misunderstanding something here, so marking as unconfirmed. Also, Gijs noted he couldn't reproduce this:

it works for me when testing with setInterval(() => console.log(window.document.documentElement.matches(":hover")), 500) in the browser console and hovering the toolbar vs not hovering it.

Works the same in other browsers. You should not use quirks mode ;)

https://quirks.spec.whatwg.org/#the-active-and-hover-quirk

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.