Skip to content

Backward-referenced transplanted views and ChangeDetectionStrategy.OnPush are not fully supported #49801

@DavidANeil

Description

@DavidANeil

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

core

Is this a regression?

No

Description

Transplanted views (templates that are rendered into a different component than where they are declared) do not function properly when the declaration occurs after the insertion point in the change detector tree.

They almost always require checkNoChanges to be disabled, or else they will throw an ExpressionChangedAfterItHasBeenCheckedError. This happens when the inserted view is not dirty, so it is skipped during detectChanges, but then the declaration-owning view is checked, which calls markTransplantedViewsForRefresh.

On the following checkNoChanges run, it will check the transplanted view, which means any binding expression change will result in a ExpressionChangedAfterItHasBeenCheckedError.

To reproduce:
Remove the false from the fixture.detectChanges here (line 403).

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

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

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussionarea: coreIssues related to the framework runtimecore: change detection

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions