Skip to content

fix: prevent universal selector leakage in getStyl#582

Open
laasya2005 wants to merge 1 commit intofreeCodeCamp:mainfrom
laasya2005:fix/universal-selector-leakage
Open

fix: prevent universal selector leakage in getStyl#582
laasya2005 wants to merge 1 commit intofreeCodeCamp:mainfrom
laasya2005:fix/universal-selector-leakage

Conversation

@laasya2005
Copy link
Copy Markdown

Closes freeCodeCamp/freeCodeCamp#64218

CSS rules using universal selectors (*) like span[class~="one"] *:first-of-type could match queries for specific selectors that did not include *, causing overly broad student CSS to incorrectly pass challenge validation.

Changes:

  • Added _selectorHasUniversal() to detect * in CSS selectors
  • Modified getStyle() to skip rules containing * when the queried selector does not use it
  • Added 7 tests covering all four want/have universal selector combinations
  • Added shared CSS fixture for universal selector test cases

@laasya2005 laasya2005 requested a review from a team as a code owner April 8, 2026 23:21
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.

CSSHelp issue with getStyleAny

1 participant