6435 Commits

Author SHA1 Message Date
Matthieu Riegler 1167626e5b refactor(core): Migrate more tests off fakeAsync
This will prevent to polute the agent context with outdated/bad practices.

(cherry picked from commit c1025a0510)
2026-07-29 08:46:06 -07:00
SkyZeroZx b4b4a64c67 fix(core): account for namespaces in host binding sanitization (#69558)
Make runtime URL sanitizer selection namespace-aware so SVG and MathML host bindings match the security schema.

Cover SVG href/xlink:href and MathML href host binding cases, including dynamic hostElement resolution.

PR Close #69558
2026-07-29 08:36:33 -07:00
SkyZeroZx 2df018fe25 fix(core): sanitize host bindings on concrete hosts (#69558)
Host binding sanitization previously used the declaring directive or component selector to choose a compile-time security context. The same host binding can execute on a different concrete element through hostDirectives, inherited host bindings, dynamic directives, or createComponent hostElement usage.

Compute host binding security contexts against possible concrete hosts and defer URL versus ResourceURL selection to runtime when necessary. Resolve dynamic root host TNodes to their native tag before sanitizer and security-sensitive attribute checks.

Fixes angular#69550

PR Close #69558
2026-07-29 08:36:33 -07:00
Suraj Yadav d3469056cb fix(migrations): correctly detect then/else keywords in control flow migration
The control flow migration determines whether an `*ngIf` uses a `then`
and/or `else` clause by regex matching the raw microsyntax string for
the literal keywords `then`/`else`. The regexes only checked that the
keyword was preceded by a non-word character, but not that it was
followed by one.

As a result, a template reference name that merely starts with `then`
(e.g. `else thenBlock`) or `else` was misidentified as the `then`/`else`
keyword itself. This caused the migration to take the wrong code path
(e.g. then+else instead of else-only), which in turn made
`getTemplateName()` compute a `slice(start, end)` with `start > end`,
producing an empty template name. That empty placeholder was never
resolved and was silently emitted as an invalid
`<ng-template [ngTemplateOutlet]=""></ng-template>`, dropping the
original template content without any warning.

Add a negative lookahead `(?![\w\d])` to both regexes so `then`/`else`
are only matched as whole keywords, not as a prefix of a longer
template reference name.

Fixes #69914

(cherry picked from commit 5ad8231397)
2026-07-24 13:56:23 -07:00
Suraj Yadav 388daea2fc fix(migrations): correctly migrate ngClass with mixed space-separated keys
Preserve NgClass import on partial migration and increment
skippedNgClassCount when an unmigrable mixed binding is encountered.

(cherry picked from commit 49672c437b)
2026-07-21 19:20:25 +02:00
Alan Agius 8616ba9db6 fix(core): ensure SVG animation attributeName is checked case-insensitively
Currently, the SVG sanitizer checks a static set of candidate attribute
names (`attributeName` and `attributename`). This approach misses other case
variations (such as `attributenAme` or others), which could potentially
bypass sanitization when binding sensitive attributes like `href` on
`<set>` or `<animate>` elements.

This change retrieves all attribute names of the SVG element, performs a
case-insensitive comparison with `'attributename'`, and sanitizes the value
if a match is found.

(cherry picked from commit 3499a1321b)
2026-07-21 11:05:07 +02:00
Suraj Yadav bb39cda648 fix(migrations): preserve NgClass import on partial migration
When only some NgClass usages are migrated (partial migration),
the NgClass import should be preserved in the module/component
imports if it is still used elsewhere.

(cherry picked from commit 223e40279f)
2026-07-20 18:14:42 +02:00
Angular Robot 829d98e9ae build: update cross-repo angular dependencies to v22.0.7
See associated pull request for more information.
2026-07-15 14:49:17 -07:00
cexbrayat 70500e4067 fix(core): preserve explicit input transform write type
If a directive has an input declared as `dismissible = input<boolean>(true, {transform: booleanAttribute});` then the following templates were not compiling:

```
<div directiveName dismissible="true"></div>
<div directiveName dismissible></div>
```

This commit fixes the issue, without breaking contravariant consumers.

(cherry picked from commit 0ae6d81ed2)
2026-07-15 12:02:23 -07:00
Cameron Smick e881b962cc refactor(core): move signal debug graph interfaces to primitives/devtools
Move the DebugSignalGraph, DebugSignalGraphEdge, and DebugSignalGraphNode interfaces from packages/core/src/render3/util/signal_debug.ts into the packages/core/primitives/devtools/src package. This decouples the signal graph debug types from runtime render3 utilities and allows devtools and internal core tooling to import them directly from primitives as type-only exports.

(cherry picked from commit d997a96b47)
2026-07-14 11:09:27 -07:00
Doug Parker 1046fd9e56 refactor(core): remove deprecated unregisterTool from ModelContext
In the WebMCP specification, tools are unregistered by aborting the `AbortSignal` provided in `registerTool(tool, {signal})`. The deprecated `unregisterTool` method on `ModelContext` is no longer needed or part of the standard, and is now removed from the TypeScript interface definition.

(cherry picked from commit ce4f7adc95)
2026-07-10 10:56:45 -07:00
Doug Parker 5936ffb80c refactor(core): update WebMCP tool registration to be asynchronous
In the latest WebMCP specification and Chromium preview builds, `document.modelContext.registerTool` was updated to be asynchronous and return a `Promise`: https://groups.google.com/a/chromium.org/g/chrome-ai-dev-preview/c/xQWt0b1sZIE/m/UJznbNCIAwAJ?utm_medium=email&utm_source=footer

This commit update adjusts Angular's experimental WebMCP implementation (`declareExperimentalWebMcpTool` and form registration) to be async as well, returning `Promise<void>`.

(cherry picked from commit f908140d71)
2026-07-10 10:56:45 -07:00
Matthew Beck c82ae67e3d Revert "fix(core): allow static attributes for explicit input transforms"
This reverts commit 9b9b0e93c9.

This broke g3. Not sure yet why it didn't break externally. We can
investigate and fix following this revert.

(cherry picked from commit 1fb4678207)
2026-07-09 17:58:26 -07:00
Angular Robot ec9b4793e8 build: update cross-repo angular dependencies
See associated pull request for more information.

Closes #69411 as a pr takeover
2026-07-09 16:05:25 -07:00
cexbrayat 94d9591b51 fix(core): allow static attributes for explicit input transforms
This is a follow-up to #67997, which allowed explicit read generics with input transforms, such as `input<boolean>(false, {transform: booleanAttribute})`.

That fixed the declaration, but static template attributes like `dismissible="true"` and bare `dismissible` were still checked as strings against the read type. Allow the fallback write type to include static attribute strings so these template forms compile.

(cherry picked from commit 9b9b0e93c9)
2026-07-09 12:28:29 -07:00
Matthieu Riegler 1b9964675f fix(forms): allow multiple async validators
When a parent form element defines an async validator, its resource's `params` function needs to evaluate `syncValid()`, which causes unvisited child form nodes to be lazily instantiated. If any of these lazily instantiated child nodes also define an async validator, their resource is initialized while the parent's `params` function is still evaluating. This incorrectly triggers Angular core's `NG0992` guard (`Cannot create a resource inside the params of another resource`).
This commit exports `ɵsetInParamsFunction` and `ɵisInParamsFunction` from `@angular/core` and uses them in `FieldMetadataState.runMetadataCreateLifecycle` to explicitly detach the lazy creation of form metadata from the parent's reactive `params` context.

fixes #69620

(cherry picked from commit 5cb8c733a3)
2026-07-09 09:55:33 -07:00
SkyZeroZx 748faa4f95 docs(docs-infra): Add build-time validation for API and guide links using route manifest
Adds build-time validation to catch broken, stale, or miscased internal documentation links in both JSDoc and markdown, including `/api/` and `/guide/` URLs and their fragments. Updates the documentation pipeline to share the canonical route manifest, ensuring that all references are checked against the current navigation structure.

(cherry picked from commit c1829f6d7c)
2026-07-08 10:24:51 -07:00
Cameron Smick c91a951817 refactor(core): move devtools ai tool definition types to primitives
Extract the AI tool definition interfaces from the core debug module to the devtools primitives module. This relocates ToolDefinition, ToolGroup, and DevtoolsToolDiscoveryEvent to the primitives folder, exposing them cleanly via "export type" in the devtools entry point, improving module organization and readability.

(cherry picked from commit bf6dba878e)
2026-07-07 10:18:10 -07:00
cexbrayat d4a926a762 fix(migrations): remove stale model import in model-output migration
Remove the model import after migrating all model() usages in a file.

(cherry picked from commit fbb705e6fd)
2026-07-07 10:08:48 -07:00
SkyZeroZx 0a6af1496b fix(migrations): preserve transitive NgModule references when pruning
avoids unintended removal of indirectly required modules

Fixes #62865

(cherry picked from commit 0a5a2b768c)
2026-07-07 10:01:17 -07:00
Shuaib Hasan Akib 45caa92e2a refactor(core): remove unused utility functions
Remove `isIterable` from `util/iterable.ts` and
`newTrustedFunctionForDev` from `util/security/trusted_types.ts`
as they are no longer referenced anywhere in the codebase.

(cherry picked from commit 01bb0a2f28)
2026-07-07 09:48:11 -07:00
Matthieu Riegler f03639cfd4 docs: correct docs about the chain behavior.
Even if the chained resource has a value, it might throw an error.

fixes #69330

(cherry picked from commit 5ad937be5e)
2026-07-06 13:37:27 -07:00
SkyZeroZx ced0180b06 fix(core): reject dynamic script host elements
The previous fix for GHSA-692r-grfm-v8x7 was incomplete because it rejected script tags only when locating an explicit host element. Dynamic component instantiation can also infer the host element from the component selector.

Move the script-host rejection to the point where ComponentFactory has resolved the host element for either path, so createComponent rejects script hosts consistently.

(cherry picked from commit d7f70616a0)
2026-06-30 17:29:41 -07:00
Andrew Scott c3be83cfe1 refactor(core): allow AnimationClassBindingFn to return undefined or null
The AnimationClassBindingFn type was too restrictive, only allowing `string | string[]`. However, the runtime (`getClassListFromValue`) safely handles `undefined` and `null` values by treating them as no animation.

This change updates the type to allow `undefined` and `null`, which is consistent with other class/style bindings in Angular and avoids requiring workarounds (like empty strings) in host bindings.

Added a compliance test case to verify that `[animate.enter]` with a potentially `undefined` value compiles correctly.

(cherry picked from commit a7bde662c3)
2026-06-30 17:28:04 -07:00
tmpln e598dc843f fix(core): improve input writes migration in best effort mode
Currently, signal migration schematics in best effort mode doesn't do a very good job migrating input writes when there is a nested property access in templates.

In event handlers, no attempt is made to migrate a nested access in the left-hand-side of assignments or anything in their right-hand-side. E.g., nothing will happen here:

`(ngModelChange)="inputD.prop = $event + inputF"`.

Additionally, when a migration attempt is made, parentheses are often incorrectly placed on the parent, both in event handlers and two-way bindings:

`(ngModelChange)="inputC = $event"` is migrated to `(ngModelChange)="inputC = $event()"`.

`[(ngModel)]="inputB.prop.prop"` is migrated to `[(ngModel)]="inputB.prop().prop"`.

(cherry picked from commit 74638cab84)
2026-06-26 10:31:01 -07:00
aparziale fd37f09f37 fix(migrations): resolve migration failure when tsconfig specifies rootDir
When `rootDir` was set in a project's tsconfig (e.g. `rootDir: "src"`),
tsurge-based migrations would fail because `projectRoot` was derived from
`rootDir`, causing `rootRelativePath` to be computed relative to `src/`
instead of the workspace root. This produced paths like `app/app.ts`
instead of `src/app/app.ts`, which the DevKit tree could not resolve.

Fix by overriding `info.projectRoot` to `absoluteFrom(info.program.getCurrentDirectory())`
immediately after program creation, ensuring workspace-relative paths are
used for all tree updates.

(cherry picked from commit 26b0c719ef)
2026-06-26 09:14:52 -07:00
JoostK f90c20df40 fix(compiler): account for NgModule dependencies in JIT-compiled partial declarations
When partial declarations are not preprocessed to AOT by the linker, the `ngDeclareComponent`
call causes them to be compiled ad-hoc. In this mode, NgModule imports in standalone components
would be dropped, deviating from the linker. This commit changes the ad-hoc compilation of
component declarations to pass the NgModule imports along just like the linker does.

Fixes #69451

(cherry picked from commit ecd047578e)
2026-06-24 14:46:48 -04:00
Matthieu Riegler 01d58d7ad7 refactor(core): Tree shake the SimpleChanges & co.
Any application that doesn't use the `ngOnChanges` hook shouldn't pull its code.

(cherry picked from commit 4744bab38e)
2026-06-24 13:04:40 -04:00
Saurabh Singh 03d1a6444a docs(core): document resource chaining with chain() in params context
Adds a 'Chaining resources' section to the resource guide covering:
- Basic usage of chain() to depend one resource on another
- Status propagation for all ResourceStatus values (idle, loading,
  reloading, error, resolved, local)
- Chaining vs reading .value() directly, shown as an avoid example
- Guidance on passing the chained value directly as params

Also adds an @see link from ResourceParamsContext to the new section.

Closes #69329

(cherry picked from commit 7057b1257f)
2026-06-24 11:23:53 -04:00
Kristiyan Kostadinov 2799304259 fix(core): avoid uncaught promise errors in injectAsync prefetching
Fixes a minor issue where the `preload` function in `injectAsync` might cause an uncaught promise error.

I also fixed that in `onIdle` we were passing the wrong function into `assertInInjectionContext`.

(cherry picked from commit 91d168e74b)
2026-06-23 12:57:30 -04:00
Jessica Janiuk 3e7c83b0a3 Revert "fix(core): escape overlapping comment delimiters in escapeCommentText"
This reverts commit ea1a3ed64c.

(cherry picked from commit a849b6fbfd)
2026-06-18 12:34:29 -04:00
Cameron Smick 152601ed94 refactor(core): add childSignalProp to ReactiveNodeKind
Add `childSignalProp` to `ReactiveNodeKind` in order to consolidate `ReactiveNodeKind` types and enable Client-Only Wiz to use it.

(cherry picked from commit ae6d8dae75)
2026-06-17 20:03:17 +00:00
arturovt 59dea13f80 fix(core): guard against DOM clobbering in declareExperimentalWebMcpTool
Previously, the modelContext truthiness check could be bypassed via DOM
clobbering (e.g. `<form id="modelContext">`), causing a truthy HTMLElement
to pass the guard and then throw when `registerTool` was called on it.

Replace the truthiness check with a duck-type check that asserts
`registerTool` is a function, rejecting both absent and clobbered values.

(cherry picked from commit 8cf7731468)
2026-06-17 20:02:14 +00:00
Andrew Scott 81cb4570b2 refactor(router): Add handling for ActivatedRoute-scoped injector
Add handling in navigation for creating and destroying injectors scoped
to `ActivatedRoute` life.
The code for creating the injectors is certainly more complicated
than it _could_ be since there's no actual feature built around this yet.

Keeps as much implementation code tree-shakeable as possible:
Raw size: +764 bytes
Gzipped size: +182 bytes

(cherry picked from commit 1e79dd3140)
2026-06-17 18:39:17 +00:00
Joost Koehoorn f902d1d35e perf(core): detect existing signal dependency without checking all producer links
This commit addresses a scaling issue in the signal dependency graph where
the detection of duplicate dependency links would perform a linear scan across
all consumer links of all producers. The linear scan is replaced with a version
comparison of the dependency edge against the current epoch; if they are
equal the existing dependency edge is known to be valid in this epoch. This means
that the link won't be eligible for removal and therefore doesn't have to be
recreated.

(cherry picked from commit 327744ac17)
2026-06-17 18:38:09 +00:00
rootvector2 e17e8d5422 fix(core): escape overlapping comment delimiters in escapeCommentText
`COMMENT_DISALLOWED` is matched globally, so overlapping delimiter
sequences are skipped: `<!-->` only escapes the leading `<!--` and
leaves a live `-->` that can close a programmatically created comment
node early. Drop the `^` anchors so a standalone `>`/`->` is escaped
wherever it appears, which neutralizes the trailing delimiter left
behind by an earlier match.

(cherry picked from commit ea1a3ed64c)
2026-06-17 18:37:12 +00:00
Angular Robot 0f1cfe3082 build: update cross-repo angular dependencies to v22.0.2
See associated pull request for more information.
2026-06-17 08:05:50 -07:00
SkyZeroZx b32ee7ceb3 fix(core): treat iframe credentialless as security-sensitive
Mark the iframe `credentialless` attribute as security-sensitive so dynamic
bindings are handled consistently with other iframe attributes that affect the
initial navigation, such as `sandbox`, `allow`, `referrerPolicy`, `csp`, and
`fetchPriority`.

Because `credentialless` must be present before the iframe starts loading to
affect the navigation’s credential mode, late dynamic updates can leave the final
DOM looking correct while the initial request was not loaded credentiallessly.

(cherry picked from commit 0152e3cbdf)
2026-06-16 16:05:57 +00:00
Kristiyan Kostadinov 93d0a5f95c fix(core): prevent unsubscribe during emit from throwing off other listeners
Fixes that when a listener unsubscribes from an `output` within its own callback, it was preventing subsequent listeners from running.

These changes fix the issue by not mutating the array while the emit loop is running, but replacing the listener with `null` and coming back later to remove it.

Fixes #69325.

(cherry picked from commit 28cb15a2bb)
2026-06-16 15:29:36 +00:00
SkyZeroZx 528a34f766 fix(core): avoid caching missing locale data
Only cache locale data loaded from the global locale registry when an actual locale entry is found.

This prevents attacker-controlled missing locale identifiers from being retained indefinitely in SSR when locale lookup falls back to a parent locale or the built-in English locale, avoiding unbounded process memory growth in locale-aware pipes and formatters.

(cherry picked from commit 98f42eaaae)
2026-06-15 17:53:12 +00:00
Alan Agius 6f1171991a fix(compiler): restrict possible event handler check to property names longer than 2 characters
Previously, the compiler disallowed translation of any attribute starting with 'on' for security reasons. This incorrectly disallowed translation of the 'on' attribute itself, which is not an event handler.

This commit introduces `isPossibleEventHandler` to verify that the property name has a length greater than 2 in addition to starting with 'on'. This allows attributes like 'on' to be translated while still correctly disallowing actual event handlers like 'onerror', 'onclick', etc.

(cherry picked from commit 417a4071a7)
2026-06-15 16:23:53 +00:00
Andrew Scott 06e9dbf9a5 refactor(core): ɵɵgetInheritedFactory should accept abstract type
An abstract component or directive can extend another class, meaning
ɵɵgetInheritedFactory needs to allow abstract

(cherry picked from commit 2112edefe1)
2026-06-15 16:22:39 +00:00
aparziale 15314c1736 fix(migrations): migration skip any target are not build or test
Fix migration behaviout that skip any target are not build or test

Fixes #66865

(cherry picked from commit 58efd86c78)
2026-06-12 16:24:47 +00:00
Alan Agius 8bb3947e99 refactor: optimize dom security schema lookups
Restructure the security schema map to index by property name instead of tag name, improving lookup efficiency.

(cherry picked from commit 32d7315094)
2026-06-12 16:20:40 +00:00
Andrew Scott 0f68807836 refactor(core): ComponentDef should allow abstract types too
d1539a8513 incorrectly assumed components wouldn't be abstract but
it is still possible (though probably should be an abstract directive instead).

(cherry picked from commit 8984c59626)
2026-06-11 20:08:13 +00:00
Kai Guo 3a48abc15c fix(core): preserve leave animation for sibling instances sharing a TNode
`animate.leave` was skipped — the element was removed from the DOM
synchronously instead of running its leave animation — whenever a
sibling instance of the same template entered in a different DOM parent
during the same change-detection tick (e.g. an exclusive-expansion
accordion or nav where opening section B collapses section A).

`leavingNodes` is keyed by `TNode`, which is shared by every instance of
a template. When a node was inserted, `cancelLeavingNodes` force-removed
any tracked leaving node whose DOM parent differed from the entering
node's parent (the `leavingParent !== newParent` branch added to
de-duplicate a dynamic component re-rendered into a fresh overlay pane).
For two distinct live sibling instances that merely share a `TNode`,
"different parent" is the normal situation, so the still-animating
sibling was ripped out.

Track the declaration view of each leaving element alongside it, and
only perform the cross-parent removal when the entering element belongs
to the same declaration view as the leaving one — i.e. the same logical
view re-rendered, the case the branch was written for. Two distinct
instances of a shared template have different declaration views, so
their `animate.leave` is now left to run to completion.

This preserves the dynamic-component/overlay de-duplication (#67032) and
the drag-and-drop node-move rescue (#67361), which are unchanged.

Fixes #69291

(cherry picked from commit 6b5616b2c7)
2026-06-11 17:39:01 +00:00
SkyZeroZx 6c1f3e9d49 fix(common): skip transfer cache for uncacheable HTTP traffic (#69316)
Do not store HTTP transfer cache entries when either the request or response
uses `Cache-Control: no-store`, `Cache-Control: private`, or
`Cache-Control: no-cache`.

Also skip transfer cache when requests use the Fetch API `cache` option with
`no-store` or `no-cache`.

Because transfer cache serializes SSR HTTP responses into the rendered HTML,
Angular now treats these directives conservatively to avoid exposing sensitive
or explicitly uncacheable data through `TransferState`.

PR Close #69316
2026-06-11 16:58:24 +00:00
Angular Robot cbcf31bfa9 build: update cross-repo angular dependencies
See associated pull request for more information.
2026-06-11 09:25:30 -07:00
Andrew Scott 4b0c3b8b8f refactor(core): Update registerNgModuleType to support codegen typechecking
Updates types and adds test for source->source transformation with tsc downstream

(cherry picked from commit d25d2e1524)
2026-06-10 17:53:00 +00:00
Doug Parker dbf64c8eb5 test(core): fix AI tools test flake
This test flakes occasionally because it is called in production when a platform is created and unregistered when a platform is destroyed. However, not all tests properly clean up their platforms, meaning we can accidentally leak platforms between tests. If this happens, we end up have an event listener created from the production code path and a second event listener from the test. When the test emits the event, both listeners respond and it causes too many responses which fails the test.

Ideally, all tests would clean up the platforms correctly, but this seems difficult to guarantee for all Angular tests and is likely to break over time. The simplest solution is just destroy any leaked platform before the test starts. It's a bit elegant, but the safest option.

(cherry picked from commit 492e3a2a1f)
2026-06-10 17:29:05 +00:00