Commit graph

3594 commits

Author SHA1 Message Date
Jessica Janiuk
2fad4d4ab6 fix(core): prevent duplicate nodes from being retained with fast animate.leave` calls (#64592)
We were clearing duplicate nodes when `animate.enter` fired fast, but not when solely `animate.leave` is fired and rapid toggles occur. This ensures that the `cancelLeavingNodes` function is called in all cases instead of just enter animations.

fixes: #64581

PR Close #64592
2025-10-22 19:07:35 +00:00
Jessica Janiuk
139b622957 refactor(core): clarify comments on enter animation queuing (#64550)
This just updates the comments and adds some tests to verify some of the queuing behavior for enter animations.

PR Close #64550
2025-10-21 15:17:14 +00:00
SkyZeroZx
b0551419cd refactor(core): Removes unused trigger parameter from scheduleDelayedPrefetching (#64517)
Simplifies delayed prefetching calls by eliminating an unnecessary trigger argument

PR Close #64517
2025-10-21 15:16:40 +00:00
SkyZeroZx
9b494c7de5 docs: Add DestroyRef.destroyed and usage in lifecycle guide (#64422)
PR Close #64422
2025-10-21 15:12:50 +00:00
Jessica Janiuk
911d6822cb fix(core): update animation scheduling (#64441)
In some rare cases, it seems the animation queue disappears despite being afterEveryRender. This updates the animation scheduler to be afterNextRender instead and only schedules it when we need to.

fixes: #64423

PR Close #64441
2025-10-16 17:35:51 +00:00
SkyZeroZx
80907b20c1 docs: Fixes DI guide reference missing ')' in see tag (#64457)
PR Close #64457
2025-10-16 17:34:18 +00:00
Matthieu Riegler
43cb583f70 refactor(devtools): add debug router APIs (#64411)
This is a patch backport of #63081

PR Close #64411
2025-10-14 15:41:11 -07:00
Andrew Kushnir
5f4f624477 Revert "refactor(core): add debug name to resource (#64172)" (#64418)
This reverts commit 63180067aa.

PR Close #64418
2025-10-14 14:28:17 -07:00
Jessica Janiuk
f15cfa4cc4 fix(core): fixes regression in animate.leave function bindings (#64413)
When adding and removing items in a `@for` loop, the `animate.leave` event binding instruction was not updated to use the same logic as the class function when the animation queue was added. We were not returning the correct signature for the `animate.leave` function, which caused the animation to not trigger correctly. This updates the event binding instruction to use the same logic as the class function when adding the animation to the queue.

fixes: #64336

PR Close #64413
2025-10-14 13:46:39 -07:00
Matthieu Riegler
5b0363c1ee refactor(core): warning when hydration trigger is used without hydration being enabled (#64185)
This replaces the error we were throwing before the change. This allows component with defer triggerrs to be used on both SSR'd and CSR.

fixes #64184

PR Close #64185
2025-10-14 11:55:22 -07:00
hawkgs
623c2847be refactor(core): add debug name to resource (#64172)
Decorate `resource` (and `httpResource`) with `debugName`, along with all of its internal signals.

PR Close #64172
2025-10-14 09:31:42 -07:00
Jessica Janiuk
d54dd674ca fix(core): Prevents early style pruning with leave animations (#64335)
In some cases, the leave animation stylesheets were getting pruned too early due to the renderer removal happening before the animation function was run. This ensures that while queuing a leave animation, we guarantee the lView is referenced in the leaving animations set. This guarantees the style sheet pruning knows about the animations existing and skips the prune step.

fixes: #64326

PR Close #64335
2025-10-14 09:30:33 -07:00
SkyZeroZx
7cc6af9ae7 docs: Add example Unhandled errors in Angular documentation (#64356)
PR Close #64356
2025-10-13 08:30:26 -07:00
SkyZeroZx
da38cd9679 docs: add example for assertInInjectionContext (#64325)
PR Close #64325
2025-10-10 06:51:45 -07:00
Matthieu Riegler
fa25dadae9 refactor(core): use the ValueEqualityFn from core (#64247)
Instead of the non-public primitive one.

PR Close #64247
2025-10-09 05:31:35 -07:00
Matthieu Riegler
0f7b877412 docs: add mentions host style bindings (#64257)
Also adds a section about css custom properties

fixes #64256

PR Close #64257
2025-10-07 20:39:41 -04:00
Jessica Janiuk
3b959105be fix(core): prevent early exit from leave animations when multiple transitions are present (#64225)
Our code ensuring host binding composition for animations was causing the early exit and removal of
elements when multiple transitions were present on the same element. This commit fixes the issue by
ensuring that we properly keep track of all the promise resolvers on the LView and then only
call them once we've properly waited for the longest animation to finish.

fixes: #64209

PR Close #64225
2025-10-06 15:34:28 -04:00
Jessica Janiuk
24906249e6 refactor(core): allow animationend to process if we don't have a longest animation (#64225)
There may be cases where the longest animation info has been cleaned up before the end animation fires. We should still do the end processing in that case.

PR Close #64225
2025-10-06 15:34:28 -04:00
Jessica Janiuk
08b8b13185 refactor(core): fix animations host binding tests (#64225)
These tests were not properly validating against the host binding changes due to the fact that the styles were on the wrong components in some of the host binding cases.

PR Close #64225
2025-10-06 15:34:27 -04:00
Jessica Janiuk
853ed169a8 fix(core): ensure missing leave animations don't queue leave animations (#64226)
There was a bug in the logic for checking if a leave animation exists for a node. This was affecting timing of nodes with enter animations.

PR Close #64226
2025-10-03 13:28:55 -07:00
Jessica Janiuk
6fed986b7a fix(core): Fixes animations in conjunction with content projection (#63776)
Content Projected nodes are not destroyed and recreated, like every other
situation. Enter and Leave animations were ephemeral and are
expected to run once, and then be cleared. This means that for content projection
cases, the animations would only ever work the first time they were shown / hid.

In order to resolve this, we move to an animation queue that re-runs the animation
functions stored in the LView. In most cases, this animation will run once on creation.
For content projection, the enter and leave animations will fire more than once. Animations
are stored on the LView, but indexed and scheduled by whichever RNode needs to be animated.
So we only run animations for an affected RNode, rather than potentially all in the LView.

This also moves the queue to afterRender, which is safer than right after template
execution in refreshView.

fixes: #63418
fixes: #64065
fixes: #63901

PR Close #63776
2025-10-02 16:56:01 +00:00
Yasin Aslan
76fe5599fe fix(core): handle undefined CSS time values in parseCssTimeUnitsToMs function (#64181)
Improve error handling when `rawDelays` contains fewer items than `transitionedProperties`, preventing a toLowerCase of undefined error in `parseCssTimeUnitsToMs`.

PR Close #64181
2025-10-02 08:13:49 -07:00
kirjs
a453b1de08 Revert "fix(core): Fixes animations in conjunction with content projection (#63776)" (#64189)
This reverts commit 1cb16fddb5.

PR Close #64189
2025-10-01 22:42:41 +00:00
Jessica Janiuk
0e928fbc4a fix(core): Fixes animations in conjunction with content projection (#63776)
Content Projected nodes are not destroyed and recreated, like every other
situation. Enter and Leave animations were ephemeral and are
expected to run once, and then be cleared. This means that for content projection
cases, the animations would only ever work the first time they were shown / hid.

In order to resolve this, we move to an animation queue that re-runs the animation
functions stored in the LView. In most cases, this animation will run once on creation.
For content projection, the enter and leave animations will fire more than once. Animations
are stored on the LView, but indexed and scheduled by whichever RNode needs to be animated.
So we only run animations for an affected RNode, rather than potentially all in the LView.

This also moves the queue to afterRender, which is safer than right after template
execution in refreshView.

fixes: #63418
fixes: #64065
fixes: #63901

PR Close #63776
2025-10-01 09:07:38 -04:00
hawkgs
612ce99457 refactor(compiler-cli): include linkedSignal in the signal debugName transformer (#64106)
Add support for `linkedSignal`s in the signal `debugName` transformer. Continuation of #63346

PR Close #64106
2025-09-30 14:52:16 -04:00
Jessica Janiuk
d900dba595 Revert "refactor(compiler): Remove the interpolation config (#64071)" (#64110)
This reverts commit 768a09d3c3.

PR Close #64110
2025-09-26 15:16:54 -04:00
Matthieu Riegler
9dbcff8794 refactor(compiler): Remove the interpolation config (#64071)
After #63474, we don't need that anymore.

PR Close #64071
2025-09-26 12:36:51 -04:00
Jessica Janiuk
e5157bd933 fix(core): prevents unintended early termination of leave animations and hoisting (#64088)
The event listeners for animationstart and animationend weren't properly checking whether the animation event fired matched the node we're bound to, since animation events bubble. This resulted in child node animation events bubbling up and causing elements to get prematurely removed.

fixes: #64084

PR Close #64088
2025-09-25 15:33:31 -04:00
Matthieu Riegler
542cd0019a fix(core): do not rename ARIA property bindings to attributes (#64089)
angular#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, angular#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 angular#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 #64089
2025-09-25 14:51:13 -04:00
Avcharov Hryhorii
8d1891a532 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
9515a70933 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
Steven Chim
64a36757e5 docs: fix typo in component bindings jsdoc (#63969)
PR Close #63969
2025-09-22 14:33:07 +00:00
Jessica Janiuk
e78451cf8a 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:20 +00:00
Matthieu Riegler
b04e6b1869 refactor(core): drop the usage of PromiseSettledResult<void> (#63955)
`PromiseSettledResult<void>` requires the ES2020 typings. Those might not be provided (or `skipLibCheck` is not enabled).

fixes #63931

PR Close #63955
2025-09-19 20:27:26 +00:00
Alan Agius
150ed2b569 docs: add documentation for NG0401 error (#63947)
PR Close #63947
2025-09-19 17:01:21 +00:00
Matthieu Riegler
d0c7ea8491 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:08 +00:00
SkyZeroZx
96a070e9e0 refactor(core): Remove duplicate code getSelectedTNode (#63897)
clean up duplicate functions

PR Close #63897
2025-09-18 16:04:26 +00:00
Matthieu Riegler
dcdca98f5d 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:52 +00:00
Matthieu Riegler
423cc17a76 refactor(common): trim undefined from locale data. (#63520)
This is an optimization to shave of unecessary data.

fixes #42315

PR Close #63520
2025-09-17 14:57:17 +00:00
arturovt
0afd9c5632 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
arturovt
4a23f6e79d 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:40 +00:00
Jessica Janiuk
c8d3439814 refactor(core): Reorganize and cleanup animations code (#63775)
This is a pure re-organization of the animations code. No functionality changes, but it should be easier to navigate now. Utility classes have been moved to a `utils.ts` file. The related functions in the instructions have been grouped closer together.

PR Close #63775
2025-09-12 21:41:52 +00:00
Jessica Janiuk
3ec8a5c753 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:25 +00:00
Jessica Janiuk
5f5828f60d refactor(core): dispatch enter and leave animations at the right times (#63710)
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 #63710
2025-09-10 22:24:31 +00:00
Jessica Janiuk
e00c5c5b3f refactor(core): track enter and leave animations in LView (#63710)
This tracks the enter and leave functions in the LView to be executed at a safe time for change detection.

PR Close #63710
2025-09-10 22:24:31 +00:00
Matthieu Riegler
10827a41ea refactor(core): Error logs links point to the archived version of the docs (#63512)
In order to point the right context, links in error messages will target the archived version of the online doc site (v*.angular.io).

See #44650

PR Close #63512
2025-09-10 22:21:10 +00:00
Matthieu Riegler
1b7f53021f build: add a noDuplicateEnumValue rule (#63483)
It caught several legitimate issues.
In the cases I wasn't sure, I just disabled the rule.

fixes #45843

PR Close #63483
2025-09-10 22:16:11 +00:00
Jessica Janiuk
802dbcc2a0 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:20 -07:00
Alan Agius
6117ccee2e feat(core): introduce BootstrapContext for improved server bootstrapping (#63636)
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.

(cherry picked from commit 8bf80c9d2314b4f2bcf3df83ae01552a6fc49834)

PR Close #63636
2025-09-09 10:45:02 -07:00
arturovt
1e3999ec36 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