Skip to content
17 changes: 15 additions & 2 deletions features/nth-child.yml
Original file line number Diff line number Diff line change
@@ -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."
name: ":nth-child()"
description: "The `:nth-child()` and `:nth-last-child()` CSS functional pseudo-classes match elements based on their index within a list of elements. The `:first-child` and `:last-child` pseudo-classes match the first and last element in a list, and the `:only-child` pseudo-class matches an element with no siblings."
spec:
- https://drafts.csswg.org/selectors-3/#nth-child-pseudo
- https://drafts.csswg.org/selectors-3/#nth-last-child-pseudo
group: selectors
status:
compute_from: css.selectors.nth-child
compat_features:
- css.selectors.first-child
- css.selectors.first-child.no_parent_required
- css.selectors.last-child
- css.selectors.last-child.no_parent_required
- css.selectors.nth-child
- css.selectors.nth-child.no_parent_required
- css.selectors.nth-last-child
- css.selectors.nth-last-child.no_parent_required
- css.selectors.only-child
- css.selectors.only-child.no_parent_required
56 changes: 54 additions & 2 deletions features/nth-child.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,28 @@ status:
baseline_low_date: 2015-07-29
baseline_high_date: 2018-01-29
support:
chrome: "4"
chrome: "1"
chrome_android: "18"
edge: "12"
firefox: "3.5"
firefox_android: "4"
safari: "3.1"
safari_ios: "2"
compat_features:
# 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.last-child

# ⬇️ Same status as overall feature ⬇️
# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
Expand All @@ -27,7 +41,32 @@ compat_features:
# safari_ios: "2"
- css.selectors.nth-child

# ⬇️ Same status as overall feature ⬇️
# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
# support:
# chrome: "2"
# chrome_android: "18"
# edge: "12"
# firefox: "1.5"
# firefox_android: "4"
# safari: "3.1"
# safari_ios: "2"
- css.selectors.only-child

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

# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
Expand All @@ -40,3 +79,16 @@ compat_features:
# safari: "3.1"
# safari_ios: "2"
- css.selectors.nth-last-child

# baseline: false
# support:
# chrome: "57"
# chrome_android: "57"
# edge: "79"
# firefox: "52"
# firefox_android: "52"
- 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
Comment on lines +90 to +94
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.

10 changes: 10 additions & 0 deletions features/nth-of-type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: ":nth-of-type() pseudo-classes"
description: "The `:nth-of-type()` and `:nth-last-of-type()` CSS functional pseudo-classes match elements based on their position among siblings of the same type. The `:first-of-type`, `:last-of-type`, and :only-of-type` pseudo-classes match the first, last, and only elements of its type."
spec: https://drafts.csswg.org/selectors-4/#typed-child-index
group: selectors
compat_features:
- css.selectors.nth-last-of-type
- css.selectors.first-of-type
- css.selectors.last-of-type
- css.selectors.nth-of-type
- css.selectors.only-of-type
45 changes: 45 additions & 0 deletions features/nth-of-type.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated from: nth-of-type.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: "4"
chrome_android: "18"
edge: "12"
firefox: "3.5"
firefox_android: "4"
safari: "3.1"
safari_ios: "2"
compat_features:
# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
# support:
# chrome: "1"
# chrome_android: "18"
# edge: "12"
# firefox: "3.5"
# firefox_android: "4"
# safari: "3.1"
# safari_ios: "2"
- css.selectors.first-of-type
- css.selectors.last-of-type
- css.selectors.nth-of-type
- css.selectors.only-of-type

# ⬇️ Same status as overall feature ⬇️
# baseline: high
# baseline_low_date: 2015-07-29
# baseline_high_date: 2018-01-29
# support:
# chrome: "4"
# chrome_android: "18"
# edge: "12"
# firefox: "3.5"
# firefox_android: "4"
# safari: "3.1"
# safari_ios: "2"
- css.selectors.nth-last-of-type