Fix dashed idents being parsed as type selectors in pseudo-element functions#186
Merged
bartveneman merged 1 commit intomainfrom Mar 16, 2026
Merged
Conversation
A dashed ident like --light-box-img is a CSS custom property name, not a valid type selector. When used as an argument to pseudo-element functions such as ::view-transition-new(--light-box-img) and ::view-transition-old(--light-box-img), the parser was incorrectly producing a TYPE_SELECTOR node for the dashed ident, causing downstream tools (e.g. css-analyzer) to misclassify it as a custom element. Fix: in parse_type_or_namespace_selector, bail out early with null when the ident token starts with -- so it is never wrapped in TYPE_SELECTOR. Fixes projectwallace/css-analyzer#539 https://claude.ai/code/session_018QWguHVy1uENPc16qgjLcz
Bundle ReportChanges will increase total bundle size by 101 bytes (0.06%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: @projectwallace/css-parser-esmAssets Changed:
Files in
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
=======================================
Coverage 95.22% 95.23%
=======================================
Files 16 16
Lines 2869 2873 +4
Branches 803 806 +3
=======================================
+ Hits 2732 2736 +4
Misses 137 137 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed a parsing issue where dashed identifiers (CSS custom property names like
--my-ident) were incorrectly being classified as type selectors when used as arguments to pseudo-element functions like::view-transition-new()and::view-transition-old().Key Changes
parse_type_or_namespace_selector()to detect and reject dashed identifiers (starting with--) from being parsed as type selectorsCHAR_MINUS_HYPHENconstant to support the dashed identifier detection::view-transition-new(--custom-name)::view-transition-old(--custom-name)::slotted(--custom-name):is()still work correctlyImplementation Details
The fix checks if an identifier token starts with two consecutive hyphens (
--), which is the CSS syntax for custom property names. When detected, the parser returnsnullinstead of creating a TYPE_SELECTOR node, allowing the dashed ident to be handled appropriately by the pseudo-element function's argument parsing logic.https://claude.ai/code/session_018QWguHVy1uENPc16qgjLcz