Commit graph

14468 commits

Author SHA1 Message Date
Kristiyan Kostadinov
4c8fb3631d fix(core): throw better errors for potential circular references
Currently circular references in user code manifest themselves with an error like `Cannot read properties of undefined (reading 'ɵcmp')`. This is a bit cryptic so these changes add an assertion mentioning circular references.

Relates to #65917.

(cherry picked from commit 7be4ddef1c)
2025-12-12 08:06:30 -08:00
Alan Agius
b8cb6cda30 refactor(compiler): remove unnecessary sanitization for safe attributes
Remove sanitization for attributes that cannot execute code (e.g. `javascript: URIs`).

(cherry picked from commit 128aef0ede)
2025-12-12 08:06:03 -08:00
SkyZeroZx
6d9d2b83f6 refactor(common): remove redundant providedIn: 'root' from injection tokens
Removes unnecessary declarations from injection tokens

(cherry picked from commit 8485579649)
2025-12-12 08:05:34 -08:00
SkyZeroZx
3d25759117 docs(language-service): add link to hydration guide in built-in names documentation
Adds link to hydration guide for `hydrate` keyword

(cherry picked from commit ef45637ca8)
2025-12-11 17:06:39 -08:00
Miles Malerba
4fd2b722b4 fix(forms): fix signal forms type error
Removes the `implements` clause on the `Field` directive since it is
causing type errors for people.

(cherry picked from commit d0097f7d0c)
2025-12-11 15:33:17 -08:00
SkyZeroZx
69d243abb7 fix(core): avoid false-positive deprecation when using InjectionToken with factory only
Prevents the deprecation warning that was incorrectly triggered when
defining an InjectionToken with only a `factory`, which correctly
defaults to the `root` scope.

(cherry picked from commit 4f6014a756)
2025-12-11 11:20:17 -08:00
Angular Robot
c937da491c build: update cross-repo angular dependencies
See associated pull request for more information.
2025-12-10 16:42:43 -08:00
SkyZeroZx
6930a2e8c8 docs: update forwardRef usage with signals and add HostListener note
(cherry picked from commit bff2dcb93c)
2025-12-10 12:23:33 -08:00
Andrew Scott
497c0e36ab refactor(core): Add transition.to property to FakeNavigation
This matches the upstream changes in f19930f98a

(cherry picked from commit 5988bdedae)
2025-12-10 10:18:13 -08:00
Matthieu Riegler
cbb10179c8 fix(forms): allow resetting with empty string
Both empty string and null values should be accepted when resetting

fixes #65949

(cherry picked from commit 14713d0992)
2025-12-10 10:04:58 -08:00
Andrew Scott
01ab257da4 refactor(core): match spec updates for FakeNavigation
Updates FakeNavigation based on updates in https://github.com/whatwg/html/pull/11952

(cherry picked from commit d355205198)
2025-12-10 08:19:28 -08:00
Matthieu Riegler
84f397c831 refactor(core): Support Error like object for on resource errors.
Error like object will be treated as errors.

Related to #61861

(cherry picked from commit 835a643161)
2025-12-10 08:18:24 -08:00
Joey Perrott
96bb4c6ae3 build: add the ignore all rc files flag when running bazel info
Due to a bug in bazel we need to ignore all of the rc files when running bazel info commands

(cherry picked from commit 9ace7d7a0d)
2025-12-09 13:44:49 -08:00
Kristiyan Kostadinov
65297c6201 fix(compiler-cli): expand type for native controls with a dynamic type
We recently allowed users to have a dynamic input `type` with signal forms, but the logic that infers the value type falls back to `string` even though in theory it can be any of the other types.

These changes expand the inferred type to `string | number | boolean | Date | null` if we detect a dynamic `type` binding.

(cherry picked from commit 8a3f3a91cf)
2025-12-09 13:01:35 -08:00
kirjs
6d7475582f fix(forms): Reuse key in parent in compat structure
This fixes the "Compat nodes do not use keyInParent." error when trying to bind compatField.

(cherry picked from commit 179b4cba67)
2025-12-09 12:59:27 -08:00
arturovt
bb0061ba63 refactor(core): wrap operationsCounter calls with ngDevMode checks
Wrap operationsCounter method calls (recordCreate, recordDestroy, reset)
with ngDevMode guards to ensure they are tree-shaken in production builds.

