3758 Commits
Author SHA1 Message Date
Matthieu Riegler 8b15295e8c fix(core): release leavingNodes when animate.leave resolves to no classes
When an element with an `animate.leave` binding is detached,
`node_manipulation` eagerly records `{el, declarationView}` in the
module-level `leavingNodes` `WeakMap`. Previously, if `runLeaveAnimations`
resolved an empty class list (such as `''`, `[]`, `null`, or
`undefined`), it pushed a resolver and resolved immediately without
starting `animateLeaveClassRunner`, so `clearLeavingNodes` was never
called and every removed element and its declaration view remained
retained for the lifetime of the `TNode`.

Avoid registering a resolver or adding the view to `allLeavingAnimations`
when `activeClasses` is empty, and clear the tracked `leavingNodes` entry
from `node_animations` once leave animations settle (or when the
animation queue cannot be resolved). Clearing at settlement preserves
`leavingNodes` tracking and `declarationView` while composed or
descendant leave animations are still running, while keeping the cleanup
inside the tree-shaken animation runtime. Also delete empty `TNode`
entries from `leavingNodes` in `cancelLeavingNodes`.

Fixes #72141
2026-11-20 09:03:23 -08:00
Doug Parker ec0f0583c3 refactor(core): update WebMCP tool declaration APIs to include outputSchema
Update `ToolDescriptor`, `declareExperimentalWebMcpTool`, and `provideExperimentalWebMcpTools` to explicitly support the `outputSchema` property. This allows tools to specify their expected return format using standard JSON Schema syntax, ensuring that AI agents know exactly how to interpret the tool execution results.
2026-11-20 08:35:37 -08:00
Alex Morris 34c6c98f94 fix(core): update standalone directiveDefs and pipeDefs during HMR
In `mergeWithExistingDefinition`, `directiveDefs` and `pipeDefs` were always
restored from `clone` to preserve remote scopes patched by
`ɵɵsetComponentScope` from an `NgModule` file, which does not re-run during HMR
of the component file.

Standalone components never use `ɵɵsetComponentScope` because their imports are
inlined directly onto the component definition (in `ngtsc`, `handler.ts` keeps
non-self dependencies during HMR and emits the component self-reference only
while used in the template). Always restoring `clone` left removed standalone
directives active, caused swapped or newly added standalone directives to fail
silently and pipes to throw `NG0302`, and broke recursive self-references.

Use `newDef.directiveDefs` and `newDef.pipeDefs` directly for standalone
components (including `null`), while keeping `clone.directiveDefs` and
`clone.pipeDefs` unconditionally for non-standalone components. Add DOM-level
acceptance specs in `hmr_spec.ts`.
2026-11-20 07:42:47 -08:00
Matthieu Riegler 88a931b968 fix(compiler): length-prefix string literals and quoted map keys in ConstantPool keys
Previously, GenericKeyFn.keyOf() wrapped string literals and quoted object literal keys in double quotes without length-prefixing or escaping. As a result, distinct array or object literals extracted during the template compiler's pure function optimization phase (such as ['a', 'b'] and ['a","b'], or {'a': 1, 'b': 2} and {'a":1,"b': 2}) produced identical constant pool keys and erroneously shared the same constant factory.

Prefix string literals and quoted object literal keys with their length ("<length>:<value>") in GenericKeyFn.keyOf() so embedded quotes and delimiters cannot cause key collisions without needing to scan or escape the string.

Fixes #71914
2026-11-19 16:39:37 -08:00
arturovt fee6dbf526 fix(core): throw coded error when @for collection is not iterable
Consider the following example:

```ts
@Component({
  template: '@for (item of items; track item) {{{ item }}}',
})
class App {
  items = {0: 'a', 1: 'b'};
}
```

Prior to this commit, `reconcile()` treated every non-nullish value that is
not an array as an iterable and called `Symbol.iterator` on it without a
check. A plain object therefore failed with a raw `TypeError`:

```
TypeError: t[Symbol.iterator] is not a function
```

That error carries no code, does not mention `@for`, and does not say which
template produced it. In a production build the stack is minified, so error
reporting shows nothing actionable. The same value through `*ngFor` reports
NG02200, which names the problem and suggests the keyvalue pipe, so `@for`
was harder to debug than the API it replaces.

With this commit the same value throws NG0957. Only the message text is
behind `ngDevMode`; the check itself is not, because production is where the
raw error is unreadable today. The array fast path is untouched, and `null`
and `undefined` keep rendering nothing.

The code is negative, which is how this package marks codes that have a
guide on angular.dev, so the fix ships with one.
2026-11-19 15:39:55 -08:00
phr4nky ca92b968b8 fix(core): use the custom Sanitizer for URLs in i18n attributes
Translated attributes with interpolations in a URL context (e.g.
`<a i18n-href href="{{url}}">` or an `href` inside an ICU case) were
sanitized with the raw `_sanitizeUrl` function, which ignores a
`Sanitizer` provided by the application. All other security contexts
already go through the `ɵɵsanitize*` instructions, as does the
compile-time path for static i18n attributes.

Use `ɵɵsanitizeUrl` for the URL context as well, so a custom
`Sanitizer` is consulted consistently.
2026-11-16 16:52:32 -08:00
SkyZeroZx ece1a15640 test(core): use a hydrate trigger in the hydration bundling example
The example now has a `@defer` block with a hydrate trigger so its golden reflects what a real hydration app ships.
2026-11-12 08:52:35 -08:00
Angular Robot 5aaebc2e7f build: update cross-repo angular dependencies
See associated pull request for more information.
2026-11-12 08:49:42 -08:00
rkandleonsenft f9cf82642c fix(forms): apply validator directives to custom form controls
Custom control (`value` or `checked` model, no ControlValueAccessor) bound with NgModel,
FormControlDirective or FormControlName is set up by setupCustomControl, which doesnt call
setUpValidators. Validator directives on element (required, minlength, any directive providing
NG_VALIDATORS) and NG_VALIDATORS provided by control itself never reach FormControl, so control
stays valid and form submits. ControlValueAccessor path merges them, and cleanUpControl already
removes them when FormControlDirective or FormControlName lets go of control

Call setUpValidators from setupCustomControl. Applying validators needs few more changes:

- FormControlName: ɵngControlUpdate runs before ngOnChanges of element, so setting control up
  there would run control's own NG_VALIDATORS before its ngOnInit, and first ngOnChanges of each
  validator directive would emit valueChanges and statusChanges during first change detection.
  ɵngControlUpdate now only resolves control and ngOnChanges sets it up, same as for
  ControlValueAccessor
- required: with FormControlDirective and FormControlName, NgControl also wrote `required` into
  RequiredValidator on same element. That cleared static `required`, and Validators.required
  turned into directive validator that outlived removeValidators(). setInputOnDirectives now
  passes directive to writePredicate and NgControl skips RequiredValidator. Custom control gets
  `required` from enabled RequiredValidator or Validators.required under all three directives
