Commit graph

37410 commits

Author SHA1 Message Date
leonsenft
8d1f58e7a7 refactor(core): implement ɵɵforeignComponent instruction
Implement the `ɵɵforeignComponent` instruction to render foreign components
(components from other frameworks) inside Angular templates. The instruction
creates a host LContainer, instantiates a foreign view, executes the foreign
component's RENDER function, inserts the returned native DOM nodes, and
registers the disposal hook.

Add unit tests to verify element rendering, property passing, dependency
injection, and disposal on destruction.
2026-05-21 16:20:54 -07:00
leonsenft
549231cd56 refactor(core): add dev mode descriptions to foreign view boundaries
Add descriptive text to foreign view head and tail comments in dev mode to
assist in debugging.
2026-05-21 16:16:16 -07:00
leonsenft
d941c13c75 fixup! refactor(compiler): emit instructions for foreign components 2026-05-21 11:47:41 -07:00
leonsenft
14f24253aa fixup! refactor(compiler): emit instructions for foreign components 2026-05-21 11:47:12 -07:00
leonsenft
b26fc24c4a refactor(compiler): emit instructions for foreign components
When a template element matches an imported foreign component, the compiler
omits standard element instructions (`ɵɵelementStart`/`ɵɵelement`) and instead
generates a single `ɵɵforeignComponent` call. The call passes the exact foreign
import wrapper expression defined in `@Component.foreignImports` along with an
aggregated object literal containing all static attributes and property
bindings.

The instruction itself is currently a no-op.
2026-05-20 10:37:00 -07:00
leonsenft
d89b707019 test(core): remove obsolete SVG script sanitization translation test
Some checks are pending
DevInfra / assistant_to_the_branch_manager (push) Waiting to run
CI (push) / lint (push) Waiting to run
CI (push) / devtools (push) Waiting to run
CI (push) / test (push) Waiting to run
CI (push) / integration-tests (push) Waiting to run
CI (push) / adev (push) Waiting to run
CI (push) / vscode-ng-language-service (push) Waiting to run
CI (push) / publish-snapshots (push) Waiting to run
CI (push) / zone-js (push) Waiting to run
CI (push) / adev-deploy (push) Blocked by required conditions
Update ADEV Cross Repo Docs / Update Cross Repo ADEV Docs (push) Waiting to run
Performance Tracking / list (push) Waiting to run
Performance Tracking / workflow (push) Blocked by required conditions
OpenSSF Scorecard / Scorecards analysis (push) Waiting to run
Removes the `should throw error on translated SVG script ResourceURL
attributes` integration test from `security_integration_spec.ts`.

