Commit graph

1303 commits

Author SHA1 Message Date
SkyZeroZx
281a2dba78 docs: Add guide for debounced signals
Add guide for `debounced` signals.
Also add `@see` tags
2026-04-15 20:04:10 +03:00
YooLCD
39e382a756 fix(http): add CSP nonce support to JsonpClientBackend
Add support for CSP nonces in JsonpClientBackend by injecting the CSP_NONCE token.
This ensures that dynamically created script tags for JSONP requests include the
required nonce attribute to comply with strict Content Security Policies.
2026-04-13 16:01:11 +03:00
Matthieu Riegler
70368ea94d refactor(http): Make BrowserXhr/XhrFactory tree-shakable
3bc095d made the `FetchBackend` the default, we shouldn't load anything Xhr related by default anymroe.
2026-04-13 13:56:03 +03:00
Doug Parker
1ef503e18e test(http): disable XSRF and mock location in HttpClient tests to avoid Domino failures and state leakage
The `HttpClient` tests in `client_spec.ts` were failing intermittently in Node/Domino environment because `MockPlatformLocation` defaults to `http://_empty_/`. This valid URL satisfied the URL parser in `xsrfInterceptorFn`, causing it to proceed to cookie extraction which throws `NotYetImplemented` in Domino.

To fix this:
1. Disabled XSRF protection in `client_spec.ts` using `withNoXsrfProtection()`, as these tests are not for XSRF.
2. Provided `ɵprovideFakePlatformNavigation` to remove state leakage effects and ensure consistency.
2026-04-06 11:05:53 -07:00
Doug Parker
61ee183fa7 test: construct local Date objects to fix timezone flakiness
Replaced testing constructions of `Date` objects from `formatDate` tests from plain ISO strings over to 'new Date(year, month, date)'.

Instantiating 'new Date("2024-01-01")' parses the string strictly as UTC midnight ("2024-01-01T00:00:00.000Z"). When local operations execute (such as calculating `getThursdayThisIsoWeek` boundaries), the UTC date shifts relative to the executing machine's timezone. For example, in PST (GMT-8), that date translates exactly to 'December 31st 16:00:00', pushing week boundaries backwards.

By wrapping date constructs explicitly as 'new Date(2024, 0, 1)', it natively guarantees local midnight execution and prevents boundaries shifting on global CI Remote Build Execution (RBE) workers.

Example (from a machine in PST):

```javascript
> new Date('2024-01-01')
Sun Dec 31 2023 16:00:00 GMT-0800 (Pacific Standard Time)
> new Date(2024, 0, 1)
Mon Jan 01 2024 00:00:00 GMT-0800 (Pacific Standard Time)
```
2026-03-26 18:34:08 +01:00
Doug Parker
a1385ad977 test: remove unsupported timezone from formatDate tests
Removes the 'America/New_York' timezone string test case from `formatDate` tests because the underlying `Date.parse` API does not support IANA timezone strings. This caused the timezone calculation to silently fall back to the local executing machine's timezone, leading to non-deterministic test flakiness on Remote Build Execution (RBE) workers operating in varying geographic locations.
2026-03-26 18:34:08 +01:00
Matthieu Riegler
eae8f7e30b feat(core): Set default Component changeDetection strategy to OnPush
The default change detection strategy is now OnPush.

BREAKING CHANGE: Component with undefined `changeDetection` property are now `OnPush` by default. Specify `changeDetection: ChangeDetectionStrategy.Eager` to keep the previous behavior.
2026-03-24 16:25:02 -07:00
SkyZeroZx
1f9a42bb42 refactor(http): Make Fetch API the default in HttpBackend
Updates the `HttpBackend` default provider to `FetchBackend`.

Also updates related warning messages to reflect the new default behavior.
2026-03-23 11:20:39 -07:00
splincode
c5da47f63f refactor: replace any with stricter types in common and core
- `JsonPipe.transform`: `any` → `unknown`
- `renderStringify`: `any` → `unknown`
- `NgLocalization.getPluralCategory`: `any` → `number`
2026-03-20 15:20:43 -07:00
SkyZeroZx
c1312da183 fix(common): avoid redundant image fetch on destroy with auto sizes
prevents browsers from re-fetch image during DOM teardown
when using `sizes="auto"` with lazy loading.

