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- CSS Selectors initial support #2170

Merged
merged 9 commits into from
Nov 21, 2024
32 changes: 32 additions & 0 deletions features/css-selectors.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the right thing to do, but one other way of looking at this would be to have distinct features here:

  • type selectors (universal, type)
  • combinators (list, child, descendant, next sibling, subsequent sibling)
  • attribute selectors (attribute, class, id)
  • user action pseudos (hover, active, focus)
  • input selectors (checked, disabled, enabled)

It leaves some weird loners though (root, target, empty, lang).

This feels slightly more meaningful—e.g., as a developer, some of these would answer the question of "I want to select a…"—for some of them, but not all ("combinators" is not exactly a "feature" so much as a foundational language construct).

I haven't really convinced myself either way here. Would be interested to know your take, having seen this though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I look at this, I think this breakout makes sense, and make sense to do as the first pass. I think the weird loners can be weird loner features fairly easily.

I've marked the other sets of selectors ready for review, and will work on splitting this one up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root, target, empty, and lang are scenario specific, and might be good to move into their own features.
I like Daniel's idea, I like being able to use web-features to answer developer questions, even if the things they're asking about are kind of old and mostly taken for granted.

That said, I would personally group type selectors, combinators, and attribute selectors into a single "Selector initial support" feature.
They're more features of the language than capabilities. They don't allow you to implement specific developer scenarios.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we're in agreement that the pseudo classes should be split out into features, so I did that in #2229. That leaves the language features- type selectors, combinators, and attribute selectors.

@ddbeck Would you be amenable to grouping those into a Selector initial support feature? This would be somewhat similar to what was done in caniuse. Although that also includes the pseudo classes, they also didn't feel the need to split out further.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be fine. If you want to try out some way of naming this doesn't feel so frozen in time though, I would welcome that (maybe even "Selectors (core)" or "Selectors (common)"). Eventually, I'd expect some of the "newer" ones to be acknowledged as basic CSS functionality (e.g., in a few years, I'd imagine that :not() would join these) and it'd be nice if we didn't commit ourselves to a permanent view of this feature.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CSS selectors (initial support)
description: CSS selectors [TODO]
spec: https://drafts.csswg.org/selectors-4/
status:
compute_from: css.selectors.class
compat_features:
- css.selectors.active
- css.selectors.active.non_a_elements
- css.selectors.child
- css.selectors.class
- css.selectors.descendant
- css.selectors.focus
- css.selectors.id
- css.selectors.list
- css.selectors.next-sibling
- css.selectors.root
- css.selectors.type
- css.selectors.universal
- css.selectors.type.namespaces
- css.selectors.universal.namespaces
- css.selectors.target
- css.selectors.hover
- css.selectors.attribute
- css.selectors.subsequent-sibling
- css.selectors.checked
- css.selectors.disabled
- css.selectors.empty
- css.selectors.empty.matches_whitespace
- css.selectors.enabled
- css.selectors.lang
- css.selectors.not
- css.selectors.not.selector_list
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:not might be its own thing—it "feels" newer to me 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also feels new to me for some reason, strange because it's been supported forever. The selector_list subfeature, however, is much newer. So I agree with Daniel about moving them both to a separate feature because of this.

129 changes: 129 additions & 0 deletions features/css-selectors.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Generated from: css-selectors.yml
# Do not edit this file by hand. Edit the source file instead!

status:
baseline: high
baseline_low_date: 2015-07-29
baseline_high_date: 2018-01-29
support:
chrome: "1"
chrome_android: "18"
edge: "12"
firefox: "1"
firefox_android: "4"
safari: "1"
safari_ios: "1"
compat_features:
# ⬇️ Same status as overall feature ⬇️
# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
# support:
# chrome: "1"
# chrome_android: "18"
# edge: "12"
# firefox: "1"
# firefox_android: "4"
# safari: "1"
# safari_ios: "1"
- css.selectors.active
- css.selectors.active.non_a_elements
- css.selectors.child
- css.selectors.class
- css.selectors.descendant
- css.selectors.focus
- css.selectors.id
- css.selectors.list
- css.selectors.next-sibling
- css.selectors.root
- css.selectors.type
- css.selectors.universal

# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
# support:
# chrome: "1"
# chrome_android: "18"
# edge: "12"
# firefox: "1"
# firefox_android: "4"
# safari: "1.3"
# safari_ios: "1"
- css.selectors.type.namespaces
- css.selectors.universal.namespaces

# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
# support:
# chrome: "1"
# chrome_android: "18"
# edge: "12"
# firefox: "1"
# firefox_android: "4"
# safari: "1.3"
# safari_ios: "2"
- css.selectors.target

# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
# support:
# chrome: "1"
# chrome_android: "18"
# edge: "12"
# firefox: "1"
# firefox_android: "4"
# safari: "2"
# safari_ios: "1"
- css.selectors.hover

# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
# support:
# chrome: "1"
# chrome_android: "18"
# edge: "12"
# firefox: "1"
# firefox_android: "4"
# safari: "3"
# safari_ios: "1"
- css.selectors.attribute
- css.selectors.subsequent-sibling

# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
# support:
# chrome: "1"
# chrome_android: "18"
# edge: "12"
# firefox: "1"
# firefox_android: "4"
# safari: "3.1"
# safari_ios: "2"
- css.selectors.checked
- css.selectors.disabled
- css.selectors.empty
- css.selectors.enabled
- css.selectors.lang
- css.selectors.not

# baseline: high
# baseline_low_date: 2021-01-21
# baseline_high_date: 2023-07-21
# support:
# chrome: "88"
# chrome_android: "88"
# edge: "88"
# firefox: "84"
# firefox_android: "84"
# safari: "9"
# safari_ios: "9"
- css.selectors.not.selector_list

# baseline: false
# support: {}
- css.selectors.empty.matches_whitespace