Skip to content

Conversation

@IncharaG26
Copy link

Checklist:

Closes #64218

This PR resolves an issue in getStyleAny where invalid or partially-matching CSS selectors were incorrectly treated as valid. This behavior allowed users to pass certain curriculum challenges without meeting the required selector constraints.

The fix ensures that only exact matches from the allowed selector list are accepted.

This update improves reliability of curriculum challenge tests such as:

Lab Book Inventory App – Selector Validation
(ref: freeCodeCamp discussions / provided link)

What Was Done
✔ Fixed selector matching logic

Updated the getStyleAny function to prevent:

Partial matching

Attribute-selector misuse

Acceptance of selectors not explicitly allowed

✔ Added complete test coverage

Introduced getStyleAny.test.ts containing:

A failing test for previously-passing invalid selectors

A passing test for correct exact-match selectors

@IncharaG26 IncharaG26 requested a review from a team as a code owner December 6, 2025 19:43
@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​assert@​1.5.111001007080100
Added@​types/​jest@​30.0.01001007781100
Added@​types/​mocha@​10.0.101001007780100
Updatedjsdom@​20.0.3 ⏵ 27.2.098 +1100100 +194100 +31

View full report

@IncharaG26
Copy link
Author

Hello team,

By removing erroneous partial matches and enforcing stringent selector validation, this PR improves the getStyleAny utility. To precisely specify the expected behaviour and avoid regressions, I have added a targeted set of unit tests.

Important Enhancements

  • To guarantee that partial or invalid selectors cannot pass, exact selector matching was implemented.
  • Extensive unit tests covering both valid and invalid cases have been added.
  • confirmed that the updated configuration consistently passes unit and integration tests.
  • made sure the helper library's unrelated components weren't impacted.
  • The behaviour is now fully covered by tests, predictable, and in line with the challenge requirements.

If you would like more test scenarios or improvements, just let me know; I'd be pleased to iterate.
Thank you for taking time to look over this.

Copy link
Contributor

@ojeytonwilliams ojeytonwilliams left a comment

Choose a reason for hiding this comment

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

Hi, you're welcome to work on this, but getStyleAny already exists on line 502. I recommend starting with that.

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.

2 participants