Commit graph

3282 commits

Author SHA1 Message Date
Alan Agius
64e28ccf81 build: update cross-repo angular dependencies (#64073)
See associated pull request for more information.

Closes #64043 as a pr takeover

PR Close #64073
2025-09-25 10:26:19 -04:00
Avcharov Hryhorii
1279364c3a refactor(core): improve linkedSignal type definitions, add debugName to options (#63346)
Add debugName for having ability to visualize linkedSignal name in devtools signal graph

PR Close #63346
2025-09-23 18:15:49 +00:00
JoostK
50d9d55f49 fix(core): fix narrowing of Resource.hasValue() (#63994)
This commit changes `Resource.hasValue()` and its derived types to improve narrowing
of resources whose generic type either does not include `undefined` (i.e. when a default
value has been provided) or when the generic type is `unknown`. This fixes the undesirable
behavior where `hasValue()` would cause the `else` branch of an `hasValue()` conditional
to have a narrowed type of `never`, given that the `hasValue()`'s type guard covers the
entire type range already (meaning that the type in the else-branch cannot be inhabited
in the type system, yielding the `never` type).

By making the `hasValue()` method only a type guard when the generic type includes `undefined`
these problems are avoided.

Fixes #60766
Fixes #63545
Fixes #63982

PR Close #63994
2025-09-23 14:20:55 +00:00
Kristiyan Kostadinov
f5b50ec20d refactor: clean up explicit standalone flags from tests (#63963)
Since standalone is the default, we can dropn the `standalone: true` flags from our tests.

PR Close #63963
2025-09-22 14:27:34 +00:00
Jessica Janiuk
dde5badb71 fix(core): prevent animations renderer from impacting animate.leave (#63921)
This adds an optional flag to the renderer on `removeChild` called `requireSynchronousElementRemoval`, which can tell any downstream renderer that elements need to be removed synchronously. This gets passed down to the legacy animation renderer to ensure that any elements that set this flag aren't impacted by that renderers changes to timing.

fixes: #63893

PR Close #63921
2025-09-19 21:26:18 +00:00
Jessica Janiuk
5d538b21fd Revert "refactor(compiler): expose member decorator identifiers (#63904)" (#63952)
This reverts commit ef0ff78de2.

PR Close #63952
2025-09-19 18:59:42 +00:00
Leon Senft
f008045ded fix(core): do not rename ARIA property bindings to attributes (#63925)
https://github.com/angular/angular/pull/62630 made it so that all ARIA
property bindings would write to their corresponding attribute instead.
The primary motivation for this change was to ensure that ARIA
attributes were always rendered correctly on the server, where the
emulated DOM may not correctly reflect ARIA properties as attributes.
Furthermore, this change added support for binding to ARIA attributes
using the property binding syntax (e.g. `[aria-label]`).

Unfortunately, https://github.com/angular/angular/pull/62630 relied on
the incorrect assumptions that an ARIA property name could be converted
to its attribute name (without hardcoding the conversion), and that the
value of an ARIA property matched its corresponding attribute. For
example, the `ariaLabelledByElements` property's value is an array of
DOM elements, while the corresponding `aria-labelledby` attribute's
value is a string containing the IDs of the DOM elements.

This partially reverts https://github.com/angular/angular/pull/62630 so
that only property bindings with ARIA attribute names (begin with
`aria-`) are converted to attribute bindings.

* `[ariaLabel]` will revert to binding to the `ariaLabel` property.
* `[aria-label]` will continue binding to the `aria-label` attribute.

Note the only difference between `[aria-label]` and `[attr.aria-label]`
is that the former will attempt to bind to inputs of the same name while
the latter will not.

PR Close #63925
2025-09-19 14:50:39 +00:00
Matthieu Riegler
f1be5ae5dc refactor(core): fix MockRenderer in unit tests. (#63936)
This allows us to drop a test only check in the runtime.

PR Close #63936
2025-09-19 14:50:07 +00:00
Kristiyan Kostadinov
ef0ff78de2 refactor(compiler): expose member decorator identifiers (#63904)
Adds the member decorators to the map of exposed compiler symbols.

PR Close #63904
2025-09-18 21:30:15 +00:00
Kristiyan Kostadinov
bb381b707e refactor(compiler): integrate regular expression literals into pipeline (#63887)
Adds support for regular expression literals in the template pipeline and adds some logic to optimize non-global ones.

PR Close #63887
2025-09-18 15:08:56 +00:00
Angular Robot
5c74339dfc build: update cross-repo angular dependencies (#63902)
See associated pull request for more information.

Closes #63890 as a pr takeover

PR Close #63902
2025-09-18 14:39:51 +00:00
Andrew Kushnir
0a81784de2 Revert "refactor(compiler): integrate regular expression literals into pipeline (#63857)" (#63883)
This reverts commit dd77233cdf.

PR Close #63883
2025-09-17 19:36:17 +00:00
arturovt
dee6ef89c7 refactor(core): tree-shake HOST_TAG_NAME in prod (#63861)
Previously, HOST_TAG_NAME had its __NG_ELEMENT_ID__ set at the top level. This
prevented tree-shaking, since the bundler had to keep the assignment as a
potential side effect even when the token was never used.

This change moves the token creation and __NG_ELEMENT_ID__ assignment into a
@__PURE__ IIFE. If HOST_TAG_NAME is not injected anywhere, the IIFE result is
unused and can be dropped entirely by the optimizer. If it is used, the token
still behaves the same at runtime.

PR Close #63861
2025-09-17 17:40:35 +00:00
Kristiyan Kostadinov
dd77233cdf refactor(compiler): integrate regular expression literals into pipeline (#63857)
Adds support for regular expression literals in the template pipeline and adds some logic to optimize non-global ones.

PR Close #63857
2025-09-17 16:06:51 +00:00
Matthieu Riegler
af33647145 refactor(core): remove usages of Promise.withResolvers (#63856)
Promise.withResolvers is Baseline 2024. Our policy is to support browsers in the scope of Basline widely available.

Fixes #63855

PR Close #63856
2025-09-17 15:21:51 +00:00
Andrew Scott
d5e00f9591 refactor(core): Make the zoneless-by-default change a flag flip (#63382)
This makes the zoneless-by-default change a flag flip that can be
individually enabled in tests, createApplication, and bootstrapModule
for gradual rollout. In addition, the "require on CD provider" check is
also made individually flippable for gradual rollout.

PR Close #63382
2025-09-16 18:56:54 +00:00
Andrew Scott
45fed3d201 fix(core): Remove Zone-based change provider from internals by default (#63382)
This change removes the internally provided `ZoneJS`-based change
detection scheduler. This makes Angular Zoneless by default and allows
tree-shaking of the Zone change detection providers.

BREAKING CHANGE: Angular no longer provides a change detection scheduler
for ZoneJS-based change detection by default. Add
`provideZoneChangeDetection` to the providers of your
`bootstrapApplication` function or your `AppModule` (if using
`bootstrapModule`). This provider addition will be covered by an
automated migration.

PR Close #63382
2025-09-16 18:56:53 +00:00
Andrew Scott
6d5c45d13d refactor(core): Remove unused token (#63819)
this removes an unused token from the core package

PR Close #63819
2025-09-16 16:52:53 +00:00
arturovt
b4acc79af6 refactor(core): swap dev/prod error handling order in injector for tree-shaking (#63354)
In production builds, `ngDevMode` is replaced with `false`, so the guard compiles to `return;`. However, bundlers like ESBuild still keep the remaining statements after the return as unreachable code instead of removing them. This leaves behind unnecessary dead code in the output.

Technically, the body is unreachable. But to prove that, the bundler must be 100% certain that:

- `return` cannot be removed by some transform
- there's no later transformation that changes control flow

As thus, it's always conservative.

This also allows dropping `assertDefined`, which was previously
referenced only inside `prependTokenToDependencyPath`. With the
function now fully inlined and dev-only, `assertDefined` is also
eliminated from production builds, further reducing bundle size.

PR Close #63354
2025-09-16 15:53:11 +00:00
Andrew Scott
d9e597f341 refactor(upgrade): use zone-based change detection by default (#63814)
To avoid the need for specifying `provideZoneChangeDetection` in any/all
modules used with `downgradedModule`, this change adds the zone-based change detection
providers by default. This also adds the zone providers to
`UpgradeModule` by default as well.

PR Close #63814
2025-09-16 14:45:28 +00:00
arturovt
7e0cf41563 refactor(core): wrap checkNoChanges body in if (ngDevMode) for better tree-shaking (#63387)
The `checkNoChanges` method previously used an early-return guard:

  if (!ngDevMode) return;
  // dev-only code ...

In production builds, `ngDevMode` is replaced with `false`, so the
guard compiles to `return;`. However, bundlers like ESBuild
still keep the remaining statements after the return as unreachable
code instead of removing them. This leaves behind unnecessary dead
code in the output.

This commit updates the method to instead wrap the full body:

  if (ngDevMode) {
    // dev-only code ...
  }

With this change, the method collapses to an empty function in
production builds:

  checkNoChanges() {}

This ensures that the dev-only logic and its dependencies
(e.g. `checkNoChangesInternal`, `UseExhaustiveCheckNoChanges`) can be
fully tree-shaken, reducing bundle size.

PR Close #63387
2025-09-15 21:11:39 +00:00
Matthieu Riegler
9a16718b13 refactor(core): remove deprecated interpolation option on Components. (#63474)
This option was deprecated by #55778.

BREAKING CHANGE: The `interpolation` option on Components has been removed. Only the default `{{ ... }}` is now supported.

PR Close #63474
2025-09-15 19:35:03 +00:00
Matthieu Riegler
6dff287bb8 refactor(compiler-cli): Add a diagnostic to detect forbiden invocations of required initializers (#63614)
The diagnostic will raise an error when required initializers (input, model, queries) are invoked the context of property initializers and contructors.

Docs will be provided in a follow-up

fixes #63602

PR Close #63614
2025-09-15 19:34:32 +00:00
Jessica Janiuk
a4001c440f fix(core): Prevent leave animations on a move operation (#63745)
When a user has `animate.leave` on a list of items in a `@for`, but are only showing a subset using a computed, removing the second to last item results in a move operation on the last item. There's no native atomic move API in the browser. So this results in the element being detached and attached at its new index. The detaching of the node resulted in leave animations firing.
This fix addresses this by adding a flag in the `LView[ANIMATIONS]` `AnimationLViewData` interface to allow for skipping animations. During list reconciliation, we set this flag so that the animations are skipped over. The flag is flipped back after the move operation is complete.

There is one complication that results from this. The index adjustment of elements in the list happens synchronously while the leave animation is asynchronous. This results in the leaving item getting shifted to the end of the list. This is not ideal but likely can be addressed in a future refactor.

fixes: #63544

PR Close #63745
2025-09-12 15:21:24 +00:00
Andrew Scott
bd54106708 refactor(router): update error checks extending error (#63487)
I forgot about the "setPrototypeOf" fix and had a recency bias for the
NotFoundError in the signal primitives.

PR Close #63487
2025-09-11 16:55:58 +00:00
Rocky Meza
663f48cfc1 refactor(core): Split consumerBefore/AfterComputation (#62549)
This makes it possible to batch effects, where we can "reopen" consumers
during initial render and then finalize them after we are finally done
adding all the effects to a batch:

```
function createBatch() {
  const effect = // ... create effect node
  resetConsumerBeforeComputation(effect);
  return effect;
}

// pseudo-code
function appendEffect(effectBatch, updater) {
  if (value is a signal) {
    const prevConsumer = setActiveConsumer(effectBatch.node);
    const output = value();
    setActiveConsumer(prevConsumer);
    effectBatch.push({ signal, updater });
    return output;
  }
}

function finalizeBatch(effectBatch) {
  if (effectBatch.length > 0) {
    finalizeConsumerAfterComputation(effectBatch.node);
  }
}

const effectBatch = createBatchEffectNode();
appendEffect(signal1, (newValue) => /* something */);
appendEffect(signal2, (newValue) => /* something different */);
finalizeBatch(effectBatch);
```

PR Close #62549
2025-09-11 15:47:33 +00:00
Jessica Janiuk
4924108630 refactor(core): dispatch enter and leave animations at the right times (#63450)
This updates the enter and leave logic to use the stored LView data to dispatch the enter and leave animations at the right points in the lifecycle. This should fix issues with signals not being available yet, parallel animations, and also eliminate the need for the element registry.

fixes: #63391
fixes: #63388
fixes: #63369

PR Close #63450
2025-09-10 22:24:00 +00:00
Jessica Janiuk
bf499f2fca refactor(core): track enter and leave animations in LView (#63450)
This tracks the enter and leave functions in the LView to be executed at a safe time for change detection.

PR Close #63450
2025-09-10 22:24:00 +00:00
Andrew Scott
fb3082fa06 build: fix symbol tests (#63709)
update golden files after cross repo dep updates

PR Close #63709
2025-09-10 13:30:00 -07:00
Alan Agius
f642fcf145 build: update cross-repo angular dependencies (#63706)
See associated pull request for more information.

Closes #63685 as a pr takeover

PR Close #63706
2025-09-10 12:10:15 -07:00
Jessica Janiuk
3d6eeab2e0 fix(core): prevent animation events from being cleaned up on destroy (#63414)
This will allow manually subscribed animation events to still fire when using `animate.leave`. Otherwise they were being cleaned up before the animations happened.

fixes: #63391

PR Close #63414
2025-09-10 10:07:19 -07:00
Angular Robot
0c64a06ea2 build: update cross-repo angular dependencies (#63570)
See associated pull request for more information.

PR Close #63570
2025-09-09 16:37:28 -07:00
Andrew Scott
c3576506b3 refactor(core): Update tests for zoneless by default (#63668)
This updates tests and examples only to prepare for zoneless by default.

These changes were identified and made as part of #63382. Anything that
failed gets `provideZoneChangeDetection` unless the fixes were easily
and quickly determined.

It also adds the zoneless provider to the `initTestEnvironment` calls
for tests in this repo to prevent regressions before #63382 is merged.

PR Close #63668
2025-09-09 14:41:56 -07:00
Alan Agius
28926ba92c feat(core): introduce BootstrapContext for improved server bootstrapping (#63562)
This commit introduces a number of changes to the server bootstrapping process to make it more robust and less error-prone, especially for concurrent requests.

Previously, the server rendering process relied on a module-level global platform injector. This could lead to issues in server-side rendering environments where multiple requests are processed concurrently, as they could inadvertently share or overwrite the global injector state.

The new approach introduces a `BootstrapContext` that is passed to the `bootstrapApplication` function. This context provides a platform reference that is scoped to the individual request, ensuring that each server-side render has an isolated platform injector. This prevents state leakage between concurrent requests and makes the overall process more reliable.

BREAKING CHANGE:
The server-side bootstrapping process has been changed to eliminate the reliance on a global platform injector.

Before:
```ts
const bootstrap = () => bootstrapApplication(AppComponent, config);
```

After:
```ts
const bootstrap = (context: BootstrapContext) =>
  bootstrapApplication(AppComponent, config, context);
```

A schematic is provided to automatically update `main.server.ts` files to pass the `BootstrapContext` to the `bootstrapApplication` call.

In addition, `getPlatform()` and `destroyPlatform()` will now return `null` and be a no-op respectively when running in a server environment.

PR Close #63562
2025-09-09 10:57:09 -07:00
Andrew Scott
92e09adc0a fix(core): Remove ignoreChangesOutsideZone option (#62700)
This option was introduced out of caution as a way for developers to opt out of
the new behavior in v18 which scheduled change detection even when
events happened outside the NgZone. After monitoring the results post-release, we
have determined that this feature is working as desired and do not believe it
should ever be disabled by setting this option to `true`.

This option was deprecated in v18.2, less than 3 months after it was
introduced in v18. We do not really expect it to be used.

BREAKING CHANGE: `ignoreChangesOutsideZone` is no longer available as an
option for configuring ZoneJS change detection behavior.

PR Close #62700
2025-09-02 11:01:44 -07:00
Andrew Scott
d399d7d02b fix(core): Explicit Zone CD in TestBed providers should not override TestBed error handler (#63404)
The internal error handler in TestBed rethrows errors to prevent them
from being silently ignored in tests. Prior to this commit, tests which
used `provideZoneChangeDetection` in the providers would override the
internal error handler of TestBed and prevent these errors from being
rethrown.

BREAKING CHANGE: (test only) - Using `provideZoneChangeDetection` in the
TestBed providers would previously prevent `TestBed` from rethrowing
errors as it should. Errors in the test will now be rethrown, regardless
of the usage of `provideZoneChangeDetection`. Tests should be adjusted to
prevent or account for these errors. As in previous major versions,
this behavior can be disabled with `rethrowApplicationErrors: false` in
`configureTestingModule` as a last resort.

PR Close #63404
2025-09-02 09:26:44 -07:00
Andrew Scott
bbb46e50d4 refactor(router): Add firstValueFrom helper (#63485)
This fixes a bug introduced in #62994 where `toPromise` was used. This
doesn't work in all situations here because some observables don't
complete. This only affected the redirect path, since the others are
already behind other rxjs code which takes the first value from the user
guards.

Note: This is marked as a refactor rather than fix because the commit above is not in
any release yet.

PR Close #63485
2025-08-29 19:02:04 +00:00
Andrew Scott
6e1599d4cc refactor(router): Add internal flag to control async vs rxjs recognize (#62994)
To aid in hitting external breaking change deadlines without pressure
of fixing everything in g3 first, add an internal opt out flag.

This also adds a privately exported provider to revert to the old
rxjs-based behavior, which can be synchronous, until any issues that
come up are addressed.

PR Close #62994
2025-08-29 08:55:13 -07:00
Andrew Scott
5b53535dd1 fix(router): Update recognize stage to use internally async/await (#62994)
This is effectively a revert of 72e6a948bb.
Debugging the recognize stage is considerably easier with async/await
stacks compared to rxjs. This also improves maintainability and is a
better 1:1 with server-side logic that has been implemented to match
and can be more easily kept in sync.

This also ensures that the recognize step is always async, whereas it
can sometimes be synchronous with rxjs.

BREAKING CHANGE: Router navigations may take several additional
microtasks to complete. Tests have been found to often be highly
dependent on the exact timing of navigation completions with respect to
the microtask queue. The most common fix for tests is to ensure all
navigations have been completed before making assertions. On rare
occasions, this can also affect production applications. This can be
caused by multiple subscriptions to router state throughout the application,
both of which trigger navigations that happened to not conflict with the
previous timing.

PR Close #62994
2025-08-29 08:55:13 -07:00
Hongxu Xu
1f4c5f72aa refactor(bazel): reduce build deps (#63348)
clean up deps in bazel build scripts

PR Close #63348
2025-08-28 09:16:10 -07:00
arturovt
ec65663d5e refactor(core): replace Optional/SkipSelf deps with inject() flags (#63386)
This commit updates provider definitions that relied on the `deps` array
with `new Optional()` and `new SkipSelf()` to instead use the modern
`inject(..., { optional: true, skipSelf: true })` API.

Previously:
  deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]

Now:
  const parent = inject(KeyValueDiffers, { optional: true, skipSelf: true });

**Bundle size reduction**: `Optional` and `SkipSelf` are runtime values
created by `makeParamDecorator()`. Even in production builds, esbuild
and other bundlers must keep their factory code because they are
referenced with `new Optional()` / `new SkipSelf()`. With `inject()`,
those classes are no longer referenced, allowing them and the
`makeParamDecorator` scaffolding to be tree-shaken when unused.

As a result, production bundles can drop both `Optional`, `SkipSelf`, and
their supporting factory code when not used elsewhere, reducing code size
while keeping the same behavior.

PR Close #63386
2025-08-28 08:43:17 -07:00
Angular Robot
58cb2bec32 build: update cross-repo angular dependencies (#63395)
See associated pull request for more information.

PR Close #63395
2025-08-27 16:13:08 -07:00
Joey Perrott
2fcafb65c5 build: rename defaults2.bzl to defaults.bzl (#63383)
Use defaults.bzl for the common macros

PR Close #63383
2025-08-25 15:45:01 -07:00
arturovt
1ebba5442f refactor(common): drop X-Request-URL (#61943)
This commit drops the `X-Request-URL` header. It was a non-standard HTTP response header, deprecated long ago and never part of any official specification. Modern browsers now expose the final URL via the `XMLHttpRequest.responseURL` property, as defined in the WHATWG spec.

PR Close #61943
2025-08-25 08:45:19 -07:00
Jessica Janiuk
9139fe0d95 fix(core): Fixes animate.leave binding to a string with spaces (#63366)
This fixes the rare case that someone uses binding syntax with `animate.leave` providing a value with a string that has spaces in it. For example:

```
<example `[animate.leave]="'class-a class-b"` />
```

fixes: #63365

PR Close #63366
2025-08-25 08:33:30 -07:00
Joey Perrott
3df1dccebe refactor: various build and import specificer fixes for strict deps (#63323)
Change direct deps in bazel targets and import specifiers within files to maintain strict deps requirements ahead of enabling strict deps tests in the repo

PR Close #63323
2025-08-22 14:45:00 -07:00
Jessica Janiuk
37ead5ffb5 fix(core): Ensures @for loop animations never get cancelled (#63328)
There's special logic in place to prevent duplicate nodes from showing up in the case when an `@if` toggles a view quickly. This had the unfortunate side effect of causing `@for` leave animations to get cancelled when an add and remove happened simultaneously, even if it was a different index. This fix prevents that from happening in the `@for` loop case.

fixes: #63307

PR Close #63328
2025-08-22 11:23:15 -07:00
Matthieu Riegler
0dd95c503f feat(forms): Add FormArrayDirective (#55880)
The `FormArrayDirective` will allow to have a `FormArray` as a top-level form object.

* `NgControlStatusGroup` directive will be applied to the `FormArrayDirective`
* `NgForm` will still create a `FormGroup`

Fixes angular#30264

BREAKING CHANGE: This new directive will conflict with existing FormArray directives or formArray inputs on the same element.

PR Close #55880
2025-08-21 09:38:37 -07:00
Matthieu Riegler
318718ce64 refactor(forms): extract shared logic from FormGroupDirective (#55880)
Ahead of the implementation of `FormArrayDirective`, extract the shared logic into an abstract class.

PR Close #55880
2025-08-21 09:38:37 -07:00
Angular Robot
790143eb9b build: update cross-repo angular dependencies (#63284)
See associated pull request for more information.

PR Close #63284
2025-08-20 15:58:42 +00:00