Skip to content
New issue

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

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

Already on GitHub? # to your account

Selectors - and indexed pseudo classes #2168

Merged
merged 11 commits into from
Nov 14, 2024

Conversation

jamesnw
Copy link
Collaborator

@jamesnw jamesnw commented Nov 6, 2024

See #2170 for more info

@github-actions github-actions bot added the feature definition Creating or defining new features or groups of features. label Nov 6, 2024
@jamesnw jamesnw marked this pull request as ready for review November 12, 2024 19:57
@@ -1,6 +1,19 @@
name: ":nth-child() (initial support)"
description: "The `:nth-child()` and `:nth-last-child()` CSS functional pseudo-classes match elements by the relative position of elements (first, second, third, fourth, and so on), counted from the first or last sibling."
description: "The `:nth-child()` and `:nth-last-child()` CSS functional pseudo-classes match elements by their relative position, counted from the first or last sibling. The `:first-child`, `:last-child`, and `:only-child` pseudo-classes represent common use cases."
Copy link
Contributor

Choose a reason for hiding this comment

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

Position within what?
Possible suggestion:

Suggested change
description: "The `:nth-child()` and `:nth-last-child()` CSS functional pseudo-classes match elements by their relative position, counted from the first or last sibling. The `:first-child`, `:last-child`, and `:only-child` pseudo-classes represent common use cases."
description: "The `:nth-child()` and `:nth-last-child()` CSS functional pseudo-classes match elements based on their relative position within a list of elements, counted from the first or last sibling. The `:first-child`, `:last-child`, and `:only-child` pseudo-classes represent common use cases."

Also, "represent common use cases" feels improvable. This doesn't describe what these pseudos do.

Comment on lines +90 to +94
- css.selectors.first-child.no_parent_required
- css.selectors.last-child.no_parent_required
- css.selectors.nth-child.no_parent_required
- css.selectors.nth-last-child.no_parent_required
- css.selectors.only-child.no_parent_required
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm unclear as to what these subfeatures cover. Can you help me understand?
Would they make sense as a separate feature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Selectors level 3 had text referring to the children's parent, but selectors level 4 adds the note-

As there was no reason to exclude them from matching elements without parents, or with non-element parents, they have been rephrased to refer to an element’s relative index amongst its siblings.

For instance, the document root matches :first-child despite having no parent.

This doesn't seem like a feature to me. It also looks like Safari data might be incorrect, as document.documentElement.matches(":first-child") returns true in Safari.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Keeping them here, ignored, seems right then.

features/nth-child.yml Outdated Show resolved Hide resolved
@@ -0,0 +1,10 @@
name: ":nth-of-type() pseudo-classes"
description: "The `:nth-of-type()` CSS functional pseudo-classes match elements based on their position among siblings of the same type, counted from the first or last sibling. The `:only-of-type` pseudo-class matches any element that is the only child of its type, of its parent."
Copy link
Contributor

Choose a reason for hiding this comment

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

The first sentence only mentions :nth-of-type(), but uses the plural "pseudo-classes", which feels odd.
We might want to list all the pseudo-classes, like we do in the nth-child feature above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated this- it's a lot to cram into 300 characters, and I'd welcome other verbage.

Copy link
Contributor

@captainbrosset captainbrosset left a comment

Choose a reason for hiding this comment

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

Approved, modulo my comment about the "(initial support)" note, which I don't think we need, but could be convinced otherwise.

Comment on lines +90 to +94
- css.selectors.first-child.no_parent_required
- css.selectors.last-child.no_parent_required
- css.selectors.nth-child.no_parent_required
- css.selectors.nth-last-child.no_parent_required
- css.selectors.only-child.no_parent_required
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Keeping them here, ignored, seems right then.

Co-authored-by: Patrick Brosset <patrickbrosset@gmail.com>
@jamesnw jamesnw enabled auto-merge (squash) November 14, 2024 13:42
@jamesnw jamesnw merged commit 794f4ff into web-platform-dx:main Nov 14, 2024
3 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature definition Creating or defining new features or groups of features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants