Commit graph

14688 commits

Author SHA1 Message Date
Leon Senft
01bfb83fc9 test(forms): submit behavior while validation is pending
Ensure `submit()` behaves as expected while a form is pending.

- Submission is not blocked by pending validation.
- Submission errors prevent pending validation errors from appearing
  after they resolve on the same field.
- Submission errors don't prevent pending validation errors from
  appearing after they resolve on subfields.
2026-01-28 00:15:29 +00:00
Jaime Burgos
4448356313
test(common): enables zoneless change detection in tests
Adds `provideZonelessChangeDetection` to TestBed configurations in  `ngComponentOutlet` , `ngOptimizedImage` , `ngTemplateOutlet` and `ngPlural`.
2026-01-28 00:08:46 +00:00
Andrew Scott
8a7cbd4668 fix(language-service): Detect local project version on creation
This updates the language service to use the detected version of angular
core in the given project on load rather than the minimum detected
version in the workspace
2026-01-26 23:51:31 +00:00
Angular Robot
3e7808b39f build: update cross-repo angular dependencies
See associated pull request for more information.

Closes #66702 as a pr takeover
2026-01-26 23:51:05 +00:00
Andrew Scott
b51bab583d feat(router): Add partial ActivatedRouteSnapshot information to canMatch params
This commit adds partial `ActivatedRouteSnapshot` information as the
third parameter of the `canMatch` guard.

resolves #49309
2026-01-26 23:36:06 +00:00
Andrew Scott
57e80a5737 refactor(router): Add type for partial ActivatedRouteSnapshot for easier re-use
This adds a type for the partial `ActivatedRouteSnapshot` that includes
only information up to a point in the matching algorithm.
2026-01-26 23:36:06 +00:00
Andrew Scott
042e6d2616 refactor(router): extract snapshot creation to shared helper
extracts ActivatedRouteSnapshot creation to a shared helper method
2026-01-26 23:36:06 +00:00
Matthieu Riegler
899df39c7c docs(docs-infra): remove unused examples 2026-01-26 23:19:35 +00:00
Matthieu Riegler
87a72f3dd0 docs: add mentions of the global target syntax. 2026-01-26 22:31:11 +00:00
Andrew Scott
dbd50be7f7 fix(router): Do not intercept reload events with Navigation integration
This commit prevents the Router from intercepting reload navigations
in the navigate event listener. This would convert hard page reloads
to SPA navigations.

fixes #66746
2026-01-26 22:29:51 +00:00
Miles Malerba
fb05fc86d0
fix(forms): sort error summary by DOM order
This will allow users to rely on the `errorSummary` order to implement
features like "focus next error"
2026-01-26 22:29:07 +00:00
SkyZeroZx
1df564b9f9 refactor(core): remove index from text node creation
Removes unnecessary `index` parameter from `_locateOrCreateTextNode`
and `locateOrCreateTextNodeImpl` functions.
2026-01-26 22:22:56 +00:00
SkyZeroZx
8feb541060 refactor(core): improve tree-shaking
Refactors getNodeInjectable to avoid pulling in stringifyForError production builds, reducing unnecessary symbols in production bundles
2026-01-26 22:18:56 +00:00
Jaime Burgos
d306737e54
docs: add resource composition with snapshots section 2026-01-26 17:02:48 +00:00
Andrew Scott
8bbe6dc46c feat(common): Add Location strategies to manage trailing slash on write
Adds dedicated `LocationStrategy` subclasses: `NoTrailingSlashPathLocationStrategy` and `TrailingSlashPathLocationStrategy`.

The `TrailingSlashPathLocationStrategy` ensures that URLs prepared for the browser always end with a slash, while `NoTrailingSlashPathLocationStrategy` ensures they never do. This configuration only affects the URL written to the browser history; the `Location` service continues to normalize paths by stripping trailing slashes when reading from the browser.

Example:
```typescript
providers: [
  {provide: LocationStrategy, useClass: TrailingSlashPathLocationStrategy}
]
```

This approach to the trailing slash problem isolates the changes to the
existing LocationStrategy abstraction without changes to Router, as was
attempted in two other options (#66452 and #66423).

From an architectural perspective, this is the cleanest approach for several reasons:

1. Separation of Concerns and "Router Purity": The Router's primary job is to map a URL structure to an application state (ActivatedRoutes). It shouldn't necessarily be burdened with the formatting nuances of the underlying platform unless those nuances affect the state itself. By pushing trailing slash handling to the LocationStrategy, you treat the trailing slash as a "platform serialization format" rather than a "router state" concern. This avoids the "weirdness" in #66423 where the UrlTree (serialization format) disagrees with the ActivatedRouteSnapshot (logical state).

2. Tree Shakability: If an application doesn't care about trailing slashes (which is the default "never" behavior), they don't pay the cost for that logic. It essentially becomes a swappable "driver" for the URL interaction.

3. Simplicity for the Router: #66452 (consuming the slash as a segment) bleeds into the matching logic, potentially causing issues with child routes or wildcards effectively "eating" a segment that should be invisible. This option leaves the matching logic purely focused on meaningful path segments by continuing to strip the trailing slash on read.

4. Consistency with Existing Patterns: Angular already uses LocationStrategy to handle Hash vs Path routing. Adding "Trailing Slash" nuances there is a natural extension of that pattern—it's just another variation of "how do we represent this logic in the browser's address bar?"

fixes #16051
2026-01-23 20:09:23 +00:00
SkyZeroZx
85122cb12d docs: update bootstrapApplication docs 2026-01-23 19:45:13 +00:00
Miles Malerba
ebae211add feat(forms): introduce parse errors in signal forms
Parse errors allow a custom control to communicate that it is currently
unable to produce a valid value.

Parse errors are reported by implementing the optional `parseErrors`
property on the `FormUiControl`. The property should be a signal of the
current parse errors.

Also renames several `*Field` types to `*FieldTree`. This aligns with the new naming of the concept after `Field` was renamed
to `FieldTree`.
2026-01-22 22:19:10 +00:00
Kristiyan Kostadinov
dbc1452de3 refactor(compiler-cli): remove deprecated signature usage
The signature for `createImportClause` was deprecated in TS 5.9. These changes switch to the non-deprecated one.
2026-01-22 21:02:36 +00:00
Matthieu Riegler
f0b1061791 docs(docs-infra): Handle additional description format
Ex: https://angular.dev/api/router/withExperimentalPlatformNavigation
2026-01-21 11:37:08 -08:00
Matthieu Riegler
b885851cbe build: don't substitute binary files
Previously, ng_package applied version stamping to all source files, which corrupted binary files like SQLite databases.

This change ignores text substitution for files passed to the `data` attribute, ensuring binary assets are preserved intact in the final package.

fixes #66637
2026-01-21 10:35:04 -08:00
JoostK
d94b19a92f fix(compiler-cli): drop .tsx extension for generated relative imports
When synthesizing an import corresponding with a .tsx file, the extension
would not be removed unlike regular .ts files. Adjust the import generators
to also drop any .tsx extension from module specifiers.

Closes #66262
2026-01-21 10:33:14 -08:00
Kristiyan Kostadinov
6bda88d203 refactor(compiler): use constants for parameter names
Uses the existing constant for `ctx` and `rf`, instead of hardcoding the strings in a few places.
2026-01-21 10:13:54 -08:00
Shuaib Hasan Akib
6284126da5 refactor(common): cleanup unused code in doc regions
Cleans unused imports and code
that is not referenced within the associated docregion blocks.
2026-01-20 16:31:10 -08:00
Kristiyan Kostadinov
e4c09776b0 refactor(compiler): remove unused symbols
Removes symbols that aren't used anymore from the identifiers map.
2026-01-20 16:14:16 -08:00
Andrew Scott
ed78fa05c7 fix(core): Remove note to skip arrow functions in best practices
Arrow functions are now supported and this note is no longer needed
2026-01-20 10:42:42 -08:00
Kristiyan Kostadinov
ce80136e7b fix(compiler): optimize away unnecessary restore/reset view calls
When producing a listener, the template pipeline does the following in separate phases:
1. Generates all the variables available within its scope.
2. Adds `restoreView` and `resetView` calls if there are any referenced to local variables (e.g. `@let` or local refs).
3. Optimizes away the variables that aren't used.

This means that we can end up in a situation where the references to the variables in the scope no longer exist, but we still enter and leave the view as if they're there which is unnecessary.

These changes add a simple optimization pass that looks specifically for the pattern of a `restoreView` followed by a `return resetView(expr)`. Furthermore, by changing the order of some optimizations, we're able to drop the `getCurrentView` variable as well.

Fixes #66286.
2026-01-20 10:22:55 -08:00
Leon Senft
d0ba332292 refactor(forms): remove unused API
Remove `SubmittedStatus` which is no longer used.
2026-01-20 10:19:58 -08:00
hawkgs
92d2498910 feat(core): add host node to DeferBlockData (#66546)
Add the host/container comment node to the `DeferBlockData`. This node can be used as a `@defer` block locator in the DOM tree in the absence of root nodes.

PR Close #66546
2026-01-20 18:16:32 +00:00
Shuaib Hasan Akib
4adbc4fa19 refactor(forms): update Reactive Forms guide URL
Updates the Reactive Forms documentation link to the new `guide/forms/reactive-forms` path after the recent docs restructure.
2026-01-20 10:11:48 -08:00
SkyZeroZx
95c386469c feat(forms): Add passing focus options to form field
Extends the `focus` method of form fields and custom controls to accept and propagate `FocusOptions`.

This enables developers to control focus behavior more precisely, for example, preventing scrolling when focusing an element.
2026-01-16 13:24:27 -08:00
Angular Robot
9989c5fb78 build: update dependency @csstools/css-color-parser to v4
See associated pull request for more information.
2026-01-16 10:30:20 -08:00
Kristiyan Kostadinov
52bc0208f9 build: move zone.js build off deprecated flag
The Zone.js build was depending on the `--outFile` flag from TypeScript which is deprecated. These changes switch to using `--outDir` and copying the files out of the directory instead.
2026-01-16 09:28:47 -08:00
Miles Malerba
e7b2dde6d1 fix(forms): fix control value syncing on touch
Previously we were unconditionally setting the control value back into
the value, regardless of if it had actually been changed. This PR
changes the logic to flush the pending sync on touch if there is one, or
just skip it if there isn't.
2026-01-16 09:25:27 -08:00
Angular Robot
54fc393d27 build: update dependency @csstools/css-calc to v3
See associated pull request for more information.
2026-01-16 09:20:05 -08:00
Kristiyan Kostadinov
d9c980a958 build: initial test of TypeScript 6
Resolves some initial test failures after updating to TypeScript 6.
2026-01-15 13:41:01 -08:00
Kristiyan Kostadinov
4831a9f676 fix(core): handle Set in class bindings
Currently migrating from `[ngClass]` to `[class]` isn't entirely supported, because `[ngClass]` supports `Set` values while `[class]` ignores them.

These changes add a bit of logic to bring them closer together and make the migration easier.
2026-01-15 13:39:59 -08:00
Miles Malerba
5974cd0afc
feat(forms): Ability to manually register a form field binding in signal forms
This PR adds the ability to manually register a binding with the
`FormField` directive. This is useful for a lower-level implementation
that takes the field tree as an `input()` rather than relying on the
automatic binding from `FormUiControl`.
2026-01-15 11:03:28 -08:00
Angular Robot
ebc52ff434 build: update all non-major dependencies
See associated pull request for more information.
2026-01-15 10:52:48 -08:00
Younes Jaaidi
a904d9f77b fix(compiler-cli): support nested component declaration
```ts
@Component(...)
class Outer {
  constructor() {
    @Component(...)
    class Inner {}
  }
}
```

previous behavior was that IVy transformation was only applied to `Inner`, thus breaking `Outer` transformation.
2026-01-14 08:10:34 -08:00
Jessica Janiuk
e673eb6df2 Revert "refactor(core): remove ng when invoking enableProdMode"
This reverts commit cb5879f566.
2026-01-14 08:08:58 -08:00
Matthieu Riegler
cb5879f566 refactor(core): remove ng when invoking enableProdMode
This was caught while investigating a leak.
2026-01-13 11:39:48 -08:00
Jeremy Elbourn
871fa1b2dd docs: update OnChanges API reference w/ signal input
We had some reports of LLMs claiming that `ngOnChanges` does not include
changes for signal-based inputs. This is wrong (and the LLMs just made
it up), but we can update the docs at least to demonstrate `ngOnChanges`
with signal-based inputs.

Previously, the API reference used a real test as a code example, but
updating the test to a signal-based input is more involved than this
change needs to call for.
2026-01-13 09:04:24 -08:00
Matthieu Riegler
72534e2a34 feat(compiler): Add support for the instanceof binary operator
Because why not ?

fixes #59975
2026-01-13 08:33:12 -08:00
SkyZeroZx
a39e3fdabe docs: update examples to use isActive instead of deprecated Router.isActive (#66430)
PR Close #66430
2026-01-12 22:42:32 +00:00
Andrew Scott
e8c44a00f9 refactor(router): Retain original navigateEvent across redirects
This builds off of #66197 by retaining the original navigateEvent across redirects
so the NavigateEvent can more accurately track the lifecycle of a navigation,
which may span across several NavigationStart events due to redirects
2026-01-12 14:41:54 -08:00
Alex Rickabaugh
1ba9b7ac50 feat(core): resource composition via snapshots
* Define `ResourceSnapshot<T>` as a type union of possible states for a
`Resource<T>`.
* Add `Resource.snapshot()` to convert a `Resource` to a signal of its
  snapshot.
* Add `resourceFromSnapshots` to convert a reactive snapshot back into a
  `Resource`.

By converting resources from/to `Signal<ResourceSnapshot>`s, full
composition of resources is now possible on top of signal composition APIs
like `computed` and `linkedSignal`.

For example, a common feature request is to have a `Resource` which retains
its value when its reactive source (params) changes. This can now be built
as a utility, leveraging `linkedSignal`'s previous value capability:

```ts
function withPreviousValue<T>(input: Resource<T>): Resource<T> {
  const derived = linkedSignal({
    source: input.snapshot,
    computation: (snap, previous) => {
      if (snap.status === 'loading' && previous?.value) {
        // When the input resource enters loading state, we keep the value
        // from its previous state, if any.
        return {status: 'loading', value: previous.value.value};
      }

      // Otherwise we simply forward the state of the input resource.
      return snap;
    },
  });

  return resourceFromSnapshots(derived);
}

// In application code:

userId = input.required<number>();
user = withPreviousValue(httpResource(() => `/user/{this.userId()}`));
// if `userId()` switches, `user.value()` will keep the old value until
// the new one is ready!
```
2026-01-12 13:49:56 -08:00
Matthieu Riegler
65fa5b5439 fix(forms): Ensure the control instruction comes after the other bindings
Prior to this change, binding to radio value was sensitive to the order in which `value` & `formField` where binding in the template.
The compiler change makes that order non-important.

fixes #66402
2026-01-12 13:49:19 -08:00
cexbrayat
7fd076bdd3 test(forms): improve test coverage for multiple pattern validators
Add comprehensive test cases to validate behavior when multiple
pattern validators are applied to the same field.

These tests clarify that multiple patterns operate with AND logic,
where each pattern is validated independently and produces its own
error when it doesn't match.
2026-01-12 13:48:16 -08:00
Shuaib Hasan Akib
1b4dcc01ff docs: replace old https://angular.io/license with https://angular.dev/license 2026-01-12 13:41:30 -08:00
SkyZeroZx
e38c1bf743 refactor(http): remove redundant providedIn: 'root' in XSRF_HEADER_NAME
Removes unnecessary `providedIn: 'root'` declarations from injection token
2026-01-12 10:00:24 -08:00