Skip to content

fix(compiler): support dots in class binding names - #71137

Open
vslipchenko wants to merge 1 commit into
angular:mainfrom
vslipchenko:fix-class-binding-dotted-names
Open

vslipchenko wants to merge 1 commit into
angular:mainfrom
vslipchenko:fix-class-binding-dotted-names

Conversation

@vslipchenko

@vslipchenko vslipchenko commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Class bindings cut the class name at the first dot after the class. prefix, so a binding like [class.px-3.5]="condition" silently applies px-3 instead of px-3.5. No error or warning is reported. The same happens for host bindings, e.g. host: {'[class.py-2.5]': 'condition'} applies py-2.

This makes single class bindings unusable with class names that contain a dot, which are common in Tailwind (px-3.5, w-1.5, gap-0.5).

Background

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

[class.px-3.5]="true" adds the class px-3.

Issue Number: N/A (reported in a comment on #67679)

What is the new behavior?

[class.px-3.5]="true" adds the class px-3.5.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove
pullapprove Bot requested a review from atscott October 2, 2026 13:46
@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Oct 2, 2026
@ngbot ngbot Bot added this to the Backlog milestone Oct 2, 2026
@vslipchenko
vslipchenko force-pushed the fix-class-binding-dotted-names branch from 5cf0db0 to 0198ee2 Compare October 2, 2026 14:36

@JeanMeche JeanMeche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AGENT: Looks good to me. The fix for dot truncation in CLASS_DOT class bindings is correct and well-tested.

@vslipchenko
vslipchenko force-pushed the fix-class-binding-dotted-names branch from 0198ee2 to b53fa41 Compare October 2, 2026 15:15
@JeanMeche JeanMeche added the requires: TGP This PR requires a passing TGP before merging is allowed label Oct 2, 2026
@JeanMeche
JeanMeche removed the request for review from atscott October 2, 2026 15:18
@JeanMeche

Copy link
Copy Markdown
Member

Can you please also check that the vscode-language-service integration also works.

Treat everything after the `class.` prefix as the class name, both in
template bindings and in `host` bindings. Previously the name was cut at
the next dot, so a binding like `[class.px-3.5]` silently applied `px-3`
instead of `px-3.5`. This made single class bindings unusable with class
names that contain a dot, which are common in Tailwind.
@vslipchenko
vslipchenko force-pushed the fix-class-binding-dotted-names branch from b53fa41 to d0ef3b9 Compare October 2, 2026 15:57
@angular-robot
angular-robot Bot requested a review from JeanMeche October 2, 2026 15:58
@vslipchenko

vslipchenko commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Can you please also check that the vscode-language-service integration also works.

Manually tested in a locally built extension in VS Code - looks good.
View-side (via class binding):
image

Component-side (via host binding):
image

Added two quick info tests (template and host binding) for class names with a dot. The template test also asserts there are no diagnostics.
Let me know if there is anything else to test/address.

@JeanMeche

JeanMeche commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Great it looks fine. To make sure we won't break anything I'll run some extended tests (TGP) on Google's codebase over the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compiler Issues related to `ngc`, Angular's template compiler requires: TGP This PR requires a passing TGP before merging is allowed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

syntax highlighting issue with class binding and tailwind classes

2 participants