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

Additional fix for :nth-child(n+B) #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

super-dm3
Copy link
Contributor

@super-dm3 super-dm3 commented Nov 14, 2024

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

:nth-child(n+B) selects only B-th elements

What is the new behavior?

:nth-child(n+B) selects B-th and all following elements
See: https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child#nth-childn7

Does this introduce a breaking change?

  • Yes
  • No

Other information

  • This is an additional fix for PR #56.
    My previous PR didn't actually fix the nth-child(n+B) bug. Two duplicate functions exist for isNthChild() and parseAnB() logic. I fixed only one that passed the tests, but appearance doesn't affect the result. I didn't notice it last time.
    Ideally, there should be no duplicated logic. But it's a task for the future refactoring.
  • Also, there was an invalid test:
    ...
    // BROKEN RULES -- these should always fail to match.
    // 6n + 7;
    ...
    This rule is actually valid for 20 elements. Every 6th element with an offset of 7 should match 3 elements but not 0. Rewrote this test to 6n+30 to fail

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.30%. Comparing base (5a9ddce) to head (f150006).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main      #60   +/-   ##
=========================================
  Coverage     89.30%   89.30%           
+ Complexity     1350     1349    -1     
=========================================
  Files            26       26           
  Lines          3131     3132    +1     
=========================================
+ Hits           2796     2797    +1     
  Misses          335      335           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Successfully merging this pull request may close these issues.

1 participant