Skip to content

[class] and [style] bindings are dropped when a directive has an output named class or style #71660

Closed

Description

@Flarette

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes. It works in 19.1.x and is broken from 19.2.0 onward.

Description

When a directive on an element declares an output whose public name is class, the template's [class] binding on that element never reaches the DOM. Static classes and [class.foo] bindings still work. The same happens with an output named style and [style]. Nothing is reported at compile time or at runtime.

@Directive({selector: '[dir]'})
export class Dir {
  @Output('class') out = new EventEmitter<string>();
}

@Component({
  selector: 'app-root',
  imports: [Dir],
  template: `<div dir class="s" [class]="cls()" [class.p]="true"></div>`,
})
export class App {
  cls = signal('b');
}

Expected classes on the div: b p s, which is what you get without dir.
Actual classes: p s. After cls.set('b2'), they are still p s.

These forms are affected too:

  • [style] with an output named style.
  • Interpolated class="s {{x}}" and style="width: {{w}}px".
  • Signal outputs, such as output({alias: 'class'}).
  • Host directives that expose an output as class, such as outputs: ['out: class'].

[className], [class.foo], host bindings and (class) listeners still work.

Cause: setShadowStylingInputFlags in packages/core/src/render3/view/directives.ts sets TNodeFlags.hasClassInput/hasStyleInput for outputs as well as inputs. The [class] value is then routed to directive inputs named class. None exist, so the value is dropped. This started with #60036, a refactor that moved the flag into helpers shared by inputs and outputs.

Please provide a link to a minimal reproduction of the bug

No hosted reproduction. The snippet in the description is self-contained: paste it into any Angular 19.2+ app. The linked PR adds regression tests.

Please provide the exception or error you saw

None. The binding is dropped silently.

Please provide the environment you discovered this bug in (run ng version)

Angular: 19.2.0 and later, including angular/angular main at 8260542ce0.
Reproduced with acceptance tests in packages/core/test/acceptance (AOT and JIT).

Anything else?

A PR with a fix and regression tests follows: the flag is set only while collecting inputs.

Activity

  1. added
    area: core
    on Oct 27, 2026
  2. added this to the needsTriage milestone on Oct 27, 2026
  3. added this to the needsTriage milestone on Oct 27, 2026
  4. erkamyaman commented on Oct 27, 2026

    @erkamyaman
    Contributor

    A maintainer would know better but I think you don't have to open an issue every time you send a PR

  5. Flarette commented on Oct 27, 2026

    @Flarette
    ContributorAuthor

    5. A maintainer would know better but I think you don't have to open an issue every time you send a PR

    Idk, haven't found an explicit rule for that. I think it has it's value to increase visibility for agents scanning the repo and keep things consistent.

  6. erkamyaman commented on Oct 27, 2026

    @erkamyaman
    Contributor

    I think it has its value to increase visibility for agents scanning the repo and keep things consistent.

    That's for an Angular team member to decide. Whether they see value in these or not.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: core

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions