angular/packages/core/test/linker
Andrew Scott ad045efd4b fix(core): Ensure views marked for check are refreshed during change detection (#54735)
When a view has the `Dirty` flag and is reattached, we should ensure that it is
reached and refreshed during the next change detection run from above.

In addition, when a view is created and attached, we should ensure that it is reached
and refreshed during change detection. This can happen if the view is
created and attached outside a change run or when it is created and
attached after its insertion view was already checked. In both cases, we
should ensure that the view is reached and refreshed during either the
current change detection or the next one (if change detection is not
already running).

We can achieve this by creating all views with the `Dirty` flag set.

However, this does happen to be a breaking change in some scenarios.
The one identified internally was actually depending on change detection
_not_ running immediately because it relied on an input value that was
set using `ngModel`. Because `ngModel` sets its value in a `Promise`, it
is not available until the _next_ change detection cycle. Ensuring
created views run in the current change change detection will result in
different behavior in this case.

fixes #52928
fixes #15634

BREAKING CHANGE: Newly created and views marked for check and reattached
during change detection are now guaranteed to be refreshed in that same
change detection cycle. Previously, if they were attached at a location
in the view tree that was already checked, they would either throw
`ExpressionChangedAfterItHasBeenCheckedError` or not be refreshed until
some future round of change detection. In rare circumstances, this
correction can cause issues. We identified one instance that relied on
the previous behavior by reading a value on initialization which was
queued to be updated in a microtask instead of being available in the
current change detection round. The component only read this value during
initialization and did not read it again after the microtask updated it.

PR Close #54735
2024-03-06 15:44:09 -08:00
..
change_detection_integration_spec.ts fix(core): Ensure views marked for check are refreshed during change detection (#54735) 2024-03-06 15:44:09 -08:00
inheritance_integration_spec.ts fix(core): better error message when directive extends a component (#45658) 2022-04-18 09:24:23 -07:00
integration_spec.ts feat(core): show runtime error for orphan component rendering (#52061) 2023-10-10 15:30:26 -07:00
ng_container_integration_spec.ts refactor(core): handle #24571 todos. (#49221) 2023-06-14 12:33:44 +02:00
ng_module_integration_spec.ts test(core): Remove manual ComponentFixture construction (#52983) 2023-11-16 15:12:32 -08:00
projection_integration_spec.ts refactor(platform-browser): Remove BrowserDetection (#50411) 2023-05-30 13:06:28 -07:00
query_integration_spec.ts refactor(core): handle #24571 todos. (#49221) 2023-06-14 12:33:44 +02:00
query_list_spec.ts test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
regression_integration_spec.ts refactor(core): handle #24571 todos. (#49221) 2023-06-14 12:33:44 +02:00
resource_loader_mock.ts refactor(core): handle #24571 todos. (#49221) 2023-06-14 12:33:44 +02:00
security_integration_spec.ts refactor(core): handle #24571 todos. (#49221) 2023-06-14 12:33:44 +02:00
source_map_integration_node_only_spec.ts feat(compiler): Enable template pipeline by default. (#54571) 2024-02-23 11:15:36 -08:00
source_map_util.ts build: replace base64-js package with Node.js Buffer usage (#53464) 2023-12-11 14:04:06 -08:00
view_injector_integration_spec.ts refactor(platform-browser): replace our own toBeAnInstanceOf with toBeInstanceOf (#50661) 2023-06-14 10:58:04 +02:00