Fixes angular#67055
2026-03-19 15:21:16 -07:00
Alan Agius
4febb8ad31 build: update aspect_rules_js to 3.0.2 (#67518)
This updates the major version of `aspect_rules_js`.

PR Close #67518
2026-03-11 13:37:33 -07:00
Jessica Janiuk
5338b5912c Revert "refactor(http): Improves base64 encoding/decoding with feature detection (#67002)"
This reverts commit aafeb1d2bd.
2026-03-04 09:19:10 -08:00
Jessica Janiuk
7eb33713b9 Revert "fix(http): correctly cache blob responses in transfer cache (#67002)"
This reverts commit 1f057afaac.
2026-03-04 09:19:10 -08:00
SkyZeroZx
1f057afaac fix(http): correctly cache blob responses in transfer cache (#67002)
Previously, Blob values were passed to `Uint8Array` this resulted in silently producing an empty array (length = 0) without throwing an error, leading to empty cached data

PR Close #67002
2026-03-04 15:56:59 +00:00
SkyZeroZx
aafeb1d2bd refactor(http): Improves base64 encoding/decoding with feature detection (#67002)
Use feature detection for `Uint8Array.prototype.toBase64` and
`Uint8Array.fromBase64`, falling back to the existing implementation
when native support is not available

PR Close #67002
2026-03-04 15:56:59 +00:00
SkyZeroZx
ead6bb1f52 test(http): refactors HTTP client tests to use TestBed and providers
Updates HTTP client, JSONP, and XSRF tests to utilize `TestBed` for setup.
2026-03-03 09:12:36 -08:00
Miles Malerba
2206efa55f feat(core): add special return statuses for resource params
Allows throwing from the resource's params function to transition the
resource to a status other than resolved.

In particular, the following values can be thrown from params:
- `ResourceParamsStatus.IDLE` causes the resource to become `idle`
  (equivalent to returning `undefined`)
- `ResourceParamsStatus.LOADING` causes the resource to become `loading`
- Any `Error` object causes the resource to become `error` and report
  the error that was thrown via `.error()`

To simplify chaining together resources, this PR also introduces a
context object passed into to the `params` functon. This context
contains a `chain` function that can be used to get the value of a
resource that the params want to depend on, while automatically
propagating the idle, loading, and erorr states of the resource forward.
2026-03-02 08:47:14 -08:00
Jessica Janiuk
88685cb3b6 fix(core): adds transfer cache to httpResource to fix hydration
This should prevent the microtask problem with hydration and httpResource.

fixes: #62897
2026-02-27 09:09:23 -08:00
Matthieu Riegler
3bc095d508 feat(core): Add a schematics to migrate provideHttpClient to keep using the HttpXhrBackend implementation.
Exisiting applications will be migrated to keep using the XHR backend to prevent any breaking changes. `withXhr()` is to the `provideHttpClient` provider function.
2026-02-26 13:47:02 -08:00
Matthieu Riegler
5c432fb8bb feat(http): Use FetchBackend as default for the HttpBackend implementation
This commit replaces the `XhrHttpBackend` with the `FetchBackend` as the default implementation of the `HttpBackend`.
This introduces a breaking change a the `FetchBackend` does not support the report progress for uploads.

The previous behavior (`HttpXhrBackend`) can be restored by setting `withXhr()` in the `provideHttpClient()` provider function.

DEPRECATED: `withFetch` is now deprecated, it can be safely removed.
BREAKING CHANGE: Use the `HttpXhrBackend` with `provideHttpClient(withXhr)` if you want to keep supporting upload progress reports.
2026-02-26 13:47:02 -08:00
Matthieu Riegler
1416eceeea refactor(http): ensure HttpClientModule always uses the xhr backend
This is a follow-up of #67231, in preparation of making the `FetchBackend` the default
2026-02-25 08:12:14 -08:00
SkyZeroZx
97ed3d9e85 refactor(common): log a warning when a KeyValuePipe receives a signal
Add signal warning for `KeyValuePipe` and consolidates the `invalidPipeArgumentError` function into a `utils`
2026-02-25 08:11:29 -08:00
Alan Agius
d550bf713a build: update minimum supported Node.js versions
This commit updates the minimum supported Node.js versions. Node.js v20 support is dropped, and the minimum version for Node.js v22 is bumped to v22.22.0, and for v24 it is bumped to v24.13.1.

BREAKING CHANGE: Node.js v20 is no longer supported. The minimum supported Node.js versions are now v22.22.0 and v24.13.1.
2026-02-25 07:57:18 -08:00
Matthieu Riegler
f30ed6bbf6 refactor(http): expose withXhr to prepare for fetch by default
This commit sets up the necessary changes that would allow us to safely migrate G3 before switch to the `FetchBackend` by default.

For now the `HttpXhrBackend` is still the default backend for the `HttpClient`.
2026-02-24 09:26:26 -08:00
SkyZeroZx
38749698d0 fix(common): fix LCP image detection with duplicate URLs
Addresses an issue where the LCP image observer incorrectly identified LCP elements when the same image URL was used multiple times on a page

Fixes #53278
2026-02-20 13:23:23 -08:00
Matthieu Riegler
0d652ba4da refactor(common): log a warning when a JsonPipe receives a signal
The JsonPipe does not unwrap signals and `JSON.stringify` will return `undefined` for signals.
To avoid confusion, we log a warning when a signal is passed to the pipe.
2026-02-20 09:17:01 -08:00
Rajveer
a8aab64809 refactor(core): remove outdated TODO comments referencing TypeScript 2.1
Angular requires TypeScript >=5.9, making TODO comments that reference TypeScript 2.1 features obsolete. These comments existed in keyvalue_differs.ts and ng_for_of.ts and referenced type improvements that were deferred until TS 2.1, which has long since been surpassed.
2026-02-17 08:49:33 -08:00
SkyZeroZx
ddfc833df9 refactor(common): improve image directive typings
Add image directive typings to improve type safety and removes an unused parameter from the observer registration.
2026-02-12 16:51:51 -08:00
Miles Malerba
18003a33bb feat(common): add an 'outlet' injector option for ngTemplateOutlet
Adds an option (`ngTemplateOutletInjector="outlet"`) that instructs the ngTemplateOutlet to inherit its injector from the outlet's place in the instantiated DOM.
2026-02-10 09:42:50 -08:00
SkyZeroZx
0c6eb60c86 test(http): remove zone-based testing utilities
Removes usages of zone-based helpers as part of the migration to zoneless tests.

Completes the transition to zoneless.
2026-02-10 07:45:00 -08:00
SkyZeroZx
51cc914807 feat(common): support height in ImageLoaderConfig and built-in loaders
Introduces an optional `height` property in `ImageLoaderConfig`, allowing
built-in image loaders to generate URLs with explicit height parameters.
This improves layout control and enables better support for loaders that
require height-based transformations.

Closes #51723
2026-02-09 14:51:04 -08:00
Jaime Burgos
c6d7500203
test(common): remove zone-based testing utilities
Removes usages of zone-based helpers such as `fakeAsync` , `tick`
`waitForAsync` as part of the migration to zoneless tests.

Completes the transition to zoneless.
2026-02-09 14:47:35 -08:00
SkyZeroZx
cb1163e5e5 fix(http): correctly parse ArrayBuffer and Blob in transfer cache
Encodes arraybuffer and blob response bodies as base64 when storing in the transfer cache, ensuring correct retrieval and usage on the client side.

Fixes #66827
2026-02-09 12:32:12 -08:00
SkyZeroZx
66e8385b6a refactor(common): extract argument assertion
Deduplicates string argument validation logic across pipes
by introducing a local assertion helper
2026-02-09 12:26:06 -08:00
Angular Robot
11767cabe4 build: update Jasmine to 6.0.0
Jasmine enables `forbidDuplicateNames: true` by default. So we also need to desambiguate duplicate spec names.
2026-02-09 12:15:57 -08:00
Matthieu Riegler
611f6a49d1 docs: reword docs on standalone.
fixes #66773
2026-01-28 18:16:54 +00:00
Jaime Burgos
4448356313
test(common): enables zoneless change detection in tests
Adds `provideZonelessChangeDetection` to TestBed configurations in  `ngComponentOutlet` , `ngOptimizedImage` , `ngTemplateOutlet` and `ngPlural`.
2026-01-28 00:08:46 +00:00
Andrew Scott
8bbe6dc46c feat(common): Add Location strategies to manage trailing slash on write
Adds dedicated `LocationStrategy` subclasses: `NoTrailingSlashPathLocationStrategy` and `TrailingSlashPathLocationStrategy`.

The `TrailingSlashPathLocationStrategy` ensures that URLs prepared for the browser always end with a slash, while `NoTrailingSlashPathLocationStrategy` ensures they never do. This configuration only affects the URL written to the browser history; the `Location` service continues to normalize paths by stripping trailing slashes when reading from the browser.

Example:
```typescript
providers: [
  {provide: LocationStrategy, useClass: TrailingSlashPathLocationStrategy}
]
```

This approach to the trailing slash problem isolates the changes to the
existing LocationStrategy abstraction without changes to Router, as was
attempted in two other options (#66452 and #66423).

From an architectural perspective, this is the cleanest approach for several reasons:

1. Separation of Concerns and "Router Purity": The Router's primary job is to map a URL structure to an application state (ActivatedRoutes). It shouldn't necessarily be burdened with the formatting nuances of the underlying platform unless those nuances affect the state itself. By pushing trailing slash handling to the LocationStrategy, you treat the trailing slash as a "platform serialization format" rather than a "router state" concern. This avoids the "weirdness" in #66423 where the UrlTree (serialization format) disagrees with the ActivatedRouteSnapshot (logical state).

2. Tree Shakability: If an application doesn't care about trailing slashes (which is the default "never" behavior), they don't pay the cost for that logic. It essentially becomes a swappable "driver" for the URL interaction.

3. Simplicity for the Router: #66452 (consuming the slash as a segment) bleeds into the matching logic, potentially causing issues with child routes or wildcards effectively "eating" a segment that should be invisible. This option leaves the matching logic purely focused on meaningful path segments by continuing to strip the trailing slash on read.

4. Consistency with Existing Patterns: Angular already uses LocationStrategy to handle Hash vs Path routing. Adding "Trailing Slash" nuances there is a natural extension of that pattern—it's just another variation of "how do we represent this logic in the browser's address bar?"

fixes #16051
2026-01-23 20:09:23 +00:00
SkyZeroZx
e38c1bf743 refactor(http): remove redundant providedIn: 'root' in XSRF_HEADER_NAME
Removes unnecessary `providedIn: 'root'` declarations from injection token
2026-01-12 10:00:24 -08:00
SkyZeroZx
f4469ad583 refactor(core): update error message links to versioned docs (#66374)
Error message links now point to the archived documentation site (v*.angular.dev)
so that referenced content matches the framework version in use.

See angular#44650

PR Close #66374
2026-01-09 22:33:51 +00:00
Andrew Scott
49295778bc refactor(core): Use the provided Document value rather than global in FakeNavigation
This commit ensures the Document used by `FakeNavigation` is the one
passed in the constructor rather than the global `document`, which may
be different.
2026-01-08 13:28:18 -08:00
Jessica Janiuk
a2b9429992 Revert "feat(router): add trailingSlash config option"
This reverts commit 12fccc5e99.
2026-01-08 12:20:03 -08:00
Andrew Scott
12fccc5e99
feat(router): add trailingSlash config option
This commit introduces a highly requested `trailingSlash` configuration option to the Angular Router, allowing developers to control how trailing slashes are handled in their applications. The options are:
- 'always': Enforces a trailing slash on all URLs.
- 'never': Removes trailing slashes from all URLs (default).
- 'preserve': Respects the presence or absence of a trailing slash as defined in the UrlTree.
2026-01-08 08:26:37 -08:00
SkyZeroZx
3dfdb71d65 docs: add docs for transform property in built-in loaders 2026-01-07 09:17:59 -05:00
Andrew Scott
dd58c4b667 refactor(common): Add token to indicate whether precommit handler is supported
This commit adds a token that indicates whether the precommitHandler feature
is supported by the navigation api.

https://developer.mozilla.org/en-US/docs/Web/API/NavigateEvent/intercept#precommithandler
2026-01-06 16:10:56 -05:00
SkyZeroZx
a6b8cb68af feat(common): support custom transformations in ImageKit and Imgix loaders
Adds a `transform` parameter for ImageKit and Imgix image loaders.
2026-01-05 15:50:13 -05:00
SkyZeroZx
d8790972be feat(common): Add custom transformations for Cloudflare and Cloudinary image loaders
Adds support for custom transformations to Cloudinary and Cloudflare image loaders via a `transform` parameter.

Fixes #65191 #64639
2026-01-02 08:07:29 +01:00
Matthieu Riegler
6270bba056 ci: reformat files
This is after we've slightly changed a rule in #66056
2025-12-16 14:44:19 -08:00
SkyZeroZx
8485579649 refactor(common): remove redundant providedIn: 'root' from injection tokens
Removes unnecessary declarations from injection tokens
2025-12-12 08:05:30 -08:00
Anuj Chhajed
96b79fc393 refactor(core): correct all typeof ngDevMode comparison patterns introduced by #63875
This change replaces all remaining occurrences of `typeof ngDevMode !== undefined`
with the correct `typeof ngDevMode !== 'undefined'` form. This aligns the codebase
with JavaScript typeof semantics and maintains consistency with other Angular code.
2025-12-08 10:30:01 -08:00