Commit graph

13676 commits

Author SHA1 Message Date
Jannik Lassahn
b489f9fa8f refactor(language-service): add methods for decoding classifications to public api (#62251)
Add methods for decoding classifications to public api for use in the
language server

PR Close #62251
2025-06-25 09:46:53 +00:00
SkyZeroZx
9791ab1b6f feat(http): Add support for fetch request cache and priority options (#61766)
Enhances Angular HttpClient requests with Fetch API cache and priority options to optimize loading and performance.

PR Close #61766
2025-06-25 09:46:21 +00:00
SkyZeroZx
73269cf5ce feat(http): add keepalive support for fetch requests in httpResource (#61833)
This commit adds support for the Fetch API's keepalive option when using httpResource with the withFetch provider

PR Close #61833
2025-06-25 09:14:26 +00:00
Jannik Lassahn
20c1f991e6 feat(language-service): add semantic tokens for templates (#60260)
Adds support for `getEncodedSemanticClassifications` to the language service.
The service now classifies components in a template as the `class` type.

PR Close #60260
2025-06-24 16:27:46 +00:00
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
7600bec71d fix(router): handle scrollRestoration error in restricted environments (#62186)
In this commit, setting `window.history.scrollRestoration` is wrapped in a try-catch block to prevent `SecurityError` exceptions in restricted contexts such as:

- sandboxed iframes
- partially navigated or inactive windows
- test runners, extensions, or content previews

If an error occurs, a runtime warning with error code [2400] is logged to the console. This avoids breaking app initialization and improves cross-browser safety.

Unfortunately, it's not possible to perform any end-to-end testing of this fix.

PR Close #62186
2025-06-24 12:24:43 +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
Alan Agius
8d049f533a build: update jest monorepo to v30 (#62234)
See associated pull request for more information.

Closes #61980 as a pr takeover

PR Close #62234
2025-06-24 10:49:30 +00:00
Andrew Scott
9833d9ea47 feat(router): Run loadComponent and loadChildren functions in the route's injection context (#62133)
This updates the loader code to run the `loadComponent` and
`loadChildren` functions in the appropriate injection context for the
route.

A primary motiviation for this feature is to bring `loadChildren` with
standalone components and the routes array to
feature-parity with what was possible when using `loadChildren` and a
module that provided routes via the `ROUTES` token and a factory
function (which would have injection context).

fixes #51532

PR Close #62133
2025-06-24 09:39:48 +00:00
Angular Robot
7d2e942653 build: lock file maintenance (#62202)
See associated pull request for more information.

PR Close #62202
2025-06-24 09:37:35 +00:00
Joey Perrott
36d5048429 build: migrate final non-zone.js jasmine tests (#62169)
Migrate the final remaining non-zone.js package jasmine tests to the new toolchain

PR Close #62169
2025-06-24 08:46:39 +00:00
Kristiyan Kostadinov
a40abf09f1 build: fix failing test (#62214)
Fixes a test that's failing, because a few PRs landed at the same time.

PR Close #62214
2025-06-23 15:38:18 +02:00
Kristiyan Kostadinov
d25a6a0120 fix(compiler-cli): handle initializer APIs wrapped in type casts (#62203)
Fixes that the logic recognizing initializer APIs didn't account for the expression being wrapped in an `as` expresion or in a parenthesized expression. This was already accounted for in the diagnostic so these changes align the behavior between them.

Fixes #62197.

PR Close #62203
2025-06-23 14:26:05 +02:00
Kristiyan Kostadinov
223279eaf5 refactor(compiler): remove TranslationParseError (#62160)
Replaces the `TranslationParseError` with `ParseError` since it wasn't adding much on top of `ParseError`.

PR Close #62160
2025-06-23 14:25:28 +02:00
Kristiyan Kostadinov
d1cb44d60a refactor(compiler): remove I18nError (#62160)
Removes the `I18nError` class since it wasn't being used for anything aside from a wrapper.

PR Close #62160
2025-06-23 14:25:28 +02:00
Kristiyan Kostadinov
982f90ff35 refactor(compiler): remove TokenError (#62160)
Replaces the `TokenError` class with `ParseError` to reduce the number of error classes we need to maintain.

PR Close #62160
2025-06-23 14:25:28 +02:00
Kristiyan Kostadinov
bcde744e0a refactor(compiler): remove _ControlFlowError (#62160)
Removes the `_ControlFlowError`, because its name is confusing and it's just a wrapper around `TokenError`.

PR Close #62160
2025-06-23 14:25:28 +02:00
Kristiyan Kostadinov
5e9707dc84 refactor(compiler): consolidate error classes (#62160)
Currently we have a `ParserError` that is used for the expression parser and a `ParseError` that is used everywhere else. These changes consolidate them into the `ParseError` to avoid confusion and make it easier to add more context in the future.

PR Close #62160
2025-06-23 14:25:28 +02: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
2b4b98ded6 refactor(compiler): produce DOM-only instructions (#62096)
Reworks the compiler so that it produces DOM-only instructions and updates the relevant tests.

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
Kristiyan Kostadinov
998b00e62f refactor(compiler): implement new binary operators in output AST (#62064)
Updates the output AST to support the new set of binary operators.

PR Close #62064
2025-06-23 14:23:29 +02:00
Kristiyan Kostadinov
0213cd23ff refactor(compiler): support new assignment operators in expression parser (#62064)
Updates the expression parser to account for the new assignment operators that were added to the lexer.

PR Close #62064
2025-06-23 14:23:29 +02:00
Kristiyan Kostadinov
cf3b583b43 refactor(compiler): support more assignment operators in lexer (#62064)
Adds support for the `+=`, `-=`, `*=`, `/=`, `%=`, `**=`, `&&=`, `||=` and `??=` assignment operators to the lexer.

PR Close #62064
2025-06-23 14:23:28 +02:00
Andrew Scott
c5fcb9d7f4 test(router): Add test for empty path redirect and no match (#62176)
this was discovered during some other work in the router that unintentionally changed this behavior

PR Close #62176
2025-06-23 14:18:12 +02:00
ivanwonder
ac1d400306 refactor(language-service): resolve module specifier for a directive exported by multiple different files (#62100)
When providing the code action for the directive that is exported by multiple modules
in different files, the directive must save all the TS completion entry data
for every module to compute the module specifier.

When providing a completion item, because the LS only supports displaying one directive
at a time, the first one will be picked.

PR Close #62100
2025-06-23 14:16:30 +02:00
Kristiyan Kostadinov
f364d5020d build: remove unused dependency (#62206)
Removes the `google-closure-compiler` dependency that keeps getting updated by the bot, even though we don't actually use it.

PR Close #62206
2025-06-23 13:14:57 +02:00
Andrew Scott
9cc7c5f38e test(router): Update timeouts to reduce firefox flakiness (#62141)
This updates the timeouts in a couple flakey router tests. Ideally we can use the jasmine
auto ticking as soon as tests are migrated to web test runner and we are on the latest
version of jasmine

PR Close #62141
2025-06-20 14:39:35 -07:00
Kristiyan Kostadinov
ed5062a91c fix(compiler-cli): add suggestion when pipe is missing (#62146)
Adds some suggestions for potential pipes to be imported when raising the missing pipe diagnostic.

Fixes #62136.

PR Close #62146
2025-06-20 10:30:04 +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
Andrew Scott
900cd37f68 fix(upgrade): Make zoneless work with hybrid apps (#61660)
Hybrid applications trigger a digest when `onMicrotaskEmpty` emits so
that the AngularJS app can run its lifecycle when the Angular app does. For
ZoneJS applications, this is effectively after every render/app tick. This change
updates the code to use `afterEveryRender` instead.

fixes #61640

PR Close #61660
2025-06-19 14:25:48 +02:00
ivanwonder
5d2e85920e feat(language-service): support to fix missing required inputs diagnostic (#50911)
Support to add the missing required inputs into the element and append
after the last attribute of the element.

But it skips the structural directive shorthand attribute. For example,
`<a *ngFor=""></a>`, its shorthand is `<ng-template ngFor>`, the `valueSpan`
of the `ngFor` is empty, and the info is lost, so it can't use to insert
the missing attribute after it.

PR Close #50911
2025-06-19 10:13:26 +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
Joey Perrott
908c6c1d30 build: split compiler-cli compliance test into more shards (#62119)
It seems that new jasmine_test runner times out with the larger size shards, by splitting into double the shards the test consistently passes as expected

PR Close #62119
2025-06-18 18:20:22 +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
Angular Robot
5885eca899 build: update dependency google-closure-compiler to v20250615 (#62114)
See associated pull request for more information.

PR Close #62114
2025-06-18 10:46:07 +02:00
Angular Robot
a06c7228ad build: lock file maintenance (#62062)
See associated pull request for more information.

PR Close #62062
2025-06-18 09:32:26 +02:00
Ben Hong
5f6e336b21 docs: add dedicated redirecting routes guide (#62005)
docs: update language block

Co-authored-by: Matthieu Riegler <kyro38@gmail.com>

docs: enhance redirects function docs

docs: fix future tense usage

docs: update phrasing to be present tense

docs: update redirect guides to use better phrasing and examples

docs: fix typo on code example

Co-authored-by: Andrew Scott <atscott01@gmail.com>

docs: fix typo in code example

Co-authored-by: Andrew Scott <atscott01@gmail.com>

docs: update syntax of code snippet

Co-authored-by: Andrew Scott <atscott01@gmail.com>

docs: update description on redirect function and api docs

PR Close #62005
2025-06-18 09:07:32 +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
Matthieu Riegler
2e3925a65c refactor(localize): add tripleslash type of Application builder (#62037)
Prior to this change, the triple slash directive was only added on the angular-devkit application builder.

Fixes #61968

PR Close #62037
2025-06-15 12:39:36 +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