fix: parse CSS data-type tokens in attr() type() notation (#4371)#4452
fix: parse CSS data-type tokens in attr() type() notation (#4371)#4452sarathfrancis90 wants to merge 1 commit into
Conversation
attr(width type(<number>)) and similar level-5 attr() declarations threw "Could not parse call arguments or missing ')'" because the <...> data-type token was not recognized as a value entity inside function-call arguments. Add a dataType entity that emits the token verbatim so the surrounding CSS function is preserved.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe Less parser gains a new ChangesCSS Data Type Entity Parsing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What:
Fixes #4371. CSS
attr()with the level-5type()notation (and bare angle-bracket data-type tokens) now parses instead of throwing.Before, this threw
Could not parse call arguments or missing ')'. Now it compiles to the same CSS.Why:
Inside function-call arguments, values go through the entity parser, which had no rule for the
<...>data-type token (e.g.<number>,<length-percentage>). Sotype(<number>)— and anything containing it, likeattr(name type(<number>))— failed to parse even though it's valid CSS. I added a smalldataTypeentity that matches<ident>and emits it verbatim, so the surrounding CSS function is preserved as-is. Guard conditions (when (@x < 1)) and media range syntax ((200px <= width)) are unaffected since those go through their own parsers, notentity().Added a fixture pair under
tests-unit/css-attr/covering thetype()notation, fallbacks, and a bare data-type value.Checklist:
Summary by CodeRabbit
<length-percentage>) in value contexts, enabling support for advanced CSS features like custom property syntax declarations and attribute functions with type notation.