-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Backward-referenced transplanted views and ChangeDetectionStrategy.OnPush are not fully supported #49801
Description
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).
angular/packages/core/test/acceptance/change_detection_transplanted_view_spec.ts
Line 403 in f9b821f
| fixture.detectChanges(false); |
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