Commit graph

1033 commits

Author SHA1 Message Date
Andrew Scott
997117bb76 refactor(router): Clean up the transition subject (#60357)
This commit cleans up the transition subject a bit so it doesn't use a dummy
initial value. It also avoids copying over data from the previous
request when a new one is created.

PR Close #60357
2025-03-14 11:16:15 +01:00
Andrew Scott
c054d620dd refactor(router): Update to use early return to reduce nesting (#60377)
Updates a switchTap body to use early return to reduce nesting

PR Close #60377
2025-03-14 11:15:28 +01:00
Andrew Scott
0b6084e1bf refactor(router): split remainder of describes in integration test file (#60313)
to more easily navigate and identify different suites of integration tests,
this commit splits them into several different files

PR Close #60313
2025-03-11 17:13:27 -07:00
Andrew Scott
7677578695 refactor(router): Add safe navigation operator (#60314)
Adds safe navigation operator to account for tests spying on navigateByUrl

PR Close #60314
2025-03-11 12:59:43 -07:00
Kristiyan Kostadinov
611baaf069 feat(core): remove InjectFlags from public API (#60318)
Removes the deprecated `InjectFlags` symbol from the `@angular/core` public API, as well as all the places that accept it. The previous commit includes an automated migration to switch over to the new way of passing in flags.

BREAKING CHANGE:
* `InjectFlags` has been removed.
* `inject` no longer accepts `InjectFlags`.
* `Injector.get` no longer accepts `InjectFlags`.
* `EnvironmentInjector.get` no longer accepts `InjectFlags`.
* `TestBed.get` no longer accepts `InjectFlags`.
* `TestBed.inject` no longer accepts `InjectFlags`.

PR Close #60318
2025-03-11 11:33:09 -07:00
Vlad Boisa
a129ae5c1f docs: fix one broke link by #57591 (#60237)
Fix 1 link in adev toolchain `{@link forRoot}`
PR Close #60237
2025-03-11 09:24:02 -07:00
Andrew Scott
647550918f refactor(router): split integration test file (#60311)
to more easily navigate and identify different suites of integration tests,
this commit splits them into several different files

PR Close #60311
2025-03-10 16:03:54 -07:00
Andrew Scott
219f41d049 fix(router): Prevent dangling promise rejections from internal navigations (#60162)
Though the plan is to change the default behavior or the router to
instead resolve the navigation promise with `false` to match all other
failed navigations, we should still prevent dangling promise rejections
from navigations triggered internally when developers opt to use the old
(current) behavior.

PR Close #60162
2025-03-06 07:58:18 -08:00
Samuel Perez
6dd8cce155 docs: fix all brokens links on the API pages (#59162)
This PR fix is for the broken links on the API
pages mentioned in issue #57591.

PR Close #59162
2025-03-04 20:07:23 +00:00
Andrew Scott
db2f2d99c8 fix(router): Scroller should scroll as soon as change detection completes (#60086)
Using `setTimeout` to delay scrolling can result in scrolling in the
next frame and cause noticeable flicker. This commit races rAF and
timeout to ensure scroll happens before the render.

fixes #53985

PR Close #60086
2025-02-25 14:17:07 -05:00
Andrew Scott
7c12cb1df9 feat(router): Allow resolvers to read resolved data from ancestors (#59860)
This commit updates the resolver execution to ensure that resolvers in
children routes are able to read the resolved data from anything above
them in the route tree. Because resolvers on one level block execution
of those below, it seems more of an oversight in the initial
implementation than anything else that this wasn't already possible.

resolves #47287

PR Close #59860
2025-02-25 12:34:40 -05:00
arturovt
acdde4aa35 refactor(router): remove unused code (#59704)
This code is never used.

PR Close #59704
2025-01-28 09:38:34 +01:00
arturovt
c7b6e1107c fix(router): prevent error handling when injector is destroyed (#59457)
In this commit, we prevent error handling when the root injector is already destroyed. This may happen when the observable completes before emitting a value, which would trigger a `catchError` block that attempts to call `runInInjectionContext` on a destroyed injector.

PR Close #59457
2025-01-23 14:21:07 -08:00
Matt Janssen
16b08853bc docs(router): Fix small grammatical errors (#59568)
Improves readability.
PR Close #59568
2025-01-17 13:21:26 -08:00
arturovt
c51c66ef1e refactor(router): drop forRoot guard in production (#59458)
In this commit, we switch from decorators (which also produce redundant metadata, such as in the `declareFactory`
instruction) to the `inject` function to drop the `ROUTER_FORROOT_GUARD` token in production. This token factory function is only in development mode but is still referenced in the constructor due to the `@Inject(ROUTER_FORROOT_GUARD)` decorator.

PR Close #59458
2025-01-16 13:55:49 -08:00
hawkgs
b9155b5121 docs: set syntax highlighting to the remaining Markdown code examples blocks (#59088)
There are some code blocks that slipped through the initial Regex-es.

Related to #59026

PR Close #59088
2025-01-14 15:14:02 -05:00
arturovt
06214821ca refactor(core): change LContainerFlags to const enum (#59416)
Prior to this commit, the compiler produced:

```js
No = (function (e) {
  return (
    (e[(e.None = 0)] = "None"),
    (e[(e.HasTransplantedViews = 2)] = "HasTransplantedViews"),
    e
  );
})(No || {});
```

Changing to `const enum` allows it to be entirely dropped and inline values.

PR Close #59416
2025-01-09 10:38:28 -05:00
zhangenming
a201d455e6 docs(router): update link to development guide in README.md (#59388)
PR Close #59388
2025-01-09 10:29:38 -05:00
RafaelJCamara
5c9e84acd6 docs: update license URL from angular.io to angular.dev and year of license to 2025 (#59407)
PR Close #59407
2025-01-09 10:27:54 -05:00
arturovt
52a6710f54 fix(router): complete router events on dispose (#59327)
In this commit, we manually complete the `events` subject to remove all active observers and enable
granular garbage collection, as users may forget to unsubscribe manually when subscribing to `router.events`.

PR Close #59327
2025-01-07 17:06:26 +00:00
Kristiyan Kostadinov
5ac6f065ab fix(router): avoid component ID collisions with user code (#59300)
Currently the `ɵEmptyOutletComponent` is very prone to generating ID collision warnings with user code, because it only has one child and no other metadata. This shows up some of our tests as well. While users can resolve it on their end, it can be confusing since they won't have any references to `ɵEmptyOutletComponent` in their own code.

These changes add an `exportAs` to it to make its component ID unique. This doesn't affect the public API of the component since users can't use it directly anyways.

PR Close #59300
2025-01-06 19:18:52 +00:00
arturovt
a088208690 refactor(router): replace mapTo since deprecated (#59333)
Replaces `mapTo` with `map` because, in RxJS, `mapTo` is deprecated and internally uses `map`.

PR Close #59333
2025-01-06 19:18:21 +00:00
Alan Agius
24e317cb15 refactor: replace ɵPendingTasks with ɵPendingTasksInternal (#59138)
This commits remove usage of the old export.

PR Close #59138
2024-12-10 13:45:07 -08:00
Sheik Althaf
fe40143813 refactor(router): remove standalone true (#58950)
removed the standalone true from router package.

PR Close #58950
2024-12-05 16:02:37 -08:00
Alex Rickabaugh
4a0c6cd435 refactor(router): remove circular dep in router navigation code (#59083)
Use `import type` to break phantom circular imports for the router
navigation implementation.

PR Close #59083
2024-12-05 16:01:15 -08:00
Alex Rickabaugh
e61a19957f refactor(router): remove circular dep in router model definitions (#59083)
Use `import type` to break phantom circular imports for router model
definitions.

PR Close #59083
2024-12-05 16:01:15 -08:00
Alex Rickabaugh
ee53dc07de refactor(router): remove circular dep in RouterOutletContext (#59083)
Use `import type` to break phantom circular imports for
`RouterOutletContext`.

PR Close #59083
2024-12-05 16:01:15 -08:00
hawkgs
0513fbc9fc docs: set syntax highlighting of code examples MD code blocks (#59026)
Set the syntax highlighting based on the code examples' language.

PR Close #59026
2024-12-04 17:30:28 +01:00
Jelle Bruisten
61ae17a419 refactor(router): remove unused default error handler function (#58819)
with v19 the `defaultErrorHandler` has become unused, so could be removed

PR Close #58819
2024-11-26 14:49:37 +00:00
Joey Perrott
bad36519f2 fix(router): remove setter for injector on OutletContext (#58343)
This is a cleanup/completion of the work in #56798

PR Close #58343
2024-10-24 16:41:04 -07:00
Alex Rickabaugh
a264c78b34 refactor: cleanup initializers that use ctor params (#58349)
Fix initializer of instance members that reference identifiers declared in
the constructor.

When public class fields are enabled, such cases throw TS2729: property used
before its initialization.

PR Close #58349
2024-10-24 16:38:50 -07:00
Néstor Sabater
18ddf0de76 docs(router): document segment consumption during route evaluation (#58069)
PR Close #58069
2024-10-24 12:41:38 -07:00
Sumit Arora
0ea9b8892b test(router): adding test for getLoadedRoutes (#58199)
Added test for getLoadedRoutes with and without loadChildren

PR Close #58199
2024-10-22 09:40:45 -07:00
Sumit Arora
0674965b59 refactor(router): publishing getLoadedRoutes using the global utils function (#58199)
Angular DevTools uses globally available functions to provide debugging information to the framework. This commit exports `getLoadedRoutes` function using the `ɵpublishExternalGlobalUtil` function added in PR: f5cd8f7ab4.

Follow-up PRs that will:
- Add a new router example in the Angulat DevTools demo application.
- Implement the router graph in the Angular DevTools to view the routes that are loaded in the application

PR Close #58199
2024-10-22 09:40:45 -07:00
Matthieu Riegler
09df589e31 refactor(core): Migrate all packages with the explicit-standalone-flag schematic. (#58160)
All components, directives and pipes will now use standalone as default.
Non-standalone decorators have now `standalone: false`.

PR Close #58160
2024-10-14 14:58:57 +00:00
Matthieu Riegler
84b6896956 refactor(platform-server): Add an ssr benchmark setup. (#57647)
In order to investigate the performances of SSR, this commit introduces a benchmark suite which will measure several step of the rendering.

PR Close #57647
2024-10-04 10:45:22 -07:00
Andrew Scott
ed57c5c9c8 docs: export ComponentInputBindingFeature which is part of the public API (#57962)
this fixes a missing export of ComponentInputBindingFeature

PR Close #57962
2024-10-01 08:30:03 +00:00
Andrew Scott
2ece9dff75 docs(router): Document missing input for route binding (#57697)
This commit clearly documents the approach used by router input binding
when an input is not present in the route data.

resolves #52946

PR Close #57697
2024-10-01 08:09:32 +00:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Andrew Scott
48216a28e8 refactor(router): Move view transitions to developer preview (#55600)
Nothing of concern arose during the time this feature was in the
experimental phase. There are no plans to change the shape of the API.

This change also updates the route animations documentation to use the
view transitions feature instead of the old and difficult to follow
guide that used the animations package. The content was taken from the
blog post: https://blog.angular.io/check-out-angulars-support-for-the-view-transitions-api-3937376cfc19

PR Close #55600
2024-09-24 12:07:02 +02:00
Matthieu Riegler
b23113dc96 refactor(common): replace non output EventEmitter with Subject. (#54666)
Semantcly we're shifting away from using `EventEmitter` on non-outputs.

PR Close #54666
2024-09-24 11:58:24 +02:00
Andrew Scott
8f6308457f fix(router): Do not unnecessarily run matcher twice on route matching (#57530)
This commit makes a small update to the route matching algorithm to
avoid running the matcher function of a route twice.

fixes #57511

PR Close #57530
2024-08-27 13:20:58 -07:00
Andrew Scott
b2790813a6 fix(router): Align RouterModule.forRoot errorHandler with provider error handler (#57050)
This change aligns the behavior of the error handler in the
`ExtraOptions` of `RouterModule.forRoot` with the error handler in
`withNavigationErrorHandler`. The changes are:

* Slightly different timing: The handler is called before the
  `NavigationError` emits
* Runs in the injection context, meaning it is more configurable at the
  config location rather than needing to assign the value to the
  `Router.errorHandler` later to get access to injectables
* Can now return `RedirectCommand` to recover from the error and
  redirect without emitting `NavigationError`
* No longer allows arbitrarily overriding return value of the navigation
  promise

BREAKING CHANGE: The `Router.errorHandler` property has been removed.
Adding an error handler should be configured in either
`withNavigationErrorHandler` with `provideRouter` or the `errorHandler`
property in the extra options of `RouterModule.forRoot`. In addition,
the error handler cannot be used to change the return value of the
router navigation promise or prevent it from rejecting. Instead, if you
want to prevent the promise from rejecting, use `resolveNavigationPromiseOnError`.

PR Close #57050
2024-08-12 09:28:08 -07:00
Andrew Scott
7436d3180e fix(router): Update Resolve interface to include RedirectCommand like ResolveFn (#57309)
This commit updates the interface of `Resolve` to allow for
`RedirectCommand`, as was done with `ResolveFn` in v18.

fixes #57131

BREAKING CHANGE: The return type of the `Resolve` interface now includes
`RedirectCommand`.

PR Close #57309
2024-08-12 09:26:53 -07:00
Andrew Scott
f271021e19 feat(router): Add routerOutletData input to RouterOutlet directive (#57051)
This commit adds an input to `RouterOutlet` that allows developers to
pass data from a parent component to the outlet components.
Setting the `routerOutletData` input on `RouterOutlet` makes the value
available to the child component injectors via the `ROUTER_OUTLET_DATA`
token. This token uses a `Signal` type to allow updating the input value
and propogating it to the token rather than needing to make the value
static.

resolves #46283

PR Close #57051
2024-08-09 08:08:26 -07:00
David LJ
d465061f00 docs(router): update initial navigation SSR note (#57245)
With rephrasing by @AndrewKushnir

PR Close #57245
2024-08-07 16:45:30 +00:00
Andrew Scott
6c76c91e15 feat(router): Add defaultQueryParamsHandling to router configuration (#57198)
This commit adds an option to specify the default value for
`queryParamsHandling` in `Router.createUrlTree` when another option is
not specified (or is `null|undefined`).

resolves #12664

PR Close #57198
2024-08-02 15:11:38 +00:00
Andrew Scott
3459289ef0 feat(core): bootstrapModule can configure NgZone in providers (#57060)
This commit allows configuring `NgZone` through the providers for
`bootstrapModule`. Prior to this change, developers had to configure
`NgZone` in the `BootstrapOptions`.

PR Close #57060
2024-07-30 18:03:35 +00:00
Joey Perrott
2d8635d29d refactor(docs-infra): migrate @angular/docs from dev-infra into adev directory (#57132)
To increase the ease of development we are moving @angular/docs into the adev directory within this repo. While
we are doing this to improve our development experience in the short term, efforts are also in place
to maintain a division between this @angular/docs (shared) code and adev itself, so that it can be extracted
back out in the future when components is ready to leverage it as well.

PR Close #57132
2024-07-30 15:51:26 +00:00
Andrew Scott
0e439d78c2 Revert "fix(router): Scroller should scroll as soon as change detection completes (#55105)" (#57115)
This reverts commit 66ffeca2de.

It looks like nuxt encountered the same issue with scrolling when
waiting for Vue's `nextTick`, which is a microtask. This would have
similar timing to ZoneJS's rendering in the microtask queue. This
reverts to a `setTimeout` alone, though recreates the problem in #53985.
This was also mentioned in one of the comments in the Nuxt issue and the
solution would be `rAF`.

In order to address #53985, we'd likely want to use the `race(rAF, setTimeout)`
that we use in the zoneless and coalescing schedulers. This would have effectively the same timing as
the `afterNextRender` implementation here with zoneless, but quite
different timing to `afterNextRender` with ZoneJS.

fixes #57109

PR Close #57115
2024-07-24 10:04:38 -07:00