Adds support for `getEncodedSemanticClassifications` to the language service.
The service now classifies components in a template as the `class` type.
PR Close#60260
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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