This test is now obsolete because SVG `<script>` elements are stripped during
template compilation (implemented in 90494cd909). As a result, they are no
longer present in the compiled template to trigger runtime sanitization,
causing this test (which expected a sanitization error to be thrown) to fail.
2026-05-19 18:02:43 -07:00
leonsenft
933608c07f fix(core): synchronize core sanitization schema with compiler
https://github.com/angular/angular/pull/68689 recently updated the compiler
schema which should be kept in sync with the core schema. Fix applied by
running `pnpm bazel run //packages/core:dom_security_schema`.
2026-05-19 18:02:43 -07:00
tmpln
048817dfa7 fix(core): visit ICU expressions in signal migration schematics
Some checks are pending
DevInfra / assistant_to_the_branch_manager (push) Waiting to run
CI (push) / lint (push) Waiting to run
CI (push) / devtools (push) Waiting to run
CI (push) / test (push) Waiting to run
CI (push) / integration-tests (push) Waiting to run
CI (push) / adev (push) Waiting to run
CI (push) / vscode-ng-language-service (push) Waiting to run
Update ADEV Cross Repo Docs / Update Cross Repo ADEV Docs (push) Waiting to run
Performance Tracking / list (push) Waiting to run
CI (push) / publish-snapshots (push) Waiting to run
CI (push) / zone-js (push) Waiting to run
CI (push) / adev-deploy (push) Blocked by required conditions
Performance Tracking / workflow (push) Blocked by required conditions
OpenSSF Scorecard / Scorecards analysis (push) Waiting to run
Before this fix ICU expressions were not migrated.
2026-05-19 13:58:08 -07:00
leonsenft
7c60a98b3c fix(compiler-cli): support import aliases in foreignImports (#68674)
Correctly matches and resolves foreign components when imported under an alias
name inside the component file.

PR Close #68674
2026-05-19 13:42:10 -07:00
leonsenft
d596d8bd0a refactor(compiler): support matching and validating foreign components in templates (#68674)
We extract the identifier name from the `foreignImports` expression in
`ComponentDecoratorHandler` and use a `SelectorlessMatcher` to match element
tags against these names. If an element matches both a regular Angular
directive and a foreign component, a conflict error is thrown.

In addition, we implement strict template semantic validation for these matched
foreign components within `TemplateSemanticsChecker`. Elements matched as
foreign components only support static attributes and property bindings. Any
event bindings, template references, or non-property input bindings (e.g.
class, style, or attribute bindings) trigger a semantic error diagnostic.

Finally, we skip standard DOM schema checks for foreign components to prevent spurious
validation errors since foreign components are not defined in standard HTML schemas.

PR Close #68674
2026-05-19 13:42:10 -07:00
aparziale
8ebc900067 docs: update HTTP testing setup guidance
Update testing documentation clarify HttpClient testing providers

Fixed #68792
2026-05-19 13:41:13 -07:00
Angular Robot
b53fa3cdaa build: lock file maintenance
See associated pull request for more information.
2026-05-19 13:22:40 -07:00
g.turri
4e55ceafc9 docs: Fix accepted Provider type in doc snippet
out of the box my IDE tells me there an error on

    const testProviders: Provider[] = [provideHttpClient(), provideHttpClientTesting()];

because `provideHttpClient()` returns an `EnvironmentProviders` so
I can't put it in a variable of type `Provider[]`
2026-05-19 13:19:33 -07:00
june-by
c49661b57b docs(compiler): add typeCheckHostBindings option to angular compiler options 2026-05-19 13:09:25 -07:00
SkyZeroZx
d251c0bf87 docs: Adds lazy service loading for best practice performance 2026-05-19 13:08:53 -07:00
Kam
96ba942a91 refactor(compiler): sync compiler_facade_interface replica with main
The replica at packages/core/src/compiler/compiler_facade_interface.ts drifted from the main copy. The file header specifies syncing via `cp main replica`; running it fixes field-order drift and relocates `legacyOptionalChaining?: boolean;` back onto R3DeclareDirectiveFacade (it was incorrectly on R3DeclareComponentFacade in the replica).
2026-05-19 13:07:05 -07:00
Georgi Serev
116b4cd936
fix(devtools): cluster-to-cluster relationships in signal graph
The PR addresses a missing step in the clustering phase of the signal graph processing on the DevTools frontend. Cluster-to-cluster relationship were missing from the graph, so the change fixes that.
2026-05-19 13:06:37 -07:00
Alan Agius
90494cd909
fix(compiler): strip namespaced SVG script elements during template compilation
Ensures that namespaced <script> elements (such as :svg:script) are correctly classified as PreparsedElementType.SCRIPT by the template preparser and stripped during compilation to prevent potential XSS vulnerabilities. Consequently, obsolete security schema mappings and runtime sanitization checks for <script> attributes have been removed since these elements are never present in compiled template outputs.
2026-05-19 13:06:00 -07:00
Cameron Smick
dbceef6221 refactor(devtools): make the DevToolsNode element property optional
The Angular DevTools Extension doesn't use the `element` property in Client-Only Wiz apps. Once the new `ng.getComponentForest`` function is implemented, Client-Only Wiz could provide `ComponentTreeNode`s without an `element` property. This change supports that case by making the `element` property optional.
2026-05-19 13:04:49 -07:00
Cameron Smick
3c255bccc1 refactor(devtools): Modify buildDirectiveForest to set default values for properties that will not be included in the forest returned by non-Angular frameworks.
Set default values for the `directives`, `element`, `hydration`, and `component.isElement` properties of every `ComponentTreeNode` returned by `ng.getComponentForest` for non-Angular apps.
2026-05-19 13:04:15 -07:00
Cameron Smick
0cf8a61e58 refactor(devtools): add optional injector property to DevToolsNode and IndexedNode types
Add an optional injector property to the DevToolsNode and IndexedNode types. Features that require an injector use the injector stored on the node, if it exists, and fall back to getInjectorFromElementNode if it doesn't.
2026-05-19 13:04:15 -07:00
Cameron Smick
50c0ce8275 refactor(devtools): Modify buildDirectiveForest to call ng.getComponentForest if it exists.
A new ng global function, ng.getComponentForest, is being added to allow the framework to provide the component forest without writing metadata to the DOM. This will allow devtools to display components that don't render any DOM.
2026-05-19 13:04:15 -07:00
arturovt
8ec0d1eee8 fix(router): skip scroll-to-top on initial navigation when hydrating
When scrollPositionRestoration is enabled and the app hydrates an
SSR-rendered page, RouterScroller was unconditionally scrolling the
viewport to [0, 0] on the first imperative navigation. This discards
any scroll position the user established while the server-rendered
page was loading.

Fix by injecting IS_HYDRATION_DOM_REUSE_ENABLED into RouterScroller
and suppressing the scroll-to-top for the initial navigation only.
Subsequent navigations are unaffected.

Closes #64578
2026-05-19 13:01:53 -07:00
Alan Agius
61a97f22e8
fix(core): support prefix-insensitive DOM schema lookups and compile-time i18n attribute validation
Updates `DomElementSchemaRegistry` to strip `:svg:` and `:math:` namespace prefixes
from tag names before querying `SECURITY_SCHEMA` at compile-time. This allows SVG
and MathML attributes to correctly match their security contexts during compilation.
2026-05-19 13:00:32 -07:00
Andrew Scott
ad37f52c12 fix(router): Add strict typing on 'getResolvedTitleForRoute'
The title property in Router type already requires that the return type of a resolved
title is a string. The type was looser here only because 'data' values are typed
as 'any'.

BREAKING CHANGE: The return type for `TitleStrategy.getResolvedTitleForRoute`
was previously 'any' while the actual return type could only be either `string`
or `undefined`. The return type now reflects the possible values correctly.
Code that reads the value may need to be adjusted.
2026-05-19 12:59:13 -07:00
Alan Agius
7390af78b1 test(upgrade): exclude unit test files from E2E application sources
Exclude `**/*.spec.ts` files from the `srcs` glob of the `full_sources` target.

Previously, `module.spec.ts` was compiled as part of the application's main sources because the glob pattern only excluded `**/*_spec.ts` (E2E specs). Consequently, `module.spec.js` was generated and included in the runfiles of the E2E test target, causing the Protractor runner to load and execute it. This failed since the E2E testing runner does not have access to unit testing imports like `@angular/core/testing`.
2026-05-19 12:57:48 -07:00
tmpln
16fe27bfef fix(core): do not insert todo when migrating void @Output
Some checks failed
Performance Tracking / list (push) Has been cancelled
DevInfra / assistant_to_the_branch_manager (push) Has been cancelled
CI (push) / lint (push) Has been cancelled
CI (push) / devtools (push) Has been cancelled
CI (push) / test (push) Has been cancelled
CI (push) / integration-tests (push) Has been cancelled
CI (push) / adev (push) Has been cancelled
CI (push) / vscode-ng-language-service (push) Has been cancelled
CI (push) / publish-snapshots (push) Has been cancelled
CI (push) / zone-js (push) Has been cancelled
Update ADEV Cross Repo Docs / Update Cross Repo ADEV Docs (push) Has been cancelled
OpenSSF Scorecard / Scorecards analysis (push) Has been cancelled
CI (push) / adev-deploy (push) Has been cancelled
Performance Tracking / workflow (push) Has been cancelled
The following:

`@Output() someChange = new EventEmitter<void>();`

is correctly migrated to:

`readonly someChange = output<void>();`

However, a TODO is incorrectly inserted for subsequent emissions from
`someChange`, stating that an argument is expected.
2026-05-18 13:25:01 -07:00
Alan Agius
49ccb5154b build: update pnpm to v11.1.2
See associated pull request for more information.

Closes #68773 as a pr takeover
2026-05-18 13:24:31 -07:00
Kristiyan Kostadinov
9b7b9ba304 refactor(core): update internal utility
Updates the `getClosestComponentName` function to add support for a predicate function, based on internal requirements.
2026-05-18 13:23:46 -07:00
Angular Robot
7ec399ecb5 build: update dependency puppeteer to v25
See associated pull request for more information.
2026-05-18 13:23:09 -07:00
Matthieu Riegler
872853fbcb docs(docs-infra): Show function args
With this change non-overloaded functions also show the params + return type in a dedicated block.
2026-05-18 13:22:28 -07:00
Kam
b7255f9d13 docs: open external anchors in adev markdown in a new tab
Several raw HTML `<a>` anchors in adev markdown link to external
sites without `target="_blank"`, so they open in the same tab
instead of a new one like the rest of the site's external links.
Add `target="_blank"` to match.
2026-05-18 13:18:20 -07:00
Alan Agius
0011664d1c fix(core): reject script element as a dynamic component host
To enhance application security and prevent accidental or malicious script execution, this change ensures that dynamically mounting a component via createComponent directly onto a <script> element throws a runtime error in development mode. SVG <script> elements are also rejected. The error message is designed to be fully tree-shakable under production builds where ngDevMode is disabled.
2026-05-18 13:16:31 -07:00
Kam
51b1db54ad refactor(core): remove deprecated UNSAFE_IFRAME_ATTRS alias
`UNSAFE_IFRAME_ATTRS` in the `RuntimeErrorCode` enum is a `@deprecated`
alias of `UNSAFE_ATTRIBUTE_BINDING` (same value -910) with no usages
anywhere. Drop it along with the paired
`tslint:disable-next-line:no-duplicate-enum-values` suppression.
`RuntimeErrorCode` is re-exported as `ɵRuntimeErrorCode`, so the
enum's value set is not a stability commitment.
2026-05-18 13:16:02 -07:00
Alan Agius
cef4a095a2
refactor(core): align namespaced attribute validation and security schema contexts
Refactors the element security schema lookups and runtime attribute validation to
consistently account for SVG and MathML namespaces. This improves the modularity
and accuracy of security context mapping during template compilation and runtime
constant evaluation, eliminating redundant or false-positive lifecycle checks.
2026-05-18 13:09:39 -07:00
Leon Senft
88b0e420cf
refactor(compiler): add support for importing foreign components
- Added the ForeignComponent interface in @angular/core.
- Added Component.foreignImports for importing ForeignComponents (supporting direct references and adapter function wrappers).
- Updated the compiler to handle ForeignComponent in template dependencies.
- Updated ngtsc to extract foreignImports from standalone components.
2026-05-18 13:08:59 -07:00
arturovt
f43bad4d7b perf(forms): avoid spurious recomputation in FormField.parseErrors
`parseErrors` in `FormField` always produced a new array on every recomputation, even when nothing actually changed. The `?? []` fallback created a new empty array whenever `parseErrorsSource` was undefined, and `.map()` also returned new object references each time.

Since computed signals use reference equality by default, those new arrays were treated as changed values. That caused unnecessary updates to propagate through `validationState.parseErrors` and the combined errors chain, triggering extra recomputations during change detection.

Fix this by adding `{equal: shallowArrayEquals}` to the `parseErrors` computed, matching the existing `errors` computed and the validation computeds in `field/validation.ts`.

This prevents empty arrays from triggering updates while still correctly propagating real parse-error changes.
2026-05-18 13:08:33 -07:00
SkyZeroZx
00c284015c fix(core): makes resource URL sanitizer lookup case-insensitive
Ensures the resource map for URL sanitization is queried using lowercase tag and property names, improving robustness by handling case variations consistently.
2026-05-18 13:07:34 -07:00
cexbrayat
9a7dedced6 docs: use when in signal forms rule examples
Some checks failed
CI (push) / lint (push) Has been cancelled
Performance Tracking / list (push) Has been cancelled
DevInfra / assistant_to_the_branch_manager (push) Has been cancelled
CI (push) / zone-js (push) Has been cancelled
OpenSSF Scorecard / Scorecards analysis (push) Has been cancelled
CI (push) / devtools (push) Has been cancelled
CI (push) / test (push) Has been cancelled
CI (push) / integration-tests (push) Has been cancelled
CI (push) / adev (push) Has been cancelled
CI (push) / vscode-ng-language-service (push) Has been cancelled
CI (push) / publish-snapshots (push) Has been cancelled
Update ADEV Cross Repo Docs / Update Cross Repo ADEV Docs (push) Has been cancelled
Performance Tracking / workflow (push) Has been cancelled
CI (push) / adev-deploy (push) Has been cancelled
Update the Signal Forms guides to match df54e6a7b2, which introduced the consistent {when: ...} form for these rules.
2026-05-15 12:16:50 -07:00
Angular Robot
2959d6bd9e docs: update cross-repo adev docs
Updated Angular adev cross repo docs files.
2026-05-15 11:41:49 -07:00
Angular Robot
991e0b4276 build: update dependency node to v22.22.3
See associated pull request for more information.
2026-05-15 11:39:51 -07:00
Angular Robot
2864fed214 build: update all non-major dependencies
Some checks failed
DevInfra / assistant_to_the_branch_manager (push) Has been cancelled
See associated pull request for more information.
2026-05-15 11:38:00 -07:00
Douglas Parker
1963a0eb18 refactor(forms): add provideExperimentalWebMcpForms
This enables the use of the `experimentalWebMcpTool` option on signal forms and implicitly declares a WebMCP tool based on the form data model. This is an experiment inspirted by the WebMCP declarative forms API to see if Angular's framework-level knowledge of the form's declarative data model can produce higher quality WebMCP tools than the web standard can on its own with less effort from the developer.

Example:

```typescript
// main.ts

import {bootstrapApplication} from '@angular/platform-browser';
import {provideExperimentalWebMcpForms} from '@angular/forms';
import {MyComp} from './form';

bootstrapApplication(MyComp, {
  providers: [
    // Activate the feature.
    provideExperimentalWebMcpForms(),
  ],
});
```

```typescript
// form.ts

import {Component, signal} from '@angular/core';
import {form} from '@angular/forms';

@Component({ /* ... */ })
export class MyComp {
  private readonly f = form(signal({
    firstName: '',
    lastName: '',
  }), {
    // Implicitly creates a WebMCP tool named `createUser` which accepts a `firstName` and `lastName` as parameters.
    experimentalWebMcpTool: {
      name: 'createUser',
      description: 'Creates a user with the given name.',
    },

    // Invokes the submit action when the agent calls the WebMCP tool.
    submission: {
      action: () => {
        console.log('User clicked submit, or agent called the tool!');
      },
    },
  });

  // ...
}
```
2026-05-15 11:35:22 -07:00
Jens Kuehlers
358d2e63fb docs: move Angular 19 to unsupported versions 2026-05-15 10:41:39 -07:00
Angular Robot
1a7f00f7c0 build: update cross-repo angular dependencies to v22.0.0-rc.0
See associated pull request for more information.
2026-05-15 10:40:32 -07:00
Andrew Scott
13911b156b refactor(compiler-cli): Remove unused properties of IndexedComponent interface
These properties aren't used in the Kythe indexer and can be removed
2026-05-15 10:37:57 -07:00
Alex Rickabaugh
0a9b19454d refactor(core): add internal API for creating foreign views
Introduces `createForeignView`, an internal API for creating foreign view
directly inside `LContainer`s. Foreign views (`TViewType.Foreign`) are bounded
by head and tail comment nodes and can contain dynamic, non-Angular DOM nodes.

Updates Render3 node manipulation to support inserting, detaching, and moving
foreign views along with their internal content.
2026-05-15 10:33:52 -07:00
Matthew Beck
71f8d488e0 docs: release notes for the v22.0.0-rc.0 release
Some checks failed
DevInfra / assistant_to_the_branch_manager (push) Has been cancelled
CI (push) / lint (push) Has been cancelled
CI (push) / devtools (push) Has been cancelled
CI (push) / test (push) Has been cancelled
CI (push) / integration-tests (push) Has been cancelled
CI (push) / adev (push) Has been cancelled
CI (push) / vscode-ng-language-service (push) Has been cancelled
CI (push) / publish-snapshots (push) Has been cancelled
CI (push) / zone-js (push) Has been cancelled
Update ADEV Cross Repo Docs / Update Cross Repo ADEV Docs (push) Has been cancelled
Performance Tracking / list (push) Has been cancelled
OpenSSF Scorecard / Scorecards analysis (push) Has been cancelled
CI (push) / adev-deploy (push) Has been cancelled
Performance Tracking / workflow (push) Has been cancelled
2026-05-13 16:34:51 -07:00
Matthew Beck
21ca0918c7 docs: release notes for the v21.2.13 release 2026-05-13 16:26:24 -07:00
Kam
7557b339ea refactor(core): mark resource() overloads as @publicApi 22.0
#68253 graduated `resource`, `rxResource`, and `httpResource` to stable
by swapping `@experimental` for `@publicApi 22.0` across three files.
The two `resource()` overloads in `packages/core/src/resource/resource.ts`
were missed and still carried `@experimental 19.0`. The public-api
golden already lists both overloads as `// @public`, so this aligns the
source with what the rest of the codebase reflects.
2026-05-13 15:54:55 -07:00