Commit graph

3142 commits

Author SHA1 Message Date
Andrew Scott
971981e1df fix(core): TestBed.tick should ensure test components are synchronized (#61382)
This ensures that `TestBed.tick` updates any components created with
`TestBed.createComponent`, regardless of whether autoDetectChanges is
on.

PR Close #61382
2025-05-21 15:02:52 +00:00
Matthieu Riegler
dba912dd07 refactor(platform-browser): replace platform-browser-dynamic with platform-browser (#61498)
The former isn't needed anymore and is now deprecated.

PR Close #61498
2025-05-21 14:01:49 +00:00
arturovt
6bf6dbc37e fix(core): cleanup testability subscriptions (#61261)
This commit prevents leaking memory when the application is destroyed and subscriptions are still alive.

PR Close #61261
2025-05-21 12:06:23 +00:00
Matthieu Riegler
ef01d3c69e refactor(core): Merge R3TemplateRef implementation and TemplateRef interface (#61455)
This was an artifact of the Ivy migration.

PR Close #61455
2025-05-21 10:07:12 +00:00
Paul Gschwendtner
082cc5579d build: migrate all ng_module in packages/core/test (#61472)
Migrates all `ng_module` to `ng_project` in `packages/core/test/`.

PR Close #61472
2025-05-20 10:00:43 +00:00
Paul Gschwendtner
8ead19fe00 build: migrate all ts_library in packages/core/test (#61472)
This commit migrates all `ts_library` in `package/core/test` to
`ts_project`, and fixes deep module, or relative imports inside.

PR Close #61472
2025-05-20 10:00:43 +00:00
Andrew Scott
f182886ce5 refactor(core): Disallow autoDetectChanges(false) in zoneless (#61430)
This removes the ability to use `autoDetectChanges(false)` when
`provideZonelessChangeDetection` is used.

PR Close #61430
2025-05-20 08:49:06 +00:00
Kristiyan Kostadinov
7a308ccc3b refactor(core): consolidate logic to determine whether node can be hydrated (#61409)
Several instructions were repeating the logic that checks if a specific can be hydrated. These changes move it into a common location.

PR Close #61409
2025-05-19 09:30:20 +00:00
Kristiyan Kostadinov
6783fb7eae refactor(core): consolidate element end instruction logic (#61409)
There was some identical logic between the `elementEnd` and `elementContainerEnd` instructions. These changes consolidate it.

PR Close #61409
2025-05-19 09:30:20 +00:00
Kristiyan Kostadinov
049fe82de6 refactor(core): consolidate element start logic (#61409)
The logic for the `elementStart` and `elementContainerStart` instructions was identical. These changes consolidate it into a single base instruction.

PR Close #61409
2025-05-19 09:30:20 +00:00
Kristiyan Kostadinov
b785256b9e perf(core): avoid intermediate arrays in definition (#61445)
A minor performance improvement for `ɵɵdefineComponent` where the underlying `extractDefListOrFactory` call had a chain of `.map.filter` which meant that we were unnecessarily creating intermediate arrays just to filter out the null values. These changes switch to simple `for` loop to get around it.

PR Close #61445
2025-05-19 09:20:07 +00:00
Pawel Kozlowski
d9d9e42c23 fix(core): handle different DI token types in Chrome DevTools integration (#61333)
This small refactor makes the DI events reporting code more resiliant
with respect to finding names for different token types.

PR Close #61333
2025-05-15 10:15:32 -07:00
arturovt
a5db6c41d0 fix(core): enable stashing only when withEventReplay() is invoked (#61077)
This commit brings the necessary event replay code code in tree-shakable manner.

PR Close #61077
2025-05-14 10:35:57 -07:00
Kristiyan Kostadinov
f6bb6cc09a build: set up runtime tests for selectorless (#61307)
Sets up the tests for the selectorless runtime so that we can easily start writing them when we get to it. The tests need to be AoT compiled so they're defined as a separate target from the other `acceptance` tests.

PR Close #61307
2025-05-14 11:06:22 +02:00
Matthieu Riegler
3eeea56ba0 refactor(core): remove compileComponents invocations (#61032)
Those weren't necessary.

PR Close #61032
2025-05-09 10:27:14 -07:00
Paul Gschwendtner
54e785683a build: prepare for compiler-cli to be using ts_project (#61181)
Prepare the compiler-cli package for being ready for migration
to `ts_project`.

PR Close #61181
2025-05-09 15:59:46 +00:00
Andrew Scott
c53310ee81 refactor(router): Update RouterLink href to use host binding and signals (#60875)
This commit updates the method of setting the href attribute on
`RouterLink` to use built in host binding rather than custom attribute
setting and sanitization. The advantage here would be automatic handling
of the sanitization and avoiding of writing the same value to the DOM
that we had before.

This change does mean that we _always_ write to the href attribute where
before we only wrote to it when the elemnt was known to support `href`.
That said, the implementation attempts to retain behavior that is as
close as possible: the original value of `href` is used and never updated.

PR Close #60875
2025-05-07 11:31:08 -07:00
Paul Gschwendtner
032b802f54 build: remove irrelevant madge circular deps tests (#61156)
We don't need this tooling anymore because we are already validating
that there are no circular dependencies via the `ng-dev` tooling that
checks `.ts` files directly.

Also these tests never actually failed to my knowledge.

PR Close #61156
2025-05-07 11:28:59 -07:00
Kristiyan Kostadinov
583b9a7be5 fix(core): missing useExisting providers throwing for optional calls (#61137)
Fixes that the runtime was throwing a DI error when attempting to inject a missing `useExisting` provider, despite the call being optional.

The problem was that when the provider has `useExisting`, we do a second `inject` call under the hood which didn't include the inject flags from the original call.

Fixes #61121.

PR Close #61137
2025-05-06 09:12:38 -07:00
Andrew Scott
e7f5aa2b52 refactor(core): Remove use of private export PendingTasksInternal where possible (#61049)
This commit removes the use of the privately exported
PendingTasksInternal everywhere except for Router. A follow-up change
will be done to remove that one as well and delete the private export.

PR Close #61049
2025-05-05 08:56:20 -07:00
Matthieu Riegler
c2c8b75d7b refactor(core): remove module bootstrap code when using standalone. (#59208)
This commit improves tree shaking in standalone apps.

PR Close #59208
2025-05-01 08:39:34 -07:00
Alan Agius
193bd7c54a fix(core): properly handle app stabilization with defer blocks (#61040)
Previously, the app was marked as stable prematurely. For more details, see https://github.com/angular/angular/issues/61038#issuecomment-2837917180

Closes: #61038

PR Close #61040
2025-04-30 12:37:02 -07:00
arturovt
624be2ef0c fix(core): prevent stash listener conflicts (#59635)
The stash event listener is a global function that might be unsafely overridden if multiple microfrontend applications exist on the page.

In this commit, we create a map of `APP_ID` to stash event listener functions. This map prevents conflicts because multiple applications might be bootstrapped simultaneously on the client (one rendered on the server and one rendering only on the client).

I.e., the code that might be used is:

```ts
// Given that `app-root` is rendered on the server
bootstrapApplication(AppComponent, appConfig);

bootstrapApplication(BlogRootComponent, appBlogConfig);
```

Two bootstrapped applications would conflict and override each other's code.

PR Close #59635
2025-04-30 08:53:06 -07:00
Matthieu Riegler
8f803aa81a build: Run browsers tests without platform-browser-dynamic (#60937) (#61060)
Use the regular `platform-browser` providers instead.

PR Close #61060
2025-04-30 08:21:02 -07:00
Jessica Janiuk
867f389a98 Revert "build: Run browsers tests without platform-browser-dynamic (#60937)" (#61059)
This reverts commit b896ca8ed5.

PR Close #61059
2025-04-30 12:21:01 +02:00
arturovt
8d82a39a60 fix(core): async EventEmitter error should not prevent stability (#61028)
This commit wraps the `fn` invocation with `try-finally`, ensuring that the pending task (added in [this commit](d5c6ee432f)) is always removed.

Prior to this commit, if a subscriber threw an error, it would prevent the application from becoming stable — though this shouldn't happen under normal scenarios because the error should be handled by the RxJS error handler or Angular's error handler.

Errors should not silently prevent the application from being rendered on the server.

PR Close #61028
2025-04-29 22:14:15 -07:00
Matthieu Riegler
b896ca8ed5 build: Run browsers tests without platform-browser-dynamic (#60937)
Use the regular `platform-browser` providers instead.

PR Close #60937
2025-04-29 12:10:53 -07:00
Taygan Caldwell
42cad2849d refactor(core): Add createSignalTuple (#60903)
Add createSignalTuple function to match Wiz array destructuring signal return. This will be the implementation for createSignal once createSignal usages in google3 are migrated to createSignalTuple.

PR Close #60903
2025-04-29 08:46:39 -07:00
Pawel Kozlowski
d8fbb909ce feat(core): rename afterRender to afterEveryRender and stabilize (#60999)
This change renames the afterRender to afterEveryRender and marks the
renamed API as stable.

BREAKING CHANGE: afterRender was renamed to afterEveryRender.

PR Close #60999
2025-04-28 12:33:55 -07:00
Andrew Scott
7680a27f30 refactor(core): Ignore errors related to updating exhaustive check value (#61027)
this can happen if the injector is already destroyed, which can happen in tests that fail to clean up correctly

PR Close #61027
2025-04-28 10:16:01 -07:00
Andrew Scott
e711f99d81 feat(core): move provideExperimentalCheckNoChangesForDebug to provideCheckNoChangesConfig (#60906)
This commit makes several changes changes to the
`provideExperimentalCheckNoChangesForDebug` API:

* Rename it
* Promote to dev preview
* Apply the exhaustive behavior to _all_ checkNoChanges runs
* Remove `useNgZoneOnStable` option. This wasn't found to be generally
  more useful than `interval`

fixes #45612

BREAKING CHANGE: `provideExperimentalCheckNoChangesForDebug` has several
breaking changes:
* It is renamed to `provideCheckNoChangesConfig`
* The behavior applies to _all_ checkNoChanges runs
* The `useNgZoneOnStable` option is removed. This wasn't found to be generally
  more useful than `interval`

PR Close #60906
2025-04-24 13:04:27 -07:00
Andrew Kushnir
c2987d8402 refactor(core): stop producing ng-reflect attributes by default (#60973)
BREAKING CHANGE:

This commit deprecates `ng-reflect-*` attributes and updates the runtime to stop producing them by default. Please refactor application and test code to avoid relying on `ng-reflect-*` attributes.

To enable a more seamless upgrade to v20, we've added the `provideNgReflectAttributes()` function (can be imported from the `@angular/core` package), which enables the mode in which Angular would be producing those attribites (in dev mode only). You can add the `provideNgReflectAttributes()` function to the list of providers within the bootstrap call.

PR Close #60973
2025-04-24 10:07:35 -07:00
Alex Rickabaugh
d0c9a6401a refactor(core): rename resource's request to params (#60919)
As decided in the resource RFC, this commit renames the `request` option of
a resource to `params`, including the subsequent argument passed to the
loader. It also corrects the type in the process to properly allow narrowing
of the `undefined` value.

Fixes #58871

PR Close #60919
2025-04-23 19:34:50 +00:00
Alex Rickabaugh
d8ca560a15 refactor(core): convert ResourceStatus to a string type (#60919)
An outcome of the Resource RFC was that we should use string constants for
communicating the resource status instead of an enum. This commit converts
`ResourceStatus` accordingly.

PR Close #60919
2025-04-23 19:34:50 +00:00
Andrew Scott
953c4b2580 feat(core): Move zoneless change detection to dev preview (#60748)
This commit moves zoneless from experimental to developer preview.

* Update tag on provider API
* Remove "experimental" from provider name
* Move documentation from "experimental features" to "Best practives ->
  Performance" (at least temporarily until there is a better place)

BREAKING CHANGE: `provideExperimentalZonelessChangeDetection` is
renamed to `provideZonelessChangeDetection` as it is now "Developer
Preview" rather than "Experimental".

PR Close #60748
2025-04-23 11:47:56 +02:00
Pawel Kozlowski
0859a99e89 refactor(core): replace TestBed.flushEffects with tick (#60959)
Instead of stabilizing the TestBed.flushEffects() API we intend to
replace it with the tick() method (equivalent of ApplicationRef.tick().
The reasoning here is that we prefer tests running the entire
synchronization process (as in production apps) instead of invoking
parts of the synchronization process in a way that would naver happen
in a running application.

PR Close #60959
2025-04-23 09:54:30 +02:00
Matthieu Riegler
1b8e7ab9fe feat(compiler): support the in keyword in Binary expression (#58432)
This commit adds the support for the `in` keyword as a relational operator, with the same precedence as the other relational operators (<,>, <=, >=)

BREAKING CHANGE: 'in' in an expression now refers to the operator

PR Close #58432
2025-04-22 21:44:12 +02:00
Matthieu Riegler
6c2fbad8a2 refactor(core): Improve NG0600 error message. (#60418)
This commit adds the mention of templates as illegal context to write signals.

fixes #60143

PR Close #60418
2025-04-22 16:35:38 +02:00
Gabriel Bergoc
be995623cd fix(forms): make NgForm emit FormSubmittedEvent and FormResetEvent (#60887)
Currently, only forms created with `FormGroupDirective` emit events on
form submission and resetting. This commit extends this behavior to
Template-driven forms also.

Related to #58894

PR Close #60887
2025-04-22 13:04:40 +02:00
Matthieu Riegler
ba34b3c3d9 refactor(core): remove unused injection props (#59209)
Those were also properties that were kept to also support of old compiled targets.

PR Close #59209
2025-04-15 17:33:02 -04:00
Andrew Scott
65adb3024d feat(core): Add provider which reports unhandled errors on window to ErrorHandler (#60704)
This commit adds a provider that installs listeners on the browser
window to forward unhandled promise rejections and uncaught errors to
the `ErrorHandler`. This is useful for both ZoneJS and Zoneless
applications. For apps using ZoneJS, errors can reach the window when
they happen outside the Angular Zone. For Zoneless apps, any errors not
explicitly caught by the framework can reach the window. Without this
provider, these errors would otherwise not be reported to
`ErrorHandler`.

We will/should consider adding this provider to apps by default in the
cli. In addition, it should be mentioned in the (to be created)
documentation page on error handling in Angular.

relates to #56240

PR Close #60704
2025-04-14 14:33:00 -04:00
JoostK
27bf809b31 test(core): type tests for linkedSignal (#60857)
This commit adds type inference tests for `linkedSignal` usages, to capture their behavior w.r.t.
type inference. Note that there's some situations where type inference doesn't work as you might
expect/hope; these have been included to capture their behavior but may be revisited in the future
if the inference capabilities are expanded for this scenario.

Closes #60423

PR Close #60857
2025-04-14 09:30:36 -04:00
Matthieu Riegler
36ae560765 refactor(core): remove the phase prop from AfterRenderOptions (#60641)
The `AfterRenderPhase` enum now becomes private, it isn't exported anymore.

PR Close #60641
2025-04-09 15:39:47 -07:00
Matthieu Riegler
0b69b61929 fix(core): Flush animations when no component has been checked (#58089)
When Angular runs application synchronization automatically, animations
are now guaranteed to be flushed, regardless of whether change detection
was run on any components attached to `ApplicationRef`. This most
frequently affects animations related to component removal where the DOM
element for the component would previously not be removed due to
animations not being flushed

BREAKING CHANGE: Animations are guaranteed to be flushed when Angular
runs automatic change detection or manual calls to `ApplicationRef.tick`.
Prior to this change, animations would not be flushed in some situations
if change detection did not run on any views attached to the
application. This change can affect tests which may rely on the old
behavior, often by making assertions on DOM elements that should have
been removed but weren't because DOM removal is delayed until animations
are flushed.

fixes #58075

PR Close #58089
2025-04-09 11:12:54 -07:00
Pawel Kozlowski
2b4fd9b273 refactor(core): allow multiple DI profilers (#60562) (#60562)
This commit changes the DI profiler infrastructure to
allow multiple profilers running at the same time.

PR Close #60562

PR Close #60562
2025-04-09 09:16:40 -07:00
Andrew Scott
b8d9f95faa Revert "refactor(core): allow multiple DI profilers (#60562)" (#60793)
This reverts commit 56cc5fdb57.

CI tests are consistently timing out after this commit

PR Close #60793
2025-04-08 14:04:16 -07:00
Kristiyan Kostadinov
c0f41bc505 refactor(platform-browser): remove GenericBrowserDomAdapter (#60760)
The `GenericBrowserDomAdapter` wasn't don't anything so we can drop it and have the `BrowserDomAdapter` extend `DomAdapter` directly.

PR Close #60760
2025-04-08 10:14:54 -07:00
Pawel Kozlowski
56cc5fdb57 refactor(core): allow multiple DI profilers (#60562)
This commit changes the DI profiler infrastructure to
allow multiple profilers running at the same time.

PR Close #60562
2025-04-08 08:56:30 -07:00
Doug Parker
0ae1889560 fix(core): run ApplicationRef.prototype.bootstrap in NgZone (#60720)
`bootstrapApplication` always creates the root component in the `NgZone`, however `ApplicationRef.prototype.bootstrap` historically did not, meaning that if users did not go out of their way to call `ngZone.run(() => appRef.bootstrap(SomeComp))`, components would not run change detection correctly.

This commit updates `ApplicationRef.prototype.bootstrap` to _always_ run within `NgZone`, removing this hazard and ensuring components always run CD as expected.

PR Close #60720
2025-04-07 11:32:31 -07:00
Doug Parker
2348f26d8a refactor(core): add ApplicationRef.prototype.bootstrapImpl with an injector parameter (#60622)
This is a roll forward of commit d5a8a1c524. Nothing is meaningfully different, as we're trying again to see if the CI failure is reproducible.

PR Close #60622
2025-04-03 10:48:01 -07:00