Commit graph

3177 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
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
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
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
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
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
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
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
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
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
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
Kristiyan Kostadinov
3c5ab643e4 build: add missing symbol (#61783)
Fixes a broken symbol test.

PR Close #61783
2025-05-30 13:34:45 -04:00
Kristiyan Kostadinov
75b7cd4cac build: update bundle goldens (#61718)
Updates out of date goldens.

PR Close #61718
2025-05-30 09:53:37 -04:00
Kristiyan Kostadinov
cb8ff45c0c refactor(core): move directive logic out of shared element code (#61718)
Moves the logic that deals with matching and instantiating directives out of the shared element instruction code.

PR Close #61718
2025-05-30 09:53:36 -04:00
Paul Gschwendtner
9d7768ccd6 build: rework benchmarks and examples in modules/ to new optimization rule (#61566)
We are dropping the custom ESBuild and Terser pipeline from dev-infra
and instead leverage the Angular CLI directly. This commit adjusts
the benchmarks to use this new rule.

PR Close #61566
2025-05-29 14:39:11 -04:00
Paul Gschwendtner
b80957d1c5 build: adjust bundling tests to use Angular CLI (#61566)
Instead of dev-infra maintaining a custom ESBuild + Terser pipeline that
tries to emulate the Angular CLI, we are switching the bundling core
tests to a new rule that really leverages the Angular CLI.

This involves some file renames and small adjustments. In addition, we
leverage the updated symbol tracking rule to output new goldens that can
work with multiple bundle files (as generated by the Angular CLI;
especially with defer and its "lazy" chunks).

PR Close #61566
2025-05-29 14:39:11 -04:00
Paul Gschwendtner
7bc39a883d build: fix app_bundle rule after migrating packages/compiler (#61566)
The `app_bundle` rule does not work after the migration of
`packages/compiler` to `ts_project` because the `.mjs` extensions are
now missing in the non npm-package output.

This causes runtime errors as `.js` is not recognized as ESM. Switching
to the real npm package for usage, fixes this issue.

PR Close #61566
2025-05-29 14:39:11 -04:00
Matthieu Riegler
fe03aa09ad Revert "fix(core): call DestroyRef on destroy callback if view is destroyed (#58008)" (#61625)
This reverts commit 5f7f04634f.

PR Close #61625
2025-05-27 15:21:20 -07:00
arturovt
9a9511ace8 refactor(platform-browser): replace isPlatformServer with ngServerMode (#59496)
In this commit, we switch from using the `isPlatformServer` runtime call to the `ngServerMode`.

Note: constructors haven't been touched in order to prevent any breaking changes for the public API.

PR Close #59496
2025-05-26 11:14:27 +00:00
Kristiyan Kostadinov
289ae50c56 refactor(core): replace propertyInterpolateX with property (#61639)
Replaces the `propertyInterpolateX` instructions with calls to `property` and the `interpolate` helper. This allows us to drop the dedicated interpolation instructions and simplify the runtime for future work.

PR Close #61639
2025-05-26 09:21:23 +00:00
Joey Perrott
687e01865f build: migrate platform-server to rules_js (#61589)
Migrate platform-server to use ts_project and ng_project.

PR Close #61589
2025-05-22 11:35:55 -07:00
Maciej Sawicki
905194fa57 fix(core): reading resource value after reload in the error state (#61441)
When the resource is loading after reloading from the error state reading `Resource.value()` would return the default value instead of throwing an error.
This change prevents `Resource.hasValue()` from throwing an error in such a case.

PR Close #61441
2025-05-21 12:06:40 -07:00
Maciej Sawicki
b35396345c fix(core): getting resource value throws an error instead of returning undefined (#61441)
When there is an underlying error state it would not be possible to swallow the error with:
`computed(() => res.value()?.inner);`

PR Close #61441
2025-05-21 12:06:40 -07:00
Maciej Sawicki
05eb028c7a fix(core): narrow error type for resources API (#61441)
`Resource.error` used to return `unknown`. Now it's `Error | undefined`.
For non-`Error` types they are encapsulated with the `Error` type.

PR Close #61441
2025-05-21 12:06:40 -07:00
Kristiyan Kostadinov
32ae421526 refactor(compiler): replace attribute interpolation instructions (#61557)
Replaces the attribute interpolation instructions with `attribute` plus the new `interpolateX` instruction. This allows to reduce our overall instruction footprint.

PR Close #61557
2025-05-21 15:13:47 +00:00
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
Matthieu Riegler
dba912dd07 refactor(platform-browser): replace platform-browser-dynamic with platform-browser (#61498)
The former isn't needed anymore and is now deprecated.

PR Close #61498
2025-05-21 14:01:49 +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
Paul Gschwendtner
082cc5579d build: migrate all ng_module in packages/core/test (#61472)
Migrates all `ng_module` to `ng_project` in `packages/core/test/`.

PR Close #61472
2025-05-20 10:00:43 +00:00
Paul Gschwendtner
8ead19fe00 build: migrate all ts_library in packages/core/test (#61472)
This commit migrates all `ts_library` in `package/core/test` to
`ts_project`, and fixes deep module, or relative imports inside.

PR Close #61472
2025-05-20 10:00:43 +00:00
Andrew Scott
f182886ce5 refactor(core): Disallow autoDetectChanges(false) in zoneless (#61430)
This removes the ability to use `autoDetectChanges(false)` when
`provideZonelessChangeDetection` is used.

PR Close #61430
2025-05-20 08:49:06 +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
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
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
Kristiyan Kostadinov
f6bb6cc09a build: set up runtime tests for selectorless (#61307)
Sets up the tests for the selectorless runtime so that we can easily start writing them when we get to it. The tests need to be AoT compiled so they're defined as a separate target from the other `acceptance` tests.

PR Close #61307
2025-05-14 11:06:22 +02:00
Matthieu Riegler
3eeea56ba0 refactor(core): remove compileComponents invocations (#61032)
Those weren't necessary.

PR Close #61032
2025-05-09 10:27:14 -07:00