Commit graph

3436 commits

Author SHA1 Message Date
Andrew Scott
971981e1df fix(core): TestBed.tick should ensure test components are synchronized (#61382)
This ensures that `TestBed.tick` updates any components created with
`TestBed.createComponent`, regardless of whether autoDetectChanges is
on.

PR Close #61382
2025-05-21 15:02:52 +00:00
Pawel Kozlowski
1123b314b1 refactor(core): consolidate TNode creation checks (#61563)
This change de-duplicates code executed during TNode creation
and reponsible for asserting a TNode index.

PR Close #61563
2025-05-21 13:49:32 +00:00
Pawel Kozlowski
a5a18ae191 refactor(core): minimize code in the element-like instructions (#61563)
Minor changes to the element and elementContainer instructions to
move as much code as possible out of those instructions.

PR Close #61563
2025-05-21 13:49:31 +00:00
arturovt
e7656b84b2 refactor(core): drop rxResource error messages (#61565)
Drops `rxResource` error messages in production and replaces with error codes.

PR Close #61565
2025-05-21 12:42:59 +00:00
arturovt
62185714b5 refactor(core): drop injection context assertion in production (#61564)
In other parts of the code, calls to the `assertInInjectionContext` function are guarded with `ngDevMode`. This change aligns these parts of the code with other implementations that drop such assertions in production.

PR Close #61564
2025-05-21 12:42:10 +00:00
Kristiyan Kostadinov
46af02395f fix(compiler): avoid conflicts between HMR code and local symbols (#61550)
Currently we construct the HMR replacement URL inline by calling into the native `URL` constructor. This can cause conflicts with user code that defines a symbol called `URL`.

These changes resolve the issue by moving the URL construction into a separate function. This has a secondary benefit of making the generated code easier to follow and allowing us to update the URL without changing the compiled code.

Fixes #61517.

PR Close #61550
2025-05-21 12:25:25 +00:00
arturovt
6bf6dbc37e fix(core): cleanup testability subscriptions (#61261)
This commit prevents leaking memory when the application is destroyed and subscriptions are still alive.

PR Close #61261
2025-05-21 12:06:23 +00:00
Matthieu Riegler
ef01d3c69e refactor(core): Merge R3TemplateRef implementation and TemplateRef interface (#61455)
This was an artifact of the Ivy migration.

PR Close #61455
2025-05-21 10:07:12 +00:00
Andrew Scott
1aa57857dd refactor(core): Remove _cdRefInjectingView from markForRefresh (#60918)
The code was not compatible with property renaming so it was always
using _lView. This didn't matter because they're always the same for the
only place the function is used. Casting to any would fix the
renaming problem but introduce a risk of getting "broken" by a refactor
that changes the private variable name. This change removes the
private member access entirely.

PR Close #60918
2025-05-21 09:46:49 +00:00
Matthieu Riegler
5a4ca62081 docs: fix info about descendants for content queries. (#61534)
- `descendants` option  is `true` for `contentChild`
- `descendants` option is `false` for `contentChildren`

PR Close #61534
2025-05-21 09:06:06 +00:00
Pawel Kozlowski
feb571ceaa refactor(core): expose enableProfiling() on from @angular/core (#61465)
This commit exposes the experimental enableProfiling() API that
enables Angular integration with the Chrome DevTools performance
panel. Previously this integration was exposed on the ng. namespace
only but there are legitimate cases where developers might want to
expose the integration earlier (ex.: bootstrap profiling).

PR Close #61465
2025-05-19 14:22:34 +00:00
Kristiyan Kostadinov
7a308ccc3b refactor(core): consolidate logic to determine whether node can be hydrated (#61409)
Several instructions were repeating the logic that checks if a specific can be hydrated. These changes move it into a common location.

PR Close #61409
2025-05-19 09:30:20 +00:00
Kristiyan Kostadinov
6783fb7eae refactor(core): consolidate element end instruction logic (#61409)
There was some identical logic between the `elementEnd` and `elementContainerEnd` instructions. These changes consolidate it.

PR Close #61409
2025-05-19 09:30:20 +00:00
Kristiyan Kostadinov
049fe82de6 refactor(core): consolidate element start logic (#61409)
The logic for the `elementStart` and `elementContainerStart` instructions was identical. These changes consolidate it into a single base instruction.

PR Close #61409
2025-05-19 09:30:20 +00:00
Kristiyan Kostadinov
d216ffedbd refactor(core): consolidate first create pass (#61409)
The first create pass for elements and containers was identical. These changes consolidate it to reduce code duplication.

PR Close #61409
2025-05-19 09:30:20 +00:00
Kristiyan Kostadinov
b785256b9e perf(core): avoid intermediate arrays in definition (#61445)
A minor performance improvement for `ɵɵdefineComponent` where the underlying `extractDefListOrFactory` call had a chain of `.map.filter` which meant that we were unnecessarily creating intermediate arrays just to filter out the null values. These changes switch to simple `for` loop to get around it.

PR Close #61445
2025-05-19 09:20:07 +00:00
Pawel Kozlowski
69984ef55d refactor(core): move the data store operation out of instructions (#61425)
The view data store operation is not an instruction and shouldn't be
located in the instructions folder.

PR Close #61425
2025-05-19 08:24:45 +00:00
Pawel Kozlowski
bf99954390 refactor(core): move i18n logic into its dedicated package (#61425)
Move the i18n-related logic out of the instructions folder into
the i18n-dedicated folder / package.

PR Close #61425
2025-05-19 08:24:45 +00:00
Kristiyan Kostadinov
7fa3203ee7 refactor(compiler): account for pipes without names (#61328)
Updates the compiler logic to account for pipe definitions that may not have names.

PR Close #61328
2025-05-19 08:24:06 +00:00
Matthieu Riegler
0995cb7756 refactor(core): cleanup after* option types (#61216)
The `phase` property of `AfterRenderOptions`  was removed in #60641.

PR Close #61216
2025-05-16 09:35:08 +00:00
Pawel Kozlowski
d9d9e42c23 fix(core): handle different DI token types in Chrome DevTools integration (#61333)
This small refactor makes the DI events reporting code more resiliant
with respect to finding names for different token types.

PR Close #61333
2025-05-15 10:15:32 -07:00
arturovt
a5db6c41d0 fix(core): enable stashing only when withEventReplay() is invoked (#61077)
This commit brings the necessary event replay code code in tree-shakable manner.

PR Close #61077
2025-05-14 10:35:57 -07:00
Paul Gschwendtner
b71c35a6b5 refactor: update packages/core:{core,src} to ts_project (#61275)
Updates `packages/core:core` and `packages/core/src/...` to `ts_project`
of `rules_js`.

PR Close #61275
2025-05-14 12:01:51 +00:00
Paul Gschwendtner
810b0a7e5c refactor: add explicit types for exports relying on inferred call return type (#61312)
As part of the Bazel toolchain migration we noticed that implicit types
generated by the TypeScript compiler sometimes end up referencing types
from other packages (i.e. cross-package imports).

These imports currently work just because the Bazel `ts_library` and
`ng_module` rules automatically inserted a `<amd-module
name="@angular/x" />` into `.d.ts` of packages. This helped TS figure
out how to import a given file. Notably this is custom logic that is not
occuring in vanilla TS or Angular compilations—so we will drop this
magic as part of the toolchain cleanup!

To improve code quality and keep the existing behavior working, we are
doing the following:

- adding a lint rule that reduces the risk of such imports breaking. The
  failure scenario without the rule is that API goldens show unexpected
  diffs, and types might be duplicated in a different package!

- keeping the `<amd-module` headers, but we manually insert them into
  the package entry-points. This should ensure we don't regress
  anywhere; while we also improved general safety around this above.

Long-term, isolated declarations or a lint rule from eslint-typescript
can make this even more robust.

PR Close #61312
2025-05-13 22:45:18 +00:00
Matthieu Riegler
dd25f3d20f refactor(core): remove USE_RUNTIME_DEPS_TRACKER_FOR_JIT flag. (#61265)
The code has been migrated in G3, this flag is no longer necessary.

PR Close #61265
2025-05-13 15:22:18 -07:00
Kristiyan Kostadinov
583b9a7be5 fix(core): missing useExisting providers throwing for optional calls (#61137)
Fixes that the runtime was throwing a DI error when attempting to inject a missing `useExisting` provider, despite the call being optional.

The problem was that when the provider has `useExisting`, we do a second `inject` call under the hood which didn't include the inject flags from the original call.

Fixes #61121.

PR Close #61137
2025-05-06 09:12:38 -07:00
Foysol Ahmed
5fe726dd45 docs: ViewContainerRef.createComponent jsdoc update (#61097)
Co-authored-by: Jessica Janiuk <1596273+thePunderWoman@users.noreply.github.com>
PR Close #61097
2025-05-02 07:57:10 -07:00
KryptonBD
0b6c8dc72d docs: ViewContainerRef.createComponent jsdoc update to reflect actual behavior (#61097)
Fixes #59918

PR Close #61097
2025-05-02 07:57:09 -07:00
Matthieu Riegler
f580318411 docs(docs-infra): Add version of introduction for APIs (#60814)
For new APIs we'll mention since when a particular API is in its current status (experimental, devPreview, stable)

fixes #49668

PR Close #60814
2025-05-02 07:51:33 -07:00
arturovt
d2cb0b9786 refactor(core): tree-shake getDirectiveDef error (#61075)
This commit (25cae4555a) introduced an error throw when the directive definition is not defined. We can guard it with `ngDevMode` and throw the error only in development mode.

PR Close #61075
2025-05-01 08:43:43 -07:00
Matthieu Riegler
c2c8b75d7b refactor(core): remove module bootstrap code when using standalone. (#59208)
This commit improves tree shaking in standalone apps.

PR Close #59208
2025-05-01 08:39:34 -07:00
Alan Agius
193bd7c54a fix(core): properly handle app stabilization with defer blocks (#61040)
Previously, the app was marked as stable prematurely. For more details, see https://github.com/angular/angular/issues/61038#issuecomment-2837917180

Closes: #61038

PR Close #61040
2025-04-30 12:37:02 -07:00
arturovt
624be2ef0c fix(core): prevent stash listener conflicts (#59635)
The stash event listener is a global function that might be unsafely overridden if multiple microfrontend applications exist on the page.

In this commit, we create a map of `APP_ID` to stash event listener functions. This map prevents conflicts because multiple applications might be bootstrapped simultaneously on the client (one rendered on the server and one rendering only on the client).

I.e., the code that might be used is:

```ts
// Given that `app-root` is rendered on the server
bootstrapApplication(AppComponent, appConfig);

bootstrapApplication(BlogRootComponent, appBlogConfig);
```

Two bootstrapped applications would conflict and override each other's code.

PR Close #59635
2025-04-30 08:53:06 -07:00
arturovt
b14fbe1497 refactor(core): tree-shake getNgModuleDef error (#60339)
Currently, the error thrown in `getNgModuleDef` is guarded by `throwIfNotFound`, which is only set to `true` when `ɵɵsetNgModuleScope` is called in production. In all other cases, `throwIfNotFound` is never used in production. This means that if NgModules aren't used, `getNgModuleDef` is never called with the second argument. We can split it into two functions to allow tree-shaking of the error when NgModules aren't used at all.

PR Close #60339
2025-04-30 08:50:52 -07:00
cexbrayat
52e2f0842d refactor(core): remove unused APP_EFFECT_SCHEDULER in effect code (#59679)
The `APP_EFFECT_SCHEDULER` Injection token is never used and not a public API.

PR Close #59679
2025-04-30 08:49:55 -07:00
vladboisa
a282f583ed docs: add link label & paragraph for correct display (#60708)
PR Close #60708
2025-04-30 08:18:07 -07:00
vladboisa
e4a667690a docs: add Security-DomSanitizer link in ElemnetRef&Renderer2 (#60708)
Renderer2 and ElementRef didn't mention the Security-DomSanitizer method, this will add clarity for potential user what to expect. Also swap deprecated "callout" class to docs-alert

Fixes #51208 , #46904

PR Close #60708
2025-04-30 08:18:07 -07:00
arturovt
8d82a39a60 fix(core): async EventEmitter error should not prevent stability (#61028)
This commit wraps the `fn` invocation with `try-finally`, ensuring that the pending task (added in [this commit](d5c6ee432f)) is always removed.

Prior to this commit, if a subscriber threw an error, it would prevent the application from becoming stable — though this shouldn't happen under normal scenarios because the error should be handled by the RxJS error handler or Angular's error handler.

Errors should not silently prevent the application from being rendered on the server.

PR Close #61028
2025-04-29 22:14:15 -07:00
Matthieu Riegler
e6a34277fc feat(devtools): defer blocks support (#60629)
This commit adds the support for defer block in the Angular DevTools.

@defer block are now visible in the directive tree and give access to defer & hydration details.

This feature also brings support of incrementation hydration.

PR Close #60629
2025-04-29 22:07:47 -07:00
Andrew Scott
3261d14391 refactor(core): NgZone.onError reports to application error handler (#60946)
This commit ensures that errors from the `NgZone.onError` subscription
in bootstrap are reported to the internal application error handler.
Practically speaking, this should not affect anything today, as the
application handler goes directly to the `ErrorHandler` from the root.
While TestBed installs an application error handler that rethrows,
`TestBed.createComponent` does not create components through this
bootstrap function.

PR Close #60946
2025-04-29 21:56:50 -07:00
Andrew Scott
c801c74c09 refactor(core): Remove zoneless change detection re-export (#61029)
removes the experimental re-export from zoneless provider

PR Close #61029
2025-04-29 10:31:18 -07:00
Pawel Kozlowski
d8fbb909ce feat(core): rename afterRender to afterEveryRender and stabilize (#60999)
This change renames the afterRender to afterEveryRender and marks the
renamed API as stable.

BREAKING CHANGE: afterRender was renamed to afterEveryRender.

PR Close #60999
2025-04-28 12:33:55 -07:00
Andrew Scott
7680a27f30 refactor(core): Ignore errors related to updating exhaustive check value (#61027)
this can happen if the injector is already destroyed, which can happen in tests that fail to clean up correctly

PR Close #61027
2025-04-28 10:16:01 -07:00
arturovt
77174680b2 refactor(core): tree-shake NOT_SET and EMPTY_CLEANUP_SET (#60979)
Adds `__PURE__` annotations to `NOT_SET` and `EMPTY_CLEANUP_SET` to enable tree-shaking, even if they are not referenced. These variables are not dropped when Angular is imported from a module that has `sideEffects` set to `true`.

PR Close #60979
2025-04-25 08:42:12 -07:00
Andrew Scott
e711f99d81 feat(core): move provideExperimentalCheckNoChangesForDebug to provideCheckNoChangesConfig (#60906)
This commit makes several changes changes to the
`provideExperimentalCheckNoChangesForDebug` API:

* Rename it
* Promote to dev preview
* Apply the exhaustive behavior to _all_ checkNoChanges runs
* Remove `useNgZoneOnStable` option. This wasn't found to be generally
  more useful than `interval`

fixes #45612

BREAKING CHANGE: `provideExperimentalCheckNoChangesForDebug` has several
breaking changes:
* It is renamed to `provideCheckNoChangesConfig`
* The behavior applies to _all_ checkNoChanges runs
* The `useNgZoneOnStable` option is removed. This wasn't found to be generally
  more useful than `interval`

PR Close #60906
2025-04-24 13:04:27 -07:00
Andrew Kushnir
c2987d8402 refactor(core): stop producing ng-reflect attributes by default (#60973)
BREAKING CHANGE:

This commit deprecates `ng-reflect-*` attributes and updates the runtime to stop producing them by default. Please refactor application and test code to avoid relying on `ng-reflect-*` attributes.

To enable a more seamless upgrade to v20, we've added the `provideNgReflectAttributes()` function (can be imported from the `@angular/core` package), which enables the mode in which Angular would be producing those attribites (in dev mode only). You can add the `provideNgReflectAttributes()` function to the list of providers within the bootstrap call.

PR Close #60973
2025-04-24 10:07:35 -07:00
Alex Rickabaugh
d0c9a6401a refactor(core): rename resource's request to params (#60919)
As decided in the resource RFC, this commit renames the `request` option of
a resource to `params`, including the subsequent argument passed to the
loader. It also corrects the type in the process to properly allow narrowing
of the `undefined` value.

Fixes #58871

PR Close #60919
2025-04-23 19:34:50 +00:00
Alex Rickabaugh
d8ca560a15 refactor(core): convert ResourceStatus to a string type (#60919)
An outcome of the Resource RFC was that we should use string constants for
communicating the resource status instead of an enum. This commit converts
`ResourceStatus` accordingly.

PR Close #60919
2025-04-23 19:34:50 +00:00
arturovt
0ac949c266 fix(core): do not run change detection on global error events (#60944)
This commit wraps the `error` and `unhandledrejection` event listeners so they are installed outside of the Angular zone, because otherwise they trigger change detection whenever the event callbacks are invoked.

PR Close #60944
2025-04-23 15:17:28 +02:00
Andrew Scott
953c4b2580 feat(core): Move zoneless change detection to dev preview (#60748)
This commit moves zoneless from experimental to developer preview.

* Update tag on provider API
* Remove "experimental" from provider name
* Move documentation from "experimental features" to "Best practives ->
  Performance" (at least temporarily until there is a better place)

BREAKING CHANGE: `provideExperimentalZonelessChangeDetection` is
renamed to `provideZonelessChangeDetection` as it is now "Developer
Preview" rather than "Experimental".

PR Close #60748
2025-04-23 11:47:56 +02:00