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

Simplifying the hover and active quirks? #75

Open
emilio opened this issue Mar 26, 2024 · 2 comments
Open

Simplifying the hover and active quirks? #75

emilio opened this issue Mar 26, 2024 · 2 comments

Comments

@emilio
Copy link

emilio commented Mar 26, 2024

What is the issue with the Quirks Mode Standard?

https://quirks.spec.whatwg.org/#the-active-and-hover-quirk has a list of conditions that doesn't keep up with new CSS features.

It seems implementations do subtly different things that end up in subtle bugs like https://bugzilla.mozilla.org/show_bug.cgi?id=1856285:

I think Blink's behavior (which if I understand correctly is "only apply the quirk if the only thing in the selector is :hover or :active and it's not nested) is simpler, and I think we should change the spec to match that, if my understanding is correct.

@lilles / @andruud: Could you confirm my read of Blink's source is correct?
@annevk: Would WebKit be fine with that change? If so I'd be happy to send a PR.

cc @whatwg/css, I assume making stuff less quirky is generally good if we can get away with it...

@annevk
Copy link
Member

annevk commented Mar 27, 2024

Tests would be good to verify that's indeed Chromium's behavior. I think WebKit would be okay with attempting to align with that, yes.

@emilio
Copy link
Author

emilio commented Mar 27, 2024

Here's a test-case. One quirk here is that at least Blink and Gecko parse *:hover and :hover to exactly the same thing. So ignoring that * special-case, yes, I think the chromium behavior is as I described above (for simple selectors at least). Not sure what the is_sub_selector in chromium conveys, it seems a mix of "being used for pseudo-elements" and "being in a nested pseudo-class / slotted / etc thing".

<!doctype html>
<body>
<script>
  let selectors = [
    `*:hover`,
    `:hover`,
    `span:hover`,
    `:is(a, span):hover`,
    `:is(span):hover`,
    `:not(div):hover`,
    `[data-attr]:hover`,
    `:hover:nth-child(1)`,
    `:hover:first-child`,
  ];

  for (let selector of selectors) {
    let frame = document.createElement("iframe");
    frame.src = `data:text/html,` + encodeURIComponent(`
      <style>${selector} { background-color: rgba(0, 0, 0, .2) }</style>
      <div id=root>
        <p><strong>${selector}</strong>
        <p><a data-attr href="#">Link</a>
        <p><span data-attr>Non-link</span>
      </div>
    `);
    document.body.appendChild(frame);
  }
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants