Skip to content

Handle identifier arguments in pseudo-class selectors - #263

Merged
bartveneman merged 1 commit into
mainfrom
claude/gifted-heisenberg-e167hi
Nov 13, 2026
Merged

bartveneman merged 1 commit into
mainfrom
claude/gifted-heisenberg-e167hi

Conversation

@bartveneman

Copy link
Copy Markdown
Member

Summary

This PR improves handling of pseudo-class selector arguments, particularly for the :lang() pseudo-class and unknown pseudo-classes with identifier arguments. The changes ensure proper formatting and minification of these selectors.

Key Changes

  • Added identifier argument support: Pseudo-class arguments that are identifiers (e.g., :unknown(foo.bar)) are now properly handled and printed as-is without being treated as selectors
  • Fixed operator handling in selector lists: Operators (commas) between pseudo-class arguments are now explicitly skipped during printing to avoid duplication, since they're emitted separately in the formatting logic
  • Updated CSS parser dependency: Bumped @projectwallace/css-parser from ^0.19.6 to ^0.19.9 to support improved parsing of pseudo-class arguments
  • Added comprehensive test coverage: New tests verify correct formatting and minification of:
    • :lang() with multiple identifiers (adds quotes around arguments)
    • Single-argument :lang()
    • Unknown pseudo-classes with identifier arguments
    • Minification of both :lang() and unknown pseudo-classes

Implementation Details

The print_selector_argument() function now includes a check for identifier nodes using the is_identifier() helper, returning the raw text for identifiers before falling back to selector printing. The print_selector_list() function was updated to skip operator nodes, allowing the comma-separated formatting to work correctly for pseudo-class argument lists.

…ments

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Package Size Increase

📦 Package 📏 Base Size 📏 Source Size 📈 Size Change
@projectwallace/format-css 9.2 kB 9.2 kB +23 B

@bartveneman
bartveneman merged commit 812e139 into main Nov 13, 2026
10 checks passed
@bartveneman
bartveneman deleted the claude/gifted-heisenberg-e167hi branch November 13, 2026 13:15
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