Commit graph

5634 commits

Author SHA1 Message Date
arturovt
c4dd258658 fix(core): avoid injecting ErrorHandler from a destroyed injector (#61886)
This commit prevents lazy injection of the internal `ErrorHandler` from a destroyed injector, as it would result in another "destroyed injector" error.

PR Close #61886
2025-06-24 14:13:34 +00:00
Andrew Scott
737b35b684 feat(core): Add destroyed property to EnvironmentInjector (#61951)
Similar to `DestroyRef`, this adds the `destroyed` property to
`EnvironmentInjector`. It also has the ability to register callbacks with
`onDestroy`, which throws if `destroyed` is already `true`.

This also omits the bit about whether those callbacks have executed
since I realized the property is set to `true` before executing the
callbacks.

PR Close #61951
2025-06-24 14:09:10 +00:00
arturovt
21dfbf3ada refactor(core): drop injection context assertion in production (#62038)
Drops `assertInInjectionContext` call in production in `afterNextRender`.

PR Close #62038
2025-06-24 12:24:09 +00:00
Kristiyan Kostadinov
3eee19d892 fix(core): unable to retrieve defer blocks in tests when component injects ViewContainerRef (#62156)
Fixes that `getDeferBlocks` wasn't accounting for the case where a component might be injecting `ViewContainerRef`. When that happens, an additional wrapper is introduced that needs to be accounted for when traversing the tree.

Fixes #62047.

PR Close #62156
2025-06-23 14:24:46 +02:00
Kristiyan Kostadinov
6b5e6b7ff7 refactor(compiler): always generate DOM-only templates for blocks (#62096)
Block templates can't have directives so we can always generate them as DOM-only.

PR Close #62096
2025-06-23 14:24:09 +02:00
Kristiyan Kostadinov
3afd3046d7 refactor(compiler): track whether component has directive dependencies (#62096)
Adds a field to the directive's metadata tracking whether it has directive dependencies. Knowing this will allow the pipeline to decide whether to produce DOM-only or full instructions.

PR Close #62096
2025-06-23 14:24:09 +02:00
Kristiyan Kostadinov
8e5b70f80b refactor(core): expose DOM-only instructions to the compiler (#62096)
Makes it possible for the compiler to reference DOM-only instructions.

PR Close #62096
2025-06-23 14:24:09 +02:00
Kristiyan Kostadinov
96b0295f12 refactor(core): properly handle local references in DOM-only instructions (#62096)
Fixes that local references weren't working correctly in DOM-only instructions.

PR Close #62096
2025-06-23 14:24:09 +02:00
Kristiyan Kostadinov
0dcf230d52 feat(compiler): add support for new binary assignment operators (#62064)
Updates the remainder of the compiler to handle the new assignment operators and sets up more tests, including for the runtime.

PR Close #62064
2025-06-23 14:23:29 +02:00
Andrew Scott
fa5ae9228d refactor(core): update FakeNavigation to the latest spec (#62017)
Spec updates are in https://github.com/whatwg/html/pull/10919

For the most part, the updates revolve around the deferred commit
handling (with precommitHandler). Updates to redirect allow more
options. A committed promise now exists on the transition since commits
can be delayed. Tests were made zoneless for easier debugging and
timeouts were reduced.

PR Close #62017
2025-06-19 15:10:41 +02:00
Angular Robot
0cd6f363ca build: update cross-repo angular dependencies (#62079)
See associated pull request for more information.

PR Close #62079
2025-06-19 10:12:19 +02:00
Joey Perrott
557ac51c32 build: migrate to using new jasmine_test (#62131)
Migrate additional targets to jasmine_test

PR Close #62131
2025-06-19 10:06:27 +02:00
Kristiyan Kostadinov
34adfdea82 fix(migrations): more robust trailing comma removal in unused imports migration (#62118)
Fixes the following issues with the logic in the unused imports migration that deals with trailing commas:
1. It was generating overlapping text ranges which can break internally.
2. It wasn't handling some cases that produce trailing commas.

PR Close #62118
2025-06-18 15:57:12 +02:00
Andrew Scott
572c32a038 fix(core): Wrap ErrorEvent with no error property (#62081)
This commit updates the global error listener to wrap the global ErrorEvent in a new Error with cause
if the error property is undefined.

fixes #62078

PR Close #62081
2025-06-18 13:57:24 +02:00
Joey Perrott
3a0cfd544d build: migrate to using new jasmine_test (#62086)
Use the new jasmine_test based on rules_js instead of jasmine_node_test from rules_nodejs

PR Close #62086
2025-06-18 08:27:26 +02:00
Kristiyan Kostadinov
2e0c98bd3f feat(core): support bindings in TestBed (#62040)
Adds support for passing in `Binding` objects into `TestBed.createComponent`. This makes it easier to test components by avoiding the need to create a wrapper component. Furthermore, it keeps the behavior consistent between tests and the actual app. For example, given a custom checkbox that looks like this:

```typescript
@Component({
  selector: 'my-checkbox',
  template: '...',
  host: {'[class.checked]': 'isChecked()'}
})
export class MyCheckbox {
  isChecked = input(false);
}
```

A test for the `isChecked` input would look something like this:

```typescript
it('should toggle the checked class', () => {
  @Component({
    imports: [MyCheckbox],
    template: '<my-checkbox [isChecked]="isChecked"/>',
  })
  class Wrapper {
    isChecked = false;
  }

  const fixture = TestBed.createComponent(Wrapper);
  const checkbox = fixture.nativeElement.querySelector('my-checkbox');
  fixture.detectChanges();
  expect(checkbox.classList).not.toContain('checked');

  fixture.componentInstance.isChecked = true;
  fixture.detectChanges();
  expect(checkbox.classList).toContain('checked');
});
```

Whereas with the new API, the test would look like this:

```typescript
it('should toggle the checked class', () => {
  const isChecked = signal(false);
  const fixture = TestBed.createComponent(MyCheckbox, {
    bindings: [inputBinding('isChecked', isChecked)]
  });
  const checkbox = fixture.nativeElement.querySelector('my-checkbox');
  fixture.detectChanges();
  expect(checkbox.classList).not.toContain('checked');

  isChecked.set(true);
  fixture.detectChanges();
  expect(checkbox.classList).toContain('checked');
});
```

PR Close #62040
2025-06-17 11:49:27 +02:00
Joey Perrott
1182fe7053 build: migrate to usages of @devinfra// instead of @npm//@angular/build-tooling (#62050)
Use workspace imported devinfra deps instead of npm dep

PR Close #62050
2025-06-16 10:23:30 +02:00
arturovt
31da435854 fix(core): inject APP_ID before injector is destroyed (#61885)
In this commit, we request `APP_ID` outside the `onDestroy` callback because the injector might already be in a destroyed state when the callback runs.

PR Close #61885
2025-06-12 15:56:51 +02:00
Angular Robot
1fcf67cb17 build: update cross-repo angular dependencies (#62006)
See associated pull request for more information.

PR Close #62006
2025-06-12 15:55:19 +02:00
Matthieu Riegler
4040a6ba5d refactor(migrations): support local string tokens for inject migration (#62013)
The `localTypeChecker` allows us to at least support locally defined strings in addition to string literals.

PR Close #62013
2025-06-12 15:53:20 +02:00
Michael Berger
28484cbe0f docs(core): correct standalone jsdocs (#62025)
PR Close #62025
2025-06-12 15:51:23 +02:00
Jessica Janiuk
8424b3bcd5 fix(core): Fixes template outlet hydration (#61989)
Projected nodes were missing ssrId information and were skipping annotating template information, which caused templates to be destroyed and recreated rather than hydrated.

fixes: #50543

PR Close #61989
2025-06-12 12:53:21 +02:00
Paul Gschwendtner
61fb6e79ff build: fix hermetic execution of packages/core/test/... (#62027)
Due to a bug that is currently in progress of being resolved in the
`rules_js` toolchain (see:
https://github.com/aspect-build/rules_js/issues/362), we were seeing
subtle differences between `main` and PRs/local builds as RBE is a
strict sandbox environment while the normal linux/darwin sandbox isn't
necessarily.

This commit fixes the issue by avoiding the interop targets that don't
bring in the actual transitive node modules.

PR Close #62027
2025-06-12 12:16:56 +02:00
Paul Gschwendtner
a137746110 build: migrate packages/core/test to new jasmine_test rule (#61902)
Migrates `packages/core/test` to the new `jasmine_test` rule. As part of
this, we are also removing an unnecessary/unused test fixture.

PR Close #61902
2025-06-12 10:00:09 +02:00
Joey Perrott
dfbdbbe882 refactor: use zone.js from npm instead of packages/zone.js throughout repo (#61977)
Use zone.js from npm isntead of from the repo going forward

PR Close #61977
2025-06-10 12:02:03 -07:00
Carolina
e1bd13d854 docs: rework programmatically rendering components section to mention @defer (#61763)
PR Close #61763
2025-06-10 12:01:29 -07:00
Taygan Caldwell
6097184711 refactor(core): Delete createSignalTuple (#61907)
Delete createSignalTuple because it is no longer needed. creatSignal has the same behavior.

PR Close #61907
2025-06-06 13:46:16 +02:00
Angular Robot
78c417ace1 build: update cross-repo angular dependencies (#61910)
See associated pull request for more information.

PR Close #61910
2025-06-06 10:30:47 +02:00
Joey Perrott
9354efc86a build: remove unnecessary zone.js dep from various build targets (#61901)
Remove unnecessary zone.js dep from various build targets

PR Close #61901
2025-06-05 09:12:27 -07:00
arturovt
4f89f6ea90 refactor(platform-browser): drop isPlatformServer in SharedStylesHost (#61685)
Replaces `isPlatformServer` with `ngServerMode` in `SharedStylesHost`.

PR Close #61685
2025-06-05 14:53:35 +02:00
kristilw
3aa933acb7 fix(core): components marked for traversal resets reactive context (#61663)
when marked for traversal the reactive context has to be set to null to avoid inheriting the reactive context of the parent component

PR Closes #61662

PR Close #61663
2025-06-05 14:49:01 +02:00
kristilw
ee6388d2a0 refactor(core): update tests to use standalone (#61663)
update tests to use standalone components for easier test setup

PR Close #61663
2025-06-05 14:49:01 +02:00
Taygan Caldwell
935ce0e0d9 refactor(core): export signal setter and updater types for wiz (#61714)
Export signal setter and updater types for Wiz to use

PR Close #61714
2025-06-05 12:57:23 +02:00
arturovt
e81ea0c3dd fix(core): unregister onDestroy in outputToObservable (#61882)
We should remove the `onDestroy` listener once subscription is unsubscribed because components might not be destroyed yet, but they still would capture subscribers.

PR Close #61882
2025-06-05 11:16:57 +02:00
arturovt
080b3687d3 fix(core): unregister onDestroy in ResourceImpl when destroy() is called (#61870)
This commit unregisters the `onDestroy` listener when `destroy()` is called on the `ResourceImpl`. This prevents memory leaks and ensures that the resource reference is not captured in the destroy callback after it has already been destroyed.

PR Close #61870
2025-06-04 14:23:13 -04:00
Andrew Scott
8163a8995e feat(core): Add destroyed property on DestroyRef (#61849)
Since `DestroyRef.onDestroy` throws if the `DestroyRef` is already
destroyed, there is a need to be able to tell if it is already destroyed
before attempting to register a callback.

PR Close #61849
2025-06-04 14:14:55 -04:00
AleksanderBodurri
9a8f4f14aa fix(core): properly handle the case where getSignalGraph is called on a componentless NodeInjector (#60772)
Previously this would throw an error on the assertLView when we try to discover the templateLView.

Now this properly returns null for the template consumer and continues discovering other effects on the injector.

PR Close #60772
2025-06-04 12:16:47 -04:00
Andrew Scott
2bd3a43028 fix(core): takeUntilDestroyed completes immediately if DestroyRef already destroyed (#61847)
Adds fix directly for `takeUntilDestroyed` to unsubscribe when already
destroyed instead of putting
synchronous behavior on `DestroyRef.onDestroyed` callback as in #58008

fixes #54527

PR Close #61847
2025-06-04 12:14:15 -04:00
cexbrayat
dcfbe6c811 refactor(core): use RefactorStreamItem type in rxResource (#59887)
The `ResourceStreamItem` was introduced in #59851 and can be used to simplify the `rxResource` code.

PR Close #59887
2025-06-04 11:45:04 -04:00
Taygan Caldwell
ed0a0a6d78 refactor(core): Refactor createSignal to return a tuple contain getter, setter, and updater (#61705)
Refactor createSignal to return a tuple instead of a signal getter. createSignalTuple will be removed in a follow up pr once createSignalTuple usages in google3 are migrated to createSignal.

PR Close #61705
2025-06-04 10:46:11 -04:00
arturovt
f37b2f7650 fix(core): unregister onDestroy when observable errors in toSignal (#61596)
The observable terminates immediately when `error` is called, and no further emissions or completion notifications occur. Thus, we have to remove the listener in both the `error` and `complete` notifications.

PR Close #61596
2025-06-04 09:36:41 -04:00
Paul Gschwendtner
d081ef9b06 build: replace all ng_package with new rule from rules_angular (#61843)
Replaces all `ng_package` rule with the new rule from `rules_angular`.

PR Close #61843
2025-06-04 09:13:41 +00:00
Paul Gschwendtner
f779c95e6f build: migrate integration and primitives/defer to ts_project (#61843)
Migrates remaining `ts_project` targets (excluding zone.js) to
`ts_project`.

PR Close #61843
2025-06-04 09:13:41 +00:00
AleksanderBodurri
3a9a70de08 refactor(compiler-cli): implement transform to determine debugName from signal functions (#57348)
Implements a compiler transform that attempts to statically analyze variable names and apply them to usages of signal functions like signal, computed, effect, etc.

PR Close #57348
2025-06-03 20:34:12 -04:00
Kristiyan Kostadinov
eb43e9242d refactor(compiler): account for new assignment AST (#61682)
Reworks the places that were depending on `PropertyWrite` and `KeyedWrite` to account for the new AST structure.

PR Close #61682
2025-06-03 11:08:50 -04:00
Angular Robot
23ad649908 build: update cross-repo angular dependencies (#61703)
See associated pull request for more information.

PR Close #61703
2025-06-03 10:34:03 -04:00
Matthieu Riegler
9630d79d1a refactor(migrations): keep the control flow migration as ng generate. (#61773)
this way `ng generate @angular/core:control-flow` which has been fairly documented, remains valid.

PR Close #61773
2025-06-03 07:12:59 -04:00
Kristiyan Kostadinov
3c5ab643e4 build: add missing symbol (#61783)
Fixes a broken symbol test.

PR Close #61783
2025-05-30 13:34:45 -04:00
Andrew Kushnir
5fce27d63f fix(core): produce an error when incremental hydration is expected, but not configured (#61741)
This commit updates runtime logic to produce an error when there are some `@defer` blocks with `hydrate` triggers, but the incremental hydration is not enabled via `withIncrementalHydration()`. Previously the check was only detecting the case when `withIncrementalHydration()` is present on the server, but missing on the client. With the change in this commit, the check would be performed on the server as well.

PR Close #61741
2025-05-30 11:14:22 -04:00
Kristiyan Kostadinov
bb88b3f22f fix(migrations): avoid trailing whitespaces in unused imports migration (#61698)
Follow-up to #61674 where we were leaving behind some whitespace, e.g. `[One, Two, Three]` would turn into `[One ]`. These changes only preserve the whitespace if the node is preceded by a newline.

This wasn't caught by tests, because they were stripping away whitespaces before asserting. I've also reworked the tests to be sensitive to formatting changes.

PR Close #61698
2025-05-30 11:07:20 -04:00