Commit graph

36863 commits

Author SHA1 Message Date
Andrew Scott
88858118ea refactor(common): Mark inputs of deprecated control flow directives as deprecated (#61089)
This updates the inputs of the deprecated control flow directives as also deprecated.
Helpful for language services/tokenization tools

PR Close #61089
2025-05-01 14:59:25 -07:00
Matthieu Riegler
d47d6720e7 fix(devtools): fix profiler support with @defer blocks (#61080)
Prior to this change, the devtools profile logged warnings "Unable to find parent node for ...".

PR Close #61080
2025-05-01 14:58:21 -07:00
arturovt
1bbf75017c fix(common): cleanup updateLatestValue if view is destroyed before promise resolves (#58041)
According to the promise specification, promises are not cancellable by default.
Once a promise is created, it will either resolve or reject, and it doesn't
provide a built-in mechanism to cancel it.
There may be situations where a promise is provided, and it either resolves after
the pipe has been destroyed or never resolves at all. If the promise never
resolves — potentially due to factors beyond our control, such as third-party
libraries — this can lead to a memory leak.
When we use `async.then(updateLatestValue)`, the engine captures a reference to the
`updateLatestValue` function. This allows the promise to invoke that function when it
resolves. In this case, the promise directly captures a reference to the
`updateLatestValue` function. If the promise resolves later, it retains a reference
to the original `updateLatestValue`, meaning that even if the context where
`updateLatestValue` was defined has been destroyed, the function reference remains in memory.
This can lead to memory leaks if `updateLatestValue` is no longer needed or if it holds
onto resources that should be released.
When we do `async.then(v => ...)` the promise captures a reference to the lambda
function (the arrow function).
When we assign `updateLatestValue = null` within the context of an `unsubscribe` function,
we're changing the reference of `updateLatestValue` in the current scope to `null`.
The lambda will no longer have access to it after the assignment, effectively
preventing any further calls to the original function and allowing it to be garbage collected.

If Chrome is built with additional flags and run with `--allow-natives-syntax --track-retaining-path`,
we could use `%DebugTrackRetainingPath` to see the distance from the root for `updateLatestValue`
if it's passed directly to async.then, e.g.:

```js
%DebugTrackRetainingPath(updateLatestValue);

// Distance from root 4: 0x123456789abc <JSPromise (sfi = 0x1fbb02e2d7f1)>
```

PR Close #58041
2025-05-01 14:53:13 -07:00
arturovt
5f31c953ed refactor(zone.js): drop passive supported check (#58010)
https://caniuse.com/passive-event-listener
Passive event listeners are supported in all major evergreen browsers.
Thus, we don't need to check whether passives are supported.

PR Close #58010
2025-05-01 11:42:13 -07:00
Angular Robot
e529a84520 build: update cross-repo angular dependencies to v20.0.0-next.10 (#61084)
See associated pull request for more information.

PR Close #61084
2025-05-01 10:31:46 -07:00
arturovt
6bc9d45e77 refactor(core): drop computation error messages in production (#60700)
Some of the error messages in `core/primitives` are already guarded with `ngDevMode`; this change guards the remaining ones.

PR Close #60700
2025-05-01 10:11:01 -07:00
Andrew Scott
da6fa0f402 refactor(router): Remove outdated comment (#61086)
removes outdated comment in router code

PR Close #61086
2025-05-01 10:09:15 -07:00
arturovt
d2cb0b9786 refactor(core): tree-shake getDirectiveDef error (#61075)
This commit (25cae4555a) introduced an error throw when the directive definition is not defined. We can guard it with `ngDevMode` and throw the error only in development mode.

PR Close #61075
2025-05-01 08:43:43 -07:00
Andrew Miller
f08f8844cb docs: Add docs for CoC plugin with neovim (#61005)
When docs were moved from aio to adev, the directions for the CoC plugin
were mistakenly dropped.

This brings back the documentation from prior versions:

https://v17.angular.io/guide/language-service#neovim

PR Close #61005
2025-05-01 08:41:46 -07:00
arturovt
1e2a70c8db refactor(common): drop platform checks in HttpXsrfCookieExtractor (#59810)
Replaces `PLATFORM_ID` checks with `ngServerMode` within the `HttpXsrfCookieExtractor`. It is not part of the public API, and thus this change should not affect consumers who may have called the constructor directly.

PR Close #59810
2025-05-01 08:41:10 -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
Angular Robot
33a336f74a build: update cross-repo angular dependencies (#61069)
See associated pull request for more information.

PR Close #61069
2025-04-30 15:12:30 -07:00
Andrew Scott
c0ae032362 refactor(router): Remove unnecessary runOutsideAngular in view transition helper (#61068)
This refactor removes the unnecessary `runOutsideAngular` call in the
view transition helper. The resolved promise re-enters the zone in the
transition, so that will trigger the Angular zone anyways. If it didn't do that,
it risks activated the route outside the zone, which is a bigger risk.
Regardless, this function is only run once per navigation, so even if it
_did_ result in an extra promise/timeout inside the zone, this is not
excessive. Using ZoneJS to trigger rendering is known to overreact to events.
Using `OnPush` or zoneless is more effective at mitigating this issue.

PR Close #61068
2025-04-30 14:18:49 -07:00
Andrew Scott
2e80744581 test(router): Fix slow-running infinite loop test and remove unnecessary duplicate tests (#61076)
The inifinite loop test is a real infinite loop and runs until a stack
overflow happens. In addition, all the promise and observable tests are
just duplicates of the other redirects and don't test any additional
logic. Instead, this change updates one test to return an observable and
another to return a promise

PR Close #61076
2025-04-30 14:18:09 -07:00
Andrew Scott
344ea29f7a refactor(docs-infra): remove 'experimental' from cli entry (#61067)
this removes the experimental prefix from zoneless entry in fake cli

PR Close #61067
2025-04-30 14:16:55 -07:00
arturovt
9b96fccbc4 refactor(service-worker): drop error messages in production (#59702)
This commit provides tree-shakable error messages for the `service-worker` package.

PR Close #59702
2025-04-30 12:41:36 -07:00
arturovt
98e53ccfb8 refactor(common): drop platform check in LCPImageObserver (#59742)
Replaces platform check within the `LCPImageObserver` with the `ngServerMode` global.

PR Close #59742
2025-04-30 12:40:41 -07:00
arturovt
4184e0b9c2 refactor(compiler): improve stringify (#60013)
This is the same change that was made in this commit (cf3a5073ec). See its description for clarification.

PR Close #60013
2025-04-30 12:40:02 -07:00
arturovt
13fd1b30e0 refactor(core): tree-shake PROPAGATION_STOPPED_SYMBOL (#61004)
Adds `__PURE__` annotations to `PROPAGATION_STOPPED_SYMBOL` to enable tree-shaking, even if is is not referenced. This variable is not dropped when Angular is imported from a module that has `sideEffects` set to `true`.

PR Close #61004
2025-04-30 12:38:44 -07:00
Alan Agius
a60373ee1a refactor(core): remove private __core_private_testing_placeholder__ API (#61055)
This API is no longer used in G3

PR Close #61055
2025-04-30 12:37:39 -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
Alan Agius
b27234bcd7 test: disable platform-server tests that do not work with zoneless (#61040)
A number of cases currently do not work with zoneless.

PR Close #61040
2025-04-30 12:37:02 -07:00
Alan Agius
d94fb764d0 test: add integration test for platform-server with zoneless (#61040)
Add an integration test to verify SSR with zoneless

PR Close #61040
2025-04-30 12:37:01 -07:00
Alan Agius
0c9e7d980e test: add integration test for defer with input on SSR with zones (#61040)
Add an integration test to verify defer block behavior with input handling during server-side rendering (SSR).

PR Close #61040
2025-04-30 12:37:01 -07:00
Miles Malerba
c1e46c5561 docs: release notes for the v20.0.0-next.9 release 2025-04-30 10:40:58 -07:00
Miles Malerba
98de7bf17e release: bump the next branch to v20.1.0-next.0 2025-04-30 10:40:58 -07:00
Miles Malerba
829379e68c docs: release notes for the v19.2.9 release 2025-04-30 10:31:53 -07:00
Angular Robot
bb00b93db3 build: update cross-repo angular dependencies (#61062)
See associated pull request for more information.

PR Close #61062
2025-04-30 09:31:36 -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
cexbrayat
fc4a56d5c5 fix(common): rename httpResource function in factory (#60022)
As the function in the factory was named `httpResourceRef`, error NG0203 had with the following message:

```
Error: NG0203: httpResourceRef() can only be used within an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`. Find more at https://angular.dev/errors/NG0203
```

PR Close #60022
2025-04-30 08:51:39 -07:00
arturovt
b14fbe1497 refactor(core): tree-shake getNgModuleDef error (#60339)
Currently, the error thrown in `getNgModuleDef` is guarded by `throwIfNotFound`, which is only set to `true` when `ɵɵsetNgModuleScope` is called in production. In all other cases, `throwIfNotFound` is never used in production. This means that if NgModules aren't used, `getNgModuleDef` is never called with the second argument. We can split it into two functions to allow tree-shaking of the error when NgModules aren't used at all.

PR Close #60339
2025-04-30 08:50:52 -07:00
cexbrayat
52e2f0842d refactor(core): remove unused APP_EFFECT_SCHEDULER in effect code (#59679)
The `APP_EFFECT_SCHEDULER` Injection token is never used and not a public API.

PR Close #59679
2025-04-30 08:49:55 -07:00
Angular Robot
2bddce2612 docs: update Angular CLI help [main] (#61048)
Updated Angular CLI help contents.

PR Close #61048
2025-04-30 08:25:47 -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
vladboisa
a282f583ed docs: add link label & paragraph for correct display (#60708)
PR Close #60708
2025-04-30 08:18:07 -07:00
Matthieu Riegler
201e02b161 docs(docs-infra): fix alert header inlining (#60708)
PR Close #60708
2025-04-30 08:18:07 -07:00
vladboisa
e4a667690a docs: add Security-DomSanitizer link in ElemnetRef&Renderer2 (#60708)
Renderer2 and ElementRef didn't mention the Security-DomSanitizer method, this will add clarity for potential user what to expect. Also swap deprecated "callout" class to docs-alert

Fixes #51208 , #46904

PR Close #60708
2025-04-30 08:18:07 -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
e6a34277fc feat(devtools): defer blocks support (#60629)
This commit adds the support for defer block in the Angular DevTools.

@defer block are now visible in the directive tree and give access to defer & hydration details.

This feature also brings support of incrementation hydration.

PR Close #60629
2025-04-29 22:07:47 -07:00
Andrew Scott
3261d14391 refactor(core): NgZone.onError reports to application error handler (#60946)
This commit ensures that errors from the `NgZone.onError` subscription
in bootstrap are reported to the internal application error handler.
Practically speaking, this should not affect anything today, as the
application handler goes directly to the `ErrorHandler` from the root.
While TestBed installs an application error handler that rethrows,
`TestBed.createComponent` does not create components through this
bootstrap function.

PR Close #60946
2025-04-29 21:56:50 -07:00
Andrew Scott
e8147df0e1 refactor(router): Move router integration suite to zoneless (#61046)
This commit moves the router integration tests to use zoneless

PR Close #61046
2025-04-29 21:56:01 -07:00
Andrew Scott
f36f2f2cb4 refactor(router): Remove inject helper from router tests (#61046)
This removes the `inject` helper from core/testing in the router tests.

PR Close #61046
2025-04-29 21:56:01 -07:00
Kristiyan Kostadinov
adaecba95f refactor(compiler-cli): split up large method (#61018)
The `ComponentHandler.resolve` method is ~500 lines and is a bit hard to follow due to some very long `if` statements. These changes split the functionality across several smaller methods to make it easier to manage.

PR Close #61018
2025-04-29 21:06:10 +00:00
Kristiyan Kostadinov
abdb6e2945 refactor(compiler): allow binder to be created without matcher (#61018)
Currently to create an `R3TargetBinder`, we have to pass some sort of directive matcher, however we also have a couple of use cases where we use the binder to do analysis that's unrelated to directives (e.g. resolving the `@defer` blocks). In these cases having to create a dummy matcher adds some slight overhead and makes the code harder to reason about since it looks like directive matching may be happening.

These changes update the `R3TargetBinder` to allow for `null` to be passed as the directive matcher.

PR Close #61018
2025-04-29 21:06:10 +00:00
Kristiyan Kostadinov
8488279659 refactor(compiler): simplify tracking of directives (#61018)
An earlier commit that introduced tracking of selectorless directives to the template binder made it so `getDirectivesOfNode` returns _all_ of the matched directives while a new method called `getOwnedDirectives` would return only the ones brought in by the specific node.

In hindsight, this is likely to cause bugs in the future, because it's unclear whether to reach for `getDirectivesOfNode` or `getOwnedDirectives`. These changes remove `getOwnedDirectives` and make it so in selectorless `getDirectivesOfNode` accepts the directive AST node itself.

Another goal of this refactor is that the TCB shouldn't have to check the `selectorlessEnabled` config option.

PR Close #61018
2025-04-29 21:06:10 +00:00
Andrew Scott
10033087b5 refactor(devtools): update zoneless provider name (#61051)
updates the zoneless provider name in the devtools example

PR Close #61051
2025-04-29 20:20:02 +00:00
Andrew Scott
b7d3f3dbfc feat(common): Allow passing ScrollOptions to ViewportScroller (#61002)
Adds ScrollOptions as an option second argument to ViewportScroller
scrollTo* functions.

Part of changes needed to address #58258

PR Close #61002
2025-04-29 12:23:12 -07:00
Angular Robot
3735d55f6f build: update cross-repo angular dependencies (#61045)
See associated pull request for more information.

PR Close #61045
2025-04-29 12:21:16 -07:00
Matthieu Riegler
2df00c9b4b build(devtools): cleanup dependencies (#60936)
Removing `platform-browser-dynamic` because we don't need it anymore.

PR Close #60936
2025-04-29 12:16:16 -07:00