-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update origin * chore: update untranslated files * chore: migrate small changes * chore: migrate changes * chore: fix patches * chore: fix broken links * chore: fix broken link * chore: remove universal.md * chore: fix broken links
- Loading branch information
Showing
233 changed files
with
7,189 additions
and
6,978 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@name HTML content was altered after server-side rendering | ||
@category runtime | ||
@shortDescription HTML content was altered after server-side rendering | ||
|
||
@description | ||
Angular throws this error when it detects that the content generated by server-side rendering (SSR) was altered after the rendering. The process of hydration relies on the content to be untouched after SSR, which also includes whitespaces and comment nodes. Those whitespaces and comment nodes must be retained in the HTML generated by the SSR process. Learn more in the [Hydration guide](guide/hydration#constraints). | ||
|
||
@debugging | ||
|
||
Typically this happens in the following cases: | ||
* Some CDN providers have a built-in feature to remove whitespaces and comment nodes from HTML as an optimization. Please verify if there is such an option in CDN configuration and turn it off. | ||
* If you use custom post-processing of HTML generated by SSR (as a build step), make sure that this process doesn't remove whitespaces and comment nodes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@name Runtime Performance Warnings | ||
@category runtime | ||
@shortDescription Performance-harming image elements detected at runtime | ||
|
||
@description | ||
After an application is loaded, Angular checks included `<img>` elements for performance-harming misconfiguration. This warning can be triggered two ways: | ||
|
||
### Oversized images | ||
When images are loaded, the **intrinsic size** of the downloaded file is checked against the actual size of the image on the page. The actual size is calculated using the **rendered size** of the image with CSS applied, multiplied by the [pixel device ratio](https://web.dev/codelab-density-descriptors/#pixel-density). If the downloaded image is much larger (more than 1200px too large in either dimension), this warning is triggered. Downloading oversized images can slow down page loading and have a negative effect on [Core Web Vitals](https://web.dev/vitals/). | ||
|
||
### Lazy-loaded LCP element | ||
The largest contentful element on a page during load is considered the "LCP Element", which relates to [Largest Contentful Paint](https://web.dev/lcp/), one of the Core Web Vitals. Lazy loading an LCP element will have a strong negative effect on page performance. With this strategy, the browser has to complete layout calculations to determine whether the element is in the viewport before starting the image download. As a result, a warning is triggered when Angular detects that the LCP element has been given the `loading="lazy"` attribute. | ||
|
||
@debugging | ||
Use the image URL provided in the console warning to find the `<img>` element in question. | ||
### Ways to fix oversized images | ||
* Use a smaller source image | ||
* Add a [`srcset`](https://web.dev/learn/design/responsive-images/#responsive-images-with-srcset) if multiple sizes are needed for different layouts. | ||
* Switch to use Angular's built-in image directive ([`NgOptimizedImage`](https://angular.io/api/common/NgOptimizedImage)), which generates [srcsets automatically](https://angular.io/guide/image-directive#request-images-at-the-correct-size-with-automatic-srcset). | ||
### Ways to fix lazy-loaded LCP element | ||
|
||
* Change the `loading` attribute to a different value such as `"eager"`. | ||
* Switch to use Angular's built-in image directive ([`NgOptimizedImage`](https://angular.io/api/common/NgOptimizedImage)), which allows for easily [prioritizing LCP images](https://angular.io/guide/image-directive#step-4-mark-images-as-priority). | ||
|
||
### Disabling Image Performance Warnings | ||
Both warnings can be disabled individually, site-wide, using a provider at the root of your application: | ||
|
||
<code-example format="typescript" language="typescript"> | ||
providers: [ | ||
{ | ||
provide: IMAGE_CONFIG, | ||
useValue: { | ||
disableImageSizeWarning: true, | ||
disableImageLazyLoadWarning: true | ||
} | ||
}, | ||
], | ||
</code-example> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@name Disallowed function call inside reactive context | ||
@category runtime | ||
@shortDescription A disallowed function is called inside a reactive context | ||
|
||
@description | ||
A function that is not allowed to run inside a reactive context was called from within a reactive context. | ||
|
||
For example, an `effect` cannot be scheduled from within a `computed` or an actively executing effect. | ||
Avoid calling functions like `effect` as part of template expressions, as those execute in their own reactive context. | ||
|
||
Computed expressions are expected to be pure. | ||
Pure means that expression do not trigger any side effects. | ||
Side effects are operations like scheduling `afterRender`, creating a new `effect`, or subscribing to observables. | ||
|
||
Some operations are explicitly banned inside reactive contexts in order to avoid common pitfalls. | ||
As an example, using `afterRender` inside a `computed` will schedule new render hooks every time the computed expression evaluates. | ||
This is likely not intended and could degrade application performance. | ||
|
||
### Fixing the error | ||
|
||
This error guide is non-exhaustive. | ||
It captures a few common scenarios and how to address the error. | ||
|
||
#### `afterRender` | ||
Move the call for `afterRender` outside of the reactive context. | ||
|
||
A good place to schedule the after render hook is in the component's class constructor. | ||
Alternatively, use `untracked` to leave the reactive context and explicitly opt-out of this error. | ||
|
||
#### `effect` | ||
Move the call for `effect` outside of the reactive context. | ||
|
||
A good place to schedule an effect is in a `@Component`'s class constructor. | ||
|
||
#### `toSignal` | ||
Move the call for `toSignal` outside of the reactive context. | ||
|
||
```typescript | ||
result = computed(() => { | ||
const dataSignal = toSignal(dataObservable$); | ||
return doSomething(dataSignal()); | ||
}); | ||
``` | ||
|
||
can be refactored into: | ||
|
||
```typescript | ||
dataSignal = toSignal(dataObservable$); | ||
result = computed(() => doSomething(dataSignal())); | ||
``` | ||
|
||
Alternatively, if this is not possible, consider manually subscribing to the observable. | ||
|
||
As a last resort, use `untracked` to leave the reactive context. | ||
Be careful as leaving the reactive context can result in signal reads to be ignored inside `untracked`. | ||
|
||
@debugging | ||
|
||
The error message mentions the function that was unexpectedly called. | ||
Look for this function call in your application code. | ||
|
||
Alternatively, the stack trace in your browser will show where the function was invoked and where it's located. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.