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
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.
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`.
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
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.
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.
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]>
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.
`@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.
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`.
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.
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.
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
Introduces error boundary support in the Angular Router, allowing individual routes to declare an `errorComponent` and applications to configure global fallback defaults via `withErrorBoundaries`.
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
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
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.
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
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
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.