Skip to content

This library calls detect changes on every property change #322

Closed
@antischematic

Description

@antischematic
@Component({
  template: `
    count: {{ count }}
    <button (click)="increment()">Increment</button>
  `
})
export class Counter {
  elementRef = inject(ElementRef)
  count = 0

  increment() {
    this.count++
    this.count++
    this.count++

    expect(elementRef.nativeElement).toHaveTextContent("count: 0")
  }
}
await render(Counter)

fireEvent.click(screen.getByText("Increment"))

Expected result: count: 0
Actual result: count: 3

This is not correct Angular behavior and breaks custom change detection strategies.

Proposal: Use ComponentRef#setInput to change component properties instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions