6707 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
Alex Morris d201dd76ef fix(core): do not drop nested @defer child blocks while parent hydrates
In `getParentBlockHydrationQueue`, PR #58722 breaks out of the ancestor loop
before calling `hydrationQueue.unshift(currentBlockId)` when it encounters an
ancestor `@defer` block that is already hydrating. Because of that,
`hydrationQueue` never contains the hydrating ancestor, only the unhydrated
descendants below it.

`triggerHydrationFromBlockName` still contains a `hydrationQueue.shift()` added
in PR #60203 under the assumption that the hydrating parent sat at index 0.
When `parentBlockPromise` is non-null, that shifts off the first unhydrated
child block instead: in a 2-level nested `@defer` block it empties the queue
and drops the replay event, and in a 3-level hierarchy (immediate inside
interaction inside immediate) it drops the middle block so both inner blocks
stay dehydrated.

Remove the stale `hydrationQueue.shift()` call and add regression specs in
`incremental_hydration_spec.ts`.
2026-11-20 05:20:30 -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
Angular Robot 3ef4cb5d43 build: update all non-major dependencies
See associated pull request for more information.
2026-11-19 09:37:07 -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
Andrew Scott 9399d67252 refactor(core): quote InputMap constraint keys on directive declarations
`getInputsTypeExpression` in `@angular/compiler` emits `'alias'`, `'required'`, and `'isSignal'` as quoted string-literal property signatures in the `InputMap` type argument of `ɵɵDirectiveDeclaration` and `ɵɵComponentDeclaration` on `ɵdir` and `ɵcmp`. However, `ɵɵDirectiveDeclaration` and `ɵɵComponentDeclaration` in `@angular/core` declared those constraint keys as unquoted identifier property signatures (`{alias: string | null; required: boolean; isSignal?: boolean}`).

In standard TypeScript, quoted and unquoted property signatures are structurally identical. When a property-renaming safety pass rewrites unquoted identifier property signatures in `.d.ts` type literals while preserving quoted string-literal keys, the renamed constraint keys on `InputMap` no longer match the quoted `'alias'`, `'required'`, and `'isSignal'` keys emitted on preprocessed `ɵdir` and `ɵcmp` source declarations, failing `TS2344`.

Quote `'alias'`, `'required'`, and `'isSignal'` in the `InputMap` constraint on `ɵɵDirectiveDeclaration` and `ɵɵComponentDeclaration` so the declaration constraints match the quoted keys emitted by `@angular/compiler`.
2026-11-16 14:44:46 -08:00
arturovt 2a450cbfaa fix(core): throw NG0512 instead of TypeError when hydration text node is missing
Given this template:

```html
<main>
  <span>{{ value }}</span>
</main>
```

During hydration, Angular looks for the text node that the server rendered
inside the `<span>`. If the HTML from the server was changed and this text
node is missing, dev mode throws a clear NG0500 error. But this check only
runs in dev mode.

Prior to this fix, production continued with the missing text node and failed
on the first update of that binding with a raw error that doesn't say what
went wrong:

```
TypeError: Cannot set properties of null (setting 'nodeValue')
```

With this fix, production throws NG0512 during hydration instead.

Note that static text behaves differently. Nothing ever updates it, so it
hydrated without an error before this fix and left a gap in the DOM. It now
throws as well.
2026-11-16 14:12:24 -08:00
arturovt 551c446d98 fix(core): throw NG0502 instead of a TypeError when a hydration comment is missing
Consider the following template:

```html
<main>
  @if (show) {
    <span>text</span>
  }
</main>
```

During hydration, Angular looks for the comment node that marks where the
`@if` block (or an `<ng-container>`) is. If the HTML from the server was
changed and this comment is missing, dev mode throws a clear NG0502 error.
But this check only runs in dev mode.

Prior to this fix, production continued with the missing comment and failed
later with a raw error that doesn't say what went wrong:

```
TypeError: Cannot set properties of null (setting '__ngContext__')
```

With this fix, production also throws NG0502.
2026-11-12 09:25:51 -08:00
Matthieu Riegler 0ce6110471 fix(core): suppress hydration warnings in test environments
When running component tests in TestBed, an application may include
provideClientHydration() (e.g. from appConfig.providers) or use
defer blocks with hydrate triggers without hydration providers configured.

In these testing scenarios, there is no serialized server state in
TransferState. As a result, Angular emitted spurious warnings:
- NG0505: warning that client hydration was requested but no serialized info was found.
- NG0508: warning that incremental hydration is not enabled for @defer hydrate triggers.

This commit introduces an internal IS_TESTING token, provided by TestBedCompiler
and BrowserTestingModule, which suppresses these warnings in test environments.

Fixes #62053
2026-11-12 09:03:36 -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
Kristiyan Kostadinov 9df39f4df2 fix(core): guard ngServerMode in validAppIdInitializer
This came up while updating Components to the 22.3 release candidate. We were reading `ngServerMode` directly which caused a reference error in some of our tests, because we weren't defining it globally. These changes guard `ngServerMode` and `ngDevMode` just in case.
2026-11-12 08:32:39 -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 98b0f3b720 refactor(core): remove signal components prototype
Removes the unfinished prototype for signal-based components and directives
(the internal `signals: true` decorator flag):

* `@Directive`/`@Component` no longer accept the internal `signals` option.
* The compiler no longer reads it (ngtsc, JIT, linker, hybrid preprocessor)
  and no longer emits `signals: true` in definitions, `isSignal: true` in
  partial declarations, or the trailing `IsSignal` type argument of
  `ɵɵDirectiveDeclaration`/`ɵɵComponentDeclaration`.
* The runtime drops `DirectiveDef.signals`/`ComponentDef.signals`,
  `LViewFlags.SignalView` and the internal `ComponentMirror.isSignal`.

Signal inputs, model inputs and signal queries (input/query-level `isSignal`)
are unaffected.
2026-11-11 09:10:56 -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
Pawel Kozlowski c9a199bd65 refactor(core): move set attribute code to a DOM-dedicated place
Moves the code responsible for setting an attribute value out of the
instructions folder into the dedicated DOM-manipulation logic file.
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
Matthieu Riegler af620ea3d9 fix(core): guard hydrating map access and release pending task on error
`triggerHydrationForBlockQueue` accessed `blocksBeingHydrated.get(dehydratedBlockId)` with a non-null assertion `!.resolve()`. If the entry was cleaned up while the function was suspended awaiting resource loading or next render, this resulted in an unhandled `TypeError: Cannot read properties of undefined (reading 'resolve')`.

Additionally, the pending task added by `pendingTasks.add()` was not guarded by a `try/finally`, causing the task to leak and permanently breaking application stability whenever hydration encountered an error or threw an exception.

This commit optional-chains `.resolve()` matching sibling accesses and wraps the queue processing loop in `try/finally` so `pendingTasks.remove(taskId)` is always invoked.

Fixes #71769
2026-11-10 12:31:01 -08:00
Matthieu Riegler 9fcdf0b80b refactor(core): validate the APP_ID value on the server
This hardening ensures the APP_ID that ends up in the event replay script can't be used as an attack vector.
2026-11-10 12:30:34 -08:00