This aligns with the existing pattern where operationsCounter is only
initialized in development mode, and eliminates unnecessary method call
overhead in production.

The optional chaining (?.) is retained as TypeScript doesn't narrow types
based on ngDevMode checks, but the entire expression will be removed during
production builds.

(cherry picked from commit 80dbd74ae8)
2025-12-09 10:38:44 -08:00
Matthieu Riegler
ffad78360f refactor(core): add dedicated deprecated signatures for providedIn: any / NgModule.
Those were deprecated by #47616 back in v15.

fixes #65923

(cherry picked from commit 8199945637)
2025-12-09 10:38:14 -08:00
Miles Malerba
f254ff4f2e feat(forms): expose element on signal forms Field directive
This allows for easier focusing of the relevant element based on the
`field` property of a `ValidationError`

(cherry picked from commit aff8b248b3)
2025-12-09 09:47:56 -08:00
Kristiyan Kostadinov
f901cc9eb3 perf(compiler): chain query creation instructions
We always emit the query creation instructions in a group which makes them good candidates for chaining.

(cherry picked from commit ae1c0dc490)
2025-12-09 09:24:41 -08:00
Miles Malerba
5880fbc73c feat(forms): redo the signal forms metadata API
This PR makes a number of changes to the metadata API to address design
flaws in the previous API. Some of the changes include:

- Replaces the previous `MetadataKey` and `AggregateMetadataKey` with a
  single unified `MetadataKey` that is used for all metadata.
- The new `MetadataKey` is only defined for fields that explicitly set
  it in their schema logic
- All metadata now has reducer / aggregate behavior
- The new `MetadataKey` has an option to create a managed key which
  wraps the result of its computed aggregate into some other structure
  such as a `Resource` or `linkedSignal`
- There are now two APIs to create metadata keys
  - `createMetadataKey` for pure computed metadata
  - `createManagedMetadataKey` for metadata that manages its computation
    internally

(cherry picked from commit ebc5c2b083)
2025-12-09 09:21:45 -08:00
Joey Perrott
53f752e7a3 build: update repository to use node 22.21.1 in bazel
The repository was updated to use node 22.21.1 via nvm, but bazel had not been updated to match

(cherry picked from commit 349133374f)
2025-12-09 09:19:19 -08:00
cexbrayat
55fc677cef fix(forms): add signals for dirty, hidden, and pending states in custom controls
FormUiControl states that hidden, pending and dirty will be bind in custom controls, but this is currently not the case.

Fixes #65575

(cherry picked from commit 9fe9566581)
2025-12-08 10:30:48 -08:00
Anuj Chhajed
288238abef refactor(core): correct all typeof ngDevMode comparison patterns introduced by #63875
This change replaces all remaining occurrences of `typeof ngDevMode !== undefined`
with the correct `typeof ngDevMode !== 'undefined'` form. This aligns the codebase
with JavaScript typeof semantics and maintains consistency with other Angular code.

(cherry picked from commit 96b79fc393)
2025-12-08 10:30:06 -08:00
Miles Malerba
a4c436a058 refactor: followup cleanup for #65758 fallout
Fixes some issues left behind by recent refactor

(cherry picked from commit efde94a525)
2025-12-08 10:28:04 -08:00
Shuaib Hasan Akib
55709c1de6 refactor(core): use proper type for stringifyTypeFromDebugify parameter
Replace the 'any' type with ClassDebugInfo for the debugInfo parameter in
stringifyTypeFromDebugInfo function. This removes the TODO comment that was
tracking the need for proper typing without creating circular dependencies.

The change improves type safety while avoiding circular imports since
stringify_utils.ts doesn't export anything that definition.ts imports.

(cherry picked from commit 5fd75410a9)
2025-12-08 10:23:21 -08:00
Joey Perrott
ed7db0e0a2 build: update to bazel version 8.4.2
Update bazel to use version 8.4.2

(cherry picked from commit aa92f19307)
2025-12-08 10:22:04 -08:00
Matthieu Riegler
10bdae9098 build: enable angular formatting on all html files
This should also be safe on any html file that isn't an angular template

