Commit graph

3554 commits

Author SHA1 Message Date
AleksanderBodurri
d006721f30 feat(devtools): clean up router tree for stable release (#63081)
Addresses some cleanup items for the router tree:

- No longer loads router ng global APIs as a side effect of importing the router. Rather this is now a runtime step that occurs when provideRouter is called.
- No longer depends on router.navigateByUrl in Angular DevTools. There is now a dedicated global util for this
- Router instance logic no longer depends on token name
- Prevents navigating to lazy or redirect routes (these don't have an associated component)

PR Close #63081
2025-09-02 20:59:15 -07:00
Andrew Scott
475ed59ec6 refactor(core): export zoneless provider token privately (#63558)
This needs to be used internally for a short time when we require one of the providers

PR Close #63558
2025-09-02 20:52:38 -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
541613e758 refactor(core): Update zone and zoneless error to be a warning instead (#63457)
This updates the error thrown when both `provideZoneChangeDetection` and
`provideZonelessChangeDetection` are both used in the application
providers to be a warning instead. The reasons for this are twofold:

1. The migration we need for using zoneless by default isn't perfect and
   may add `provideZoneChangeDetection` when the zoneless provider
   exists. This change will prevent that from causing an error
2. There might be valid situations where a "default" is used in a common
   provider but that can be overridden by individal applications. In
   tests, we do allow this type of thing, where `initTestEnvironment`
   may have a default but individual tests might want to use a different
   one. The same logic might apply to applications in some environments.

PR Close #63457
2025-09-02 09:25:23 -07:00
Andrew Scott
4df3b17b47 refactor(core): Add internal option to require at least one cd provider (#63486)
This option would require one of either the zone or zoneless provider so
applications don't accidentally enable zoneless when the default flips if we
missed it in the migration. It'll be a hard failure at bootstrap, but that's a
lot easier to notice than zoneless getting turned on accidentally since
many things might just work.

PR Close #63486
2025-09-02 09:24:33 -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
Jessica Janiuk
ed3d1f246b 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:05 +00:00
arturovt
eee3e5a4df 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:06 -07:00
arturovt
538de86a72 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:54 -07:00
Alexander Melde
3a3bd364d1 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
fa0f11f6e8 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
a43057c059 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:32 -07:00
Jessica Janiuk
a0388409e3 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:07 -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
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
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
Jessica Janiuk
18c9352d21 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:15 -07:00
Matthieu Riegler
d16a992b12 refactor(core): remove the deprecated ImportedNgModuleProviders type. (#63277)
Use the `EnvironmentProviders` type instead

PR Close #63277
2025-08-22 11:22:22 -07:00
Matthieu Riegler
edbbbb1e44 refactor(core): remove NgProbeToken class (#63279)
This class served no purpose and was deprecated in by #51396

G3 also has no usage anymore.

PR Close #63279
2025-08-20 16:21:38 +00:00
Matthieu Riegler
d8bdf56145 refactor(core): remove deprecated PACKAGE_ROOT_URL token (#63274)
The symbol was deprecated by #51222 and already has no usages in g3.

PR Close #63274
2025-08-20 15:45:12 +00:00
Matthieu Riegler
239fe6f83e refactor(core): remove public symbol for defineInjectable (#63270)
This public symbol was deprecated in v8.
The private symbol `ɵɵdefineInjectable` remains available.

PR Close #63270
2025-08-20 15:44:14 +00:00
Jessica Janiuk
70afb41f8e 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
72ae1064fe docs: use correct closing quote in input and model import usage notes (#63237)
PR Close #63237
2025-08-19 12:33:22 +00:00
Shuaib Hasan Akib
6712456847 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:49 +00:00
Jessica Janiuk
a7cfb42c03 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:16 +00:00
cexbrayat
e9b2fe7ce5 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:17 +02:00
Matthieu Riegler
f9a38a4b73 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:45 -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