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

Carryover evaluation: CSS :has() pseudo-class #432

Closed
2 of 3 tasks
mayank99 opened this issue Sep 16, 2023 · 9 comments
Closed
2 of 3 tasks

Carryover evaluation: CSS :has() pseudo-class #432

mayank99 opened this issue Sep 16, 2023 · 9 comments
Labels
carryover-evaluation Evaluate whether to continue a focus area in the next year focus area: :has()

Comments

@mayank99
Copy link

Description

MDN description:

The functional :has() CSS pseudo-class represents an element if any of the relative selectors that are passed as an argument match at least one element when anchored against this element. This pseudo-class presents a way of selecting a parent element or a previous sibling element with respect to a reference element by taking a relative selector list as an argument.

Example:

/* Selects an h1 heading with a
paragraph element that immediately follows
the h1 and applies the style to h1 */
h1:has(+ p) {
  margin-bottom: 0;
}

Specification

https://drafts.csswg.org/selectors-4/#relational

Open Issues

No response

Tests

https://wpt.fyi/results/css/selectors?q=has

Current Implementations

  • Blink
  • Gecko
  • WebKit

Standards Positions

No response

Browser bug reports

https://bugzilla.mozilla.org/show_bug.cgi?id=418039

Developer discussions

No response

Polls & Surveys

https://2023.stateofcss.com/en-US/features/other-features#has_selector

Existing Usage

No response

Workarounds

No response

Accessibility Impact

No response

Privacy Impact

No response

Other

We still have a few months left in 2023 so there's a chance this might get implemented in Gecko, in which case this doesn't need to be part of interop 2024. 🤷

@mayank99 mayank99 added the focus-area-proposal Focus Area Proposal label Sep 16, 2023
@foolip
Copy link
Member

foolip commented Sep 18, 2023

@mayank99 it sounds like you probably know this, but this is part of https://wpt.fyi/interop-2023. We're going to evaluate all current proposal for carryover into 2024, and I'll take you filing this issue as a vote in favor of keeping :has() if it isn't done by the end of the year.

@BearCooder
Copy link

Firefox has enabled :has() support on Nightly! Should be in tomorrow's build.
https://bugzilla.mozilla.org/show_bug.cgi?id=1853701

@mayank99
Copy link
Author

i'll wait for this to show up in Firefox stable (i believe v119) then close this issue

@foolip foolip added the carryover-evaluation Evaluate whether to continue a focus area in the next year label Sep 21, 2023
@foolip
Copy link
Member

foolip commented Sep 21, 2023

I've added the carryover-evaluation label as this is about continuing/expanding an existing focus area.

@jensimmons
Copy link
Contributor

i'll wait for this to show up in Firefox stable (i believe v119) then close this issue

No, please do not close this issue, @mayank99. The group planning Interop 2024 will consider whether or not we want to carry this focus area over until the next year. We might have reasons to keep working on :has().

@mayank99
Copy link
Author

ah ok, i'll keep it open then.

@jensimmons
Copy link
Contributor

I started a spreadsheet of all the pseudo-classes that could be supported inside of :has(), hoping to figure out who supports what, with the goal of getting this data submitted to MDN's BCD project (where it would all get surfaced on Can I Use).

https://docs.google.com/spreadsheets/d/1NZeNiJqOEiphHJiAIB9iWsp2yxsn8fsqAJj1syM6K10/edit?usp=sharing

Screenshot 2023-09-21 at 5 29 42 PM

I think it'd be terrific to create tests for all of these, and add them to Interop 2024. Being able to use pseudo-classes inside of :has() significantly increases their usefulness. For example, :has(:playing) targets an element if there's a video or audio element playing inside of it. :has(:user-invalid) targets an element if there's a form field inside of it that's in an invalid state — making it very easy, for example, to create a red border on a text label when its field is not filled out correctly.

@jensimmons
Copy link
Contributor

(Here's the rest of the list on the spreadsheet, or click the link above. Anyone should be able to access it.)

Screenshot 2023-09-21 at 5 33 42 PM

@jensimmons jensimmons changed the title CSS :has() pseudo-class Carryover evaluation: CSS :has() pseudo-class Sep 21, 2023
@foolip foolip added focus area: :has() and removed focus-area-proposal Focus Area Proposal labels Sep 22, 2023
@jensimmons
Copy link
Contributor

I opened a new proposal for the idea of extending :has()
#555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
carryover-evaluation Evaluate whether to continue a focus area in the next year focus area: :has()
Projects
Status: Done
Development

No branches or pull requests

5 participants