Commit graph

3545 commits

Author SHA1 Message Date
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
Jessica Janiuk
114906d2d6 fix(core): Fix cancellation of animation enter classes (#63442)
When toggling visibility on an element over and over, the enter animations were supposed to be cancelled and then the classes removed. There was a race condition happening that resulted in the cancelled animation being the leave animation. Rather than using the animation.cancel functionality, it's safer to just remove the enter classes.

fixes: #63439

PR Close #63442
2025-08-28 14:11:06 +00:00
arturovt
fce5602b53 refactor(core): mark VERSION as @__PURE__ for better tree-shaking (#63400)
Annotate the `new Version(...)` call with `/* @__PURE__ */` to signal to
optimizers that the constructor is side-effect free.

Without this hint, bundlers such as Terser or ESBuild may conservatively
retain the `VERSION` instantiation even when unused. With the annotation,
the constant can be tree-shaken away in production builds if not referenced,
reducing bundle size.

PR Close #63400
2025-08-27 11:39:07 -07:00
arturovt
f87fad3fff fix(core): avoid injecting internal error handler from a destroyed injector (#62275)
This commit prevents lazy injection of the internal `ErrorHandler` from a destroyed injector, which would otherwise result in a secondary "destroyed injector" error.

The `handleUncaughtError` function is used in a wrapped event listener that invokes the `ErrorHandler` if the listener throws. A simple case in a micro-frontend application:

```ts
onNavigationToAnotherApp() {
  this.appRef.destroy();
  do_some_stuff_ie_loggin_that_may_throw();
}
```

If the function throws an error, Angular attempts to inject the `ErrorHandler` from a destroyed injector.

PR Close #62275
2025-08-27 11:35:55 -07:00
Alexander Melde
06c53679ba docs: update to new standalone default behavior (#63329)
When declaring directives, the standalone flag is set to true by default in current Angular versions.

The docs for the directive decorator should correctly explain the default behavior, while still mentioning when to set it to false.

PR Close #63329
2025-08-27 11:26:13 -07:00
Jessica Janiuk
ed6a347109 refactor(core): prevent timeout from applying to non-event animation bindings (#63393)
The 4 second removal timeout was applying in all cases, but it should only actually apply to the situation where the event binding syntax is used for animate.leave. This ensures that's the only case in which it'll apply.

PR Close #63393
2025-08-27 11:17:40 -07:00
Taygan Caldwell
23d1ace339 refactor(core): Create a base effect interface and prototype to be used by both angular and wiz. (#62931)
Add a common effect interface and prototype to be used to create the wiz and angular effects.

PR Close #62931
2025-08-26 14:48:33 -07:00
Jessica Janiuk
d7b6045d61 fix(compiler): fixes animations on elements with structural directives (#63390)
The animate instructions were getting applied to the container comment nodes as well as the element nodes. This prevents that on the compiler level.

fixes: #63371

PR Close #63390
2025-08-26 09:47:08 -07:00
Joey Perrott
9a27c5befb build: rename defaults2.bzl to defaults.bzl (#63384)
Use defaults.bzl for the common macros

PR Close #63384
2025-08-25 15:45:46 -07:00
Jessica Janiuk
c8f07daf8f 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:31 -07:00
Jessica Janiuk
6c421ed65d 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:16 -07:00
Jessica Janiuk
9093e0e132 fix(core): fix memory leak with leaving nodes tracking (#63328)
This ensures the nodes are properly cleaned up from the leaving nodes map.

PR Close #63328
2025-08-22 11:23:16 -07:00
Jessica Janiuk
f9d73cc687 fix(core): handle cases where classes added have no animations (#63242)
In the case that someone wants to disable animations via selector specificity, for example by adding an `.animate-disabled` class to a parent node, we need to make sure the animate instructions don't misbehave. Now we detect if animations exist in the provided classes and react accordingly.

fixes: #63161

PR Close #63242
2025-08-20 08:59:03 +00:00
Julien Zapata Duque
52106fb71b docs: use correct closing quote in input and model import usage notes (#63237)
PR Close #63237
2025-08-19 12:33:24 +00:00
Shuaib Hasan Akib
8164b2298e refactor(core): update NG0303 error message (#63222)
Ensure consistency in error message wording by aligning the NG0303
error with other Angular error strings. This improves clarity and
maintains a uniform developer experience

PR Close #63222
2025-08-19 08:25:50 +00:00
Jessica Janiuk
bdc31675b7 fix(core): ensure animate events do not have duplicate elements (#63216)
This applies the same fix that fixed the class version to the event binding version. It prevents duplicate elements from being on screen when animations have been toggled too fast.

fixes: #63127

PR Close #63216
2025-08-18 12:42:17 +00:00
cexbrayat
af63b800ec refactor(core): improve animation instruction robustness and maintainability (#63163)
This commit extracts helper functions to reduce code duplication across animation instructions and adds early return when animations are disabled.

PR Close #63163
2025-08-18 12:49:18 +02:00
Andrew Scott
d9f0e6b27c Revert "feat(platform-browser): Add IsolatedShadowDom encapsulation method (#62723)" (#63142)
This reverts commit d24d5742db. A
legitimate issue was raised in the original commit
(see d24d5742db (commitcomment-163853393))

PR Close #63142
2025-08-13 11:12:59 -07:00
Matthieu Riegler
af247cacb6 refactor(core): remove temporary resource setter function. (#63097)
Now that G3 has been fully migrated to the new throwing behavior, we don't need that setter anymore.

PR Close #63097
2025-08-11 15:43:48 -07:00
Jessica Janiuk
6a1184600c fix(core): prevents duplicate nodes when @if toggles with leave animations (#63048)
In the case that a leave animation is running and someone toggles an `@if`, a new node would be inserted. For a brief moment, there may be two of the same nodes visible at once. While this is expected with native CSS, it's not ideal. Instead, we retain a reference to the leaving element and can remove that node when the new node is entering.

fixes: #63020

PR Close #63048
2025-08-08 10:02:35 -07:00
Matthieu Riegler
85d51a3215 fix(core): destroying the effect on afterRenderEffect (#63001)
Prior to this commit, the effect node wasn't destroyed.

fixes #62980

PR Close #63001
2025-08-08 08:46:46 -07:00
Ryan Bendel
d24d5742db feat(platform-browser): Add IsolatedShadowDom encapsulation method (#62723)
IsolatedShadowDom encapsulation fixes style leakage in Shadowdom encapsulation by removing sharedstyleshost from dom-renderer IsolatedShadowdom class. Updates docs.

PR Close #62723
2025-08-06 16:48:37 +02:00
Matthieu Riegler
9a76a6540d refactor(devtools): add support for afterRenderEffect on the signal graph (#63005)
Prior to this change, the `afterRenderEffect` phases were not represented in the signal graph.

PR Close #63005
2025-08-06 15:08:33 +02:00
Andrew Scott
01fec33556 docs: Deprecate BootstrapOptions on bootstrapModule (#62690)
This deprecates `BootstrapOptions` since `NgZone` can now be configured
in the providers. This is a necessary step because when zoneless becomes
the default, developers will have to add ZoneJS via
`provideZoneChangeDetection` and that will override anything defined in
`BootstrapOptions`.

PR Close #62690
2025-08-06 11:19:45 +02:00
Milo
b3e490437c refactor(devtools): enable view source for template effects (#62692)
Use inspect(class instance.constructor) to jump to the source of
components when trying to inspect template effects

PR Close #62692
2025-08-06 11:19:14 +02:00
Jessica Janiuk
ebd622b344 fix(core): fixes empty animations when recalculating styles (#63007)
Any time something causes styles to recalculate,
`element.getAnimations()` will be empty. This updates `animate.enter`
and `animate.leave` to rely on `getComputedStyles` to determine the
longest animation instead.

fixes: #63006

PR Close #63007
2025-08-06 11:17:30 +02:00
SkyZeroZx
52b8e07d6e feat(platform-browser): Warns on conflicting hydration and blocking navigation (#62963)
Adds an internal token to detect when both hydration and blocking initial navigation are enabled. Logs a warning during app initialization if this unsupported combination is found, helping developers avoid misconfiguration and potential runtime issues.

PR Close #62963
2025-08-05 18:16:10 +02:00
Paul Gschwendtner
648bbb097e fix(core): properly recognize failed fetch responses when loading external resources in JIT (#62992)
Currently when loading external resources in JIT, when `fetch` fails,
the `text` is empty and the component is loading. This hides the actual
underlying fetch error. We should properly detect this and error out.

PR Close #62992
2025-08-05 10:10:56 +02:00
Jessica Janiuk
de3a0c5cf3 fix(core): Fix animate.enter class removal when composing classes (#62981)
In the case when composing animation classes with `animate.enter` on the
element itself and also with host bindings, the removal would only
have context for one of the classes added: the last one added. This
allows for tracking of the classes added by `animate.enter` via a
WeakMap so we know the exact classes added and which to remove.

Also shores up the tests to make sure we are fully testing animate.enter.

PR Close #62981
2025-08-05 10:06:28 +02:00
Andrew Scott
141bb75ff2 feat(core): Promote zoneless to stable (#62699)
This commit moves zoneless from developer preview to stable and updates the roadmap to indicate it is ready for production use.

PR Close #62699
2025-08-05 10:03:31 +02:00
Jessica Janiuk
6597ac0af7 fix(core): fix support for space separated strings in leave animations (#62979)
Space separated strings, e.g. `class-1 class-2`, should work with both enter and leave animations. `animate.leave` lost that functionality in a refactor. Tests are now added to catch this.

fixes: #62964

PR Close #62979
2025-08-04 12:24:11 +02:00
Jessica Janiuk
857675fedb refactor(core): this delays removal of stylesheets when the element registry is present (#62943)
When animate.leave is used, stylesheet pruning causes issues. Stylesheets with the appropriate animations get pruned before the animations can run. This will delay the removal in the case that the registry is present.

fixes: #62942

PR Close #62943
2025-08-01 12:54:22 +00:00
Jessica Janiuk
455b147488 fix(core): fixes timing issues with enter animations (#62925)
In some patterns, `element.getAnimations()` will be an empty array despite the animation class being present during animation start and the style sheet showing a keyframe animation.
Moving the longest animation check to the end resolves this problem.

fixes: #62923

PR Close #62925
2025-08-01 08:06:34 +00:00
Joey Perrott
cbc258eec8 build: remove ts_project_interop infrastructure (#62908)
Remove the interop macros and final usages

PR Close #62908
2025-07-31 09:12:58 +00:00
Jessica Janiuk
d23c5e4670 refactor(core): Tiny animation optimization (#62896)
This removes one redundant check to reduce code size.

PR Close #62896
2025-07-30 13:56:46 +00:00
Jessica Janiuk
320de4e96d refactor(core): deprecate animations field on component interface (#62895)
This deprecates the animations field on the component decorator in favor of animate.enter and leave.

DEPRECATED: @angular/animations

PR Close #62895
2025-07-30 10:35:29 +00:00
Matthieu Riegler
1ab3b5b21b refactor(core): add private resource error helper function for g3 migration (#62840)
This function is intented to be temporary to help migrate G3 code to the new throwing behavior.

PR Close #62840
2025-07-30 09:23:11 +00:00
Jessica Janiuk
898244a03a refactor(core): add configurable behavior for animations to testbed (#62764)
This adds a test module configuration to define whether animations should be enabled or disabled in test. By default, they are disabled.

PR Close #62764
2025-07-29 09:49:35 +00:00
Joey Perrott
17ada9838b build: move tsec to new toolchain (#62825)
Migrate tsec tooling/macro to use tsec directly as a js_binary and rely on ts_project dependencies.

PR Close #62825
2025-07-28 20:07:05 +02:00
Milo
3c008c9263 refactor(core): use quad linked lists for signals (#62284)
inspired by the design of Preact's signals, use linked lists instead of arrays for faster signal creation

PR Close #62284
2025-07-28 17:01:42 +02:00
Garegin Hakobyan
b11e0502f5 docs(docs-infra): correct typos in adev and wording in resource api (#62801)
PR Close #62801
2025-07-24 16:13:00 +00:00
Jessica Janiuk
063b5e166f fix(core): switch check to documentElement with chaining (#62773)
This fixes a situation where DOM checks may report null.

PR Close #62773
2025-07-23 15:01:59 -04:00
Jessica Janiuk
593cc8a368 fix(core): checks if body exists before continuing (#62768)
This fixes a case in which the document exists, but the body does not.

PR Close #62768
2025-07-23 12:54:39 -04:00
Jessica Janiuk
882522c1ad refactor(compiler): Tree shake Element Registry (#62682)
This creates a feature to detect usages of animate.leave and only enables the element removal registry when necessary

PR Close #62682
2025-07-23 09:37:16 -04:00
Jessica Janiuk
6b1f4b9e8b feat(core): add enter and leave animation instructions (#62682)
This adds the instructions to support enter and leave animations on nodes.

PR Close #62682
2025-07-23 09:37:16 -04:00
Kristiyan Kostadinov
68f3c65314 refactor(core): expose function for inferring tag name (#62283)
Exposes the code that we use to infer the tag name of a component as a private export so that we can use it in `TestBed`.

PR Close #62283
2025-07-23 07:30:36 -04:00
Hryhorii Avcharov
a2f366f629 feat(devtools): add transfer state tab (#62465)
Add transfer state tab, which is taking transfer state script by using APP_ID. Created internal api ɵgetTransferState to retrieve transfer state value from app into devtools app.

PR Close #62465
2025-07-22 08:41:10 -04:00
Leon Senft
4138aca91f feat(core): render ARIA property bindings as attributes (#62630)
Allow binding to ARIA attributes using property binding syntax _without_
the `attr.` prefix. For example, `[aria-label]="expr"` is now valid, and
equivalent to `[ariaLabel]="expr"`. Both examples bind to either a
matching input or the `aria-label` HTML attribute, rather than the
`ariaLabel` DOM property.

Binding ARIA properties as attributes will ensure they are rendered
correctly on the server, where the emulated DOM may not correctly
reflect ARIA properties as attributes.

Reuse the DOM schema registry from the compiler to map property names in
type check blocks.

PR Close #62630
2025-07-22 06:59:00 -04:00
Matthieu Riegler
db3c928305 refactor(core): add a getTransferState for the devtools (#62722)
`getTransferState` will expose public data from the transfer state. It will for example remove internal hydration data.

PR Close #62722
2025-07-21 17:00:27 -04:00
Elizabeth
b8e415a717 fix(core): fix change tracking for Resource#hasValue (#62595)
When using `hasValue()` I would expect it to behave like any other
reactive value such that changes to the internal `value()` that do not
cause `hasValue()` to return anything different do not trigger change
detection, but this was not the case. This change wraps the value
checking in a `computed` such that it behaves as expected again while
still preserving the type narrowing.

PR Close #62595
2025-07-18 10:01:43 -04:00