- errors: status inputs are read through untracked getters and `errors` was plain field, so
  re-validation later in same pass (validator directive's ngOnChanges) left `invalid` and `errors`
  stale, and markForCheck during that refresh doesnt re-run view. `errors` is backed by signal now
  like `status`, and ngControlUpdate reads both, so errors-only change is bound in same pass, with
  `emitEvent: false` too
- _enabled on validator directives is backed by signal too, so change from their ngOnChanges
  reaches custom control in same change detection

Fixes #70721

Co-authored-by: leonsenft <[email protected]>
2026-11-11 14:59:21 -08:00
Shuaib Hasan Akib f499ad0c7c refactor: remove redundant standalone: true from tests
Standalone is the default, so the explicit flag is redundant. Remove the
occurrences added to core, platform-browser, forms and router tests since
the last cleanup.
2026-11-11 12:38:00 -08:00
hawkgs 5a802b5e0f test(forms): replace @mcp-b/webmcp-polyfill with ModelContextMock
Reuse the `ModelContextMock` for the forms tests.
The mock is moved to `packages/private/testing`.
2026-11-11 11:12:58 -08:00
hawkgs d398ea1593 test(core): replace @mcp-b/webmcp-polyfill with a local mock
`@mcp-b/webmcp-polyfill` is deprecated in favor of `@w3c/webmcp-polyfill`.
However, the latter doesn't include any testing utilities, just an install
API without a convenient way to reset the polyfill.

This change drops `@mcp-b/webmcp-polyfill` in favor of a lean `ModelContext`
mock used for the purposes of the `webmcp` tests.
2026-11-11 11:12:58 -08:00
Matthieu Riegler 5f51154197 fix(core): resolve closure and reference retention leaks
Resolves several V8 closure-context and reference retention issues
across `@angular/core`, including isolating closure scopes in
`injectAsync`, `ɵɵboundaryUpdate`, and incremental hydration triggers,
skipping non-`jsaction` elements in event replay stashing, clearing
recovered signal error references, and avoiding retaining the document
reference in `InertDocumentHelper`.
2026-11-11 11:12:18 -08:00
Alex Rickabaugh ae9c706d14 refactor(compiler): remove selectorless prototype
Removes the experimental "selectorless" template syntax (`<MyComp>` / `@Dir(...)`)
which was never shipped. This deletes:

- compiler: lexer/parser support for component and directive tokens, the
  html `Component`/`Directive` nodes and the R3 `Component`/`Directive`
  (`TmplAstComponent`/`TmplAstDirective`) nodes together with their visitor
  methods and the `directives` field on elements/templates, the
  `selectorlessEnabled`/`enableSelectorless` parse options, direct pipe
  references (`BindingPipeType`), selectorless reference validation, the
  selectorless paths in the binder (`referencedDirectiveExists`),
  type-check ops, indexer, i18n and template pipeline.
- compiler-cli: the `_enableSelectorless` option, selectorless component
  analysis and `SelectorlessScope`, deferred selectorless dependencies,
  selectorless template symbols, out-of-band diagnostics and the related
  error codes (2024, 2025, 2026, 8018), the linker option, and the
  preprocessor/ng-analyze selectorless analysis.
- language-service: selectorless definitions, quick info, references and
  rename.
- the selectorless runtime and compiler tests.

`SelectorlessMatcher` is kept since it is used to match foreign components
(`foreignImports`) by tag name.
2026-11-11 09:10:56 -08:00
Pawel Kozlowski a3bc172846 refactor(core): don't store testing metadata for attribute bindings
Exploratory change to check usage patterns.
2026-11-11 08:54:19 -08:00
Zhiqi Zhang efbab16e56 fix(core): cancel obsolete resource loads when params become unavailable
Cancel previous loads before returning for unavailable or errored resource
params. These transitions otherwise leave the old AbortSignal active and
keep its pending task blocking application stability.

Preserve pending-task ownership when cancelled promises settle after a new
request starts. Cover unavailable params, propagated statuses and errors,
and late resolution or rejection in regression tests.
2026-11-10 16:56:58 -08:00
aparziale 088cdd2cab fix(core): allow binding null and undefined to resource URL properties
Binding `null` or `undefined` to a resource URL property such as
`<iframe [src]>` throws NG0904 ("unsafe value used in a resource URL
context"), even though there is nothing unsafe about clearing the binding.
The inlined `ɵɵsanitizeResourceUrl` only accepts values marked trusted with
`bypassSecurityTrustResourceUrl` and rejects everything else, including
nullish values. This forces users to bind a trusted placeholder such as
`about:blank` instead of simply using `undefined`.

The same binding already works when a custom `Sanitizer` is provided,
because `DomSanitizer.sanitize` returns `null` for nullish values, which is
then mapped to an empty string. Apply the same handling to the inlined
sanitizer: `null` and `undefined` are mapped to an empty string, which the
browser treats as `about:blank` for `<iframe src>`. Since
`setElementAttribute` runs the sanitizer before removing an attribute for a
nullish value, this also fixes `[attr.src]` bindings on resource URL
attributes.

Fixes #42527
2026-11-10 15:59:28 -08:00
SkyZeroZx 4854f68e39 perf(core): tree-shake JIT dependencies from AOT module bootstrap
Keep the JIT implementation in an explicit conditional branch so AOT builds can discard its transitive dependencies before bundling.
2026-11-10 14:30:28 -08:00
Matthieu Riegler 262417f155 feat(router): introduce route error boundaries and redirect handling
Introduces error boundary support in the Angular Router, allowing individual routes to declare an `errorComponent` and applications to configure global fallback defaults via `withErrorBoundaries`.
2026-11-10 13:20:49 -08:00
Jessica Janiuk c476164c6c fix(core): http golden symbols updated again
Yet again symbols were broken.
2026-11-10 11:38:47 -08:00
aparziale 3296939422 fix(core): improve error message for unparsable ICU expressions in translations
Previously, when a translation contained an ICU expression that could not be
parsed at runtime, the error was a plain `Unable to parse ICU expression in
"..." message.` without explaining the most common causes or carrying an
error code.

The error is now a `RuntimeError` with the dedicated code NG0702
(`UNPARSABLE_ICU_EXPRESSION`). The message explains that the translation must
contain a valid ICU expression and that ICU expressions can only be used in a
translation when the original message contains one as well. The detailed
message is guarded by `ngDevMode`, so it is tree-shaken away from production
bundles where only the error code remains, while the error itself is still
thrown in production because translations vary by locale and may not be
exercised during development.

Additionally, the `$localize` docs now call out that ICU expressions are not
supported by the tagged-string API.

Fixes #48217
2026-11-10 11:12:35 -08:00
Matthieu Riegler 833c1f2c96 perf(core): avoid unnecessary aborts and reuse abort reason during resource teardown
When tearing down component trees containing resources, `abortInProgressLoad` previously invoked `pendingController.abort()` without arguments for every resource.

This caused two performance issues:
1. Omitting the reason parameter in `abort()` instantiates a new `DOMException` ('AbortError') each time. In engines like V8, this triggers a full call stack capture (`CaptureStackTrace()`), whose cost scales linearly with call stack depth. On deep component tree teardown, this can take up to 20-40ms.
2. `ResourceImpl` retained its `pendingController` even after a non-streaming load had completed, unnecessarily executing `abort()` for operations that were no longer in flight.

This change:
- Reuses a shared `AbortError` `DOMException` reason when aborting loads, preventing repeated V8 stack captures while maintaining full compatibility with consumers expecting a standard `DOMException`.
- Clears `pendingController` upon completion for non-streaming resources, avoiding unnecessary abort work when tearing down already settled resources. Streaming resources (such as `rxResource`) continue to receive abort signals on destroy to clean up active subscriptions.

Fixes #71422
2026-11-10 11:10:51 -08:00
Angular Robot 24622b7a87 build: update cross-repo angular dependencies
See associated pull request for more information.
2026-11-10 10:56:36 -08:00
Jessica Janiuk e25a22841a fix(core): update golden symbols
Another issue of golden symbols being out of date post PR merge.
2026-11-10 10:08:48 -08:00
Matthieu Riegler 225d600314 fix(compiler): disallow attribute and property names starting with a colon
Previously, binding to an attribute starting with a colon (such as
`[attr.:onclick]` or `[attr.:href]`) resulted in the leading colon being
stripped by `mergeNsAndName` only after attribute validation and security
context resolution had already taken place. This allowed `[attr.:onclick]`
to bypass event attribute validation, producing an `onclick` attribute binding.

Because attribute and property names starting with a colon are invalid syntax
in HTML/XML and Angular templates, this change rejects any attribute or property
binding whose name starts with a colon immediately during validation.

In addition, namespaced event attributes (such as `[attr.svg:onclick]`) are now
properly disallowed by inspecting the local name across element schemas and host
bindings.
2026-11-10 09:42:00 -08:00
SkyZeroZx b178c11301 perf(core): release intermediate inert trees while sanitizing HTML
The mXSS check in `_sanitizeHtml` parses the input again after each serialization, but the previous inert tree stayed referenced until the next parse returned, and only the last tree was cleared at the end. For HTML that the parser expands, such as formatting elements that are reconstructed for every paragraph, two full trees were alive at once.
So, clear the serialized tree before parsing again, so only one inert tree is live at a time. The sanitized output doesn't change.

Fixes #70873
2026-11-10 09:36:17 -08:00
Jessica Janiuk 11c32ff559 fix(forms): forms signals goldens update
This updates the forms symbols to get CI back to green.
2026-11-09 17:47:42 -08:00
Matthieu Riegler 4422f4ef50 perf(forms): avoid retaining AbstractControl in signal forms
Previously, `FieldNodeContext.valueOf` used `result instanceof AbstractControl` to throw `NG1907` when reading an `AbstractControl` inside a regular `form()`. That value reference prevented `AbstractControl` (along with control event classes and validator helpers) from being tree-shaken in applications that only use signal forms.

Introduce an internal symbol-based type guard `ɵisAbstractControl` that checks a private symbol set in `AbstractControl`'s constructor without referencing the `AbstractControl` class value.

Fixes #71621
2026-11-09 16:55:19 -08:00
Matthieu Riegler 93b89ccc5f test(forms): add bundling symbol test for signal forms
Add a bundling symbol test and baseline golden file for signal forms applications.
2026-11-09 16:55:19 -08:00
SkyZeroZx b7cf38695f perf(http): tree-shake unused transfer cache from httpResource
Provide cache lookup through the existing private transfer-cache options so httpResource clients without transfer caching do not retain cache restoration and hashing.

Preserve the optional dependency lookups, their timing, and synchronous hydration behavior. Update the http bundle golden to show the removal of the cache-related symbols.
2026-11-09 16:51:36 -08:00