(cherry picked from commit 9d1d742f1b)
2025-12-08 10:19:50 -08:00
SkyZeroZx
71568e069c docs: add documentation HOST_TAG_NAME
(cherry picked from commit 6f2ef918e3)
2025-12-08 09:08:55 -08:00
SkyZeroZx
56418b108e docs: add documentation for HTTP_TRANSFER_CACHE_ORIGIN_MAP
(cherry picked from commit 7e1e396a00)
2025-12-08 09:00:13 -08:00
Matthieu Riegler
bd4cfc88ef docs(docs-infra): expose VERSION from @angular/upgrade
The missing src was responsible for not exposing the symbols during the doc extraction.

fixes #65916

(cherry picked from commit 81cf319534)
2025-12-08 08:41:40 -08:00
Kirill Cherkashin
7de8558219 refactor(forms): Break logic.ts into separate files
This would make it easier to navigate

(cherry picked from commit 5be33048cc)
2025-12-04 11:33:26 -08:00
Nakul Sharma
d40a517c0f refactor(core): use getComponentDef in stringify_utils
- Use getComponentDef in debugStringifyTypeForError to clean up TODO
- Remove outdated comment from stringify_utils

(cherry picked from commit 0bb8924ab6)
2025-12-04 11:32:17 -08:00
Joey Perrott
c3bd22d10d
build: update cross-repo angular dependencies
See associated pull request for more information.
2025-12-04 11:26:14 -08:00
Alex Rickabaugh
bf1c12cd93 fix(forms): memoize reads of child fields in signal forms (#65802)
Previously, navigating a `FieldTree` in signal forms involved reactive reads
of the value of the parent field(s), both directly and via `.childrenMap()`.

This meant that on _any_ change to the value of a field, reactive
notifications would trigger updates of computeds, reruns of effects, etc.
So for example, this effect would run on every change to the form:

```ts
const f = form(signal({data: 'abc', unrelated: 0}));
effect(() => {
  // accessing f.data incurs a dependency on f().value() which changes
  // on every change in the whole form
  console.log(f.data().value());
});
```

This is deeply counterintuitive and troublesome when attempting to write
effect logic, and also results in `computed`s unnecessarily updating.

This change introduces the concept of a "reader" computed, which memoizes
the access of a field at a given key via the reactive graph. With this, the
same `f.data` access above now depends on the `data` reader in `f` only,
which is effectively a constant computed. As a result, the effect only
reruns on changes to `data`'s value, as intended.

PR Close #65802
2025-12-03 12:52:43 -08:00
Alex Rickabaugh
2c12661620 refactor(forms): simplify child field creation (#65802)
Previously, several values were being passed into the creation of
`FieldNodeStructure`s that were only used in the creation of child nodes.
Separately, we also passed a `createChildNode` function which these values
were passed back into.

Instead, this moves the small bit of logic from structure.ts behind the
`createChildNode` callback, which reduces the passing of values back-and-
forth and gives `createChildNode` a much more suitable signature.

PR Close #65802
2025-12-03 12:52:43 -08:00
SkyZeroZx
6b4ab876e8 feat(forms): Allows transforms on FormUiControl signals
Extends the `FormUiControl` interface to allow `InputSignalWithTransform` in addition to `InputSignal` for its properties.

Fixes #65756

(cherry picked from commit 7d1e502345)
2025-12-03 15:13:06 +01:00
Leon Senft
609699ae17 perf(core): tree shake unused dynamic [field] binding instructions (#65599)
Move the instructions used to dynamically bind a `Field` directive to a
form control onto the `Field` itself. This way the instructions are only
retained if the app uses the `Field` directive.

PR Close #65599
2025-12-03 15:10:50 +01:00
Leon Senft
a5dbd4b382 fix(forms): support dynamic [field] bindings (#65599)
Support binding a `Field` directive to a component created dynamically
with `createComponent()`.

Fix #64632

PR Close #65599
2025-12-03 15:10:49 +01:00
Kristiyan Kostadinov
4bb085311e fix(core): unable to inject viewProviders when host directive with providers is present
When registering providers, the DI system assumes that `viewProviders` are registered before plain `providers`. This was reinforced by components always being first in the array of directive matches, only one component being allowed per node and the fact that only components can have `viewProviders`.

This breaks down if there are host directives with `providers` on the component, because they'll execute earlier, throwing off the order of operations.

These changes fix the issue by separating out the resolvers for `viewProviders` and plain `providers` and explicitly running the component's `viewProviders` resolver before any others. This also has the benefit of not attempting to resolve `viewProviders` for directives which are guaranteed not to have them.

Fixes #65724.

(cherry picked from commit 886cf6c452)
2025-12-03 15:09:53 +01:00
Alan Agius
20474d3f0f fix(http): enable XSRF protection for same-origin absolute URLs
Previously, the XSRF interceptor only added the XSRF token to requests with relative URLs.
This commit updates the interceptor to also add the token to requests with absolute URLs, provided they match the current origin.

(cherry picked from commit 0659d11c85)
2025-12-03 12:19:46 +01:00
Kristiyan Kostadinov
1f1856e897 fix(compiler-cli): check that field radio button values are strings
Adds some type checking code which verifies that the bound `value` on a `Field` radio button is a string.

Fixes #65726.

(cherry picked from commit 6773d3b97d)
2025-12-03 12:19:01 +01:00
arturovt
48b89f9fbe fix(router): handle errors from view transition finished promise
This commit adds a `.catch()` handler to `transition.finished` from `document.startViewTransition` to prevent unhandled promise rejections. The finished promise can reject with `TimeoutError` or `InvalidStateError` when transitions fail during or after the animation phase.

Based on the Blink source code, the `finished` promise can reject with:
* `TimeoutError`: "Transition was aborted because of timeout in DOM update"
* `InvalidStateError`: "Transition was aborted because of invalid state"

This may happen when the DOM update phase exceeds the browser's internal timeout threshold.

(cherry picked from commit b74a0693f2)
2025-12-03 12:17:02 +01:00
Andrew Scott
c2a8934d12 Revert "refactor(router): compress synchronous end to router navigation to single operator"
This reverts commit 71362733cf.
2025-12-02 19:13:07 +01:00
Andrew Scott
71362733cf refactor(router): compress synchronous end to router navigation to single operator
The end of the Router navigation is a block of synchronous logic that
can be compressed into a single operator rather than splitting it across
several, making it harder to step through. The only benefit from the
split is automatic unsubscribe/cancellation, which we can replicate
with an additional 'shouldContinue' check before proceeding.

(cherry picked from commit b7d21e209a)
2025-12-02 16:44:06 +01:00
Kristiyan Kostadinov
5a80a48e96 fix(compiler-cli): avoid allocating an object for signals in production mode
Currently when the signal debug name transform sees something like `const foo = signal(0);`, it transforms the signal into `signal(0, {...(ngDevMode ? { debugName: 'foo' } : {})})`. After minification this becomes `signal(0, {})` which will allocate memory for the empty object literal.

These changes rework the logic to produce `signal(0, ...(ngDevMode ? [{ debugName: 'foo' }] : []))` which will be fully tree shaken away to `signal(0)`.

(cherry picked from commit e30e61b789)
2025-12-02 15:06:55 +01:00
Jessica Janiuk
8c3304c766 fix(core): run animation queue in environment injector context
In the case that a component injector is destroyed before the animation
queue runs, the animation queue would fail to run because it was using a
destroyed injector. This commit changes the animation queue to run in the
context of the EnvironmentInjector, which is not destroyed until the app
is destroyed.

fixes: #65628
(cherry picked from commit d8ab83ca82)
2025-12-02 15:05:21 +01:00
Matthieu Riegler
017672f742 refactor(compiler): Generate the controlCreate instruction after the native element has been created
This is necessary to exclude a race condition where the MutationObserver initialized by the instruction fired before the inputs are binded.

fixes #65678

(cherry picked from commit f35b2ef47c)
2025-12-02 12:59:53 +01:00
Matthieu Riegler
8e0df4083d docs(docs-infra): Show examples on function overloads
(cherry picked from commit a784995a98)
2025-12-02 12:13:16 +01:00
Tim Deschryver
efe4b72abb docs: fix documentation link for currentNavigation method
(cherry picked from commit 680de24c3c)
2025-12-02 12:02:28 +01:00
Angular Robot
706d7620e8 build: update cross-repo angular dependencies
See associated pull request for more information.
2025-12-01 19:36:18 +01:00