Skip to content

Commit ef1a0b8

Browse files
ricardochlSplaktar
authored andcommitted
feat: update origin to Angular v18.0.1
1 parent 084a8e9 commit ef1a0b8

File tree

77 files changed

+1066
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1066
-351
lines changed

adev-es/src/app/sub-navigation-data.ts

Lines changed: 170 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import {NavigationItem} from '@angular/docs';
1010

11+
// These 2 imports are expected to be red because they are generated a build time
1112
import FIRST_APP_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/first-app/routes.json';
1213
import LEARN_ANGULAR_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/learn-angular/routes.json';
1314

@@ -639,6 +640,12 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
639640
},
640641
],
641642
},
643+
{
644+
label: 'Experimental features',
645+
children: [
646+
{label: 'Zoneless', path: 'guide/experimental/zoneless', contentPath: 'guide/zoneless'},
647+
],
648+
},
642649
],
643650
},
644651
{
@@ -678,9 +685,9 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
678685
contentPath: 'tools/cli/end-to-end',
679686
},
680687
{
681-
label: 'ESBuild',
682-
path: 'tools/cli/esbuild',
683-
contentPath: 'tools/cli/esbuild',
688+
label: 'Migrating to new build system',
689+
path: 'tools/cli/build-system-migration',
690+
contentPath: 'tools/cli/build-system-migration',
684691
},
685692
{
686693
label: 'Build environments',
@@ -931,19 +938,70 @@ const REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [
931938
},
932939
{
933940
label: 'ng analytics',
934-
path: 'cli/analytics',
941+
children: [
942+
{
943+
label: 'Overview',
944+
path: 'cli/analytics',
945+
},
946+
{
947+
label: 'disable',
948+
path: 'cli/analytics/disable',
949+
},
950+
{
951+
label: 'enable',
952+
path: 'cli/analytics/enable',
953+
},
954+
{
955+
label: 'info',
956+
path: 'cli/analytics/info',
957+
},
958+
{
959+
label: 'prompt',
960+
path: 'cli/analytics/prompt',
961+
},
962+
],
935963
},
936964
{
937965
label: 'ng build',
938966
path: 'cli/build',
939967
},
940968
{
941969
label: 'ng cache',
942-
path: 'cli/cache',
970+
children: [
971+
{
972+
label: 'Overview',
973+
path: 'cli/cache',
974+
},
975+
{
976+
label: 'clear',
977+
path: 'cli/cache/clean',
978+
},
979+
{
980+
label: 'disable',
981+
path: 'cli/cache/disable',
982+
},
983+
{
984+
label: 'enable',
985+
path: 'cli/cache/enable',
986+
},
987+
{
988+
label: 'info',
989+
path: 'cli/cache/info',
990+
},
991+
],
943992
},
944993
{
945994
label: 'ng completion',
946-
path: 'cli/completion',
995+
children: [
996+
{
997+
label: 'Overview',
998+
path: 'cli/completion',
999+
},
1000+
{
1001+
label: 'script',
1002+
path: 'cli/completion/script',
1003+
},
1004+
],
9471005
},
9481006
{
9491007
label: 'ng config',
@@ -953,10 +1011,6 @@ const REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [
9531011
label: 'ng deploy',
9541012
path: 'cli/deploy',
9551013
},
956-
{
957-
label: 'ng doc',
958-
path: 'cli/doc',
959-
},
9601014
{
9611015
label: 'ng e2e',
9621016
path: 'cli/e2e',
@@ -967,7 +1021,80 @@ const REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [
9671021
},
9681022
{
9691023
label: 'ng generate',
970-
path: 'cli/generate',
1024+
children: [
1025+
{
1026+
label: 'Overview',
1027+
path: 'cli/generate',
1028+
},
1029+
{
1030+
label: 'app-shell',
1031+
path: 'cli/generate/app-shell',
1032+
},
1033+
{
1034+
label: 'application',
1035+
path: 'cli/generate/application',
1036+
},
1037+
{
1038+
label: 'class',
1039+
path: 'cli/generate/class',
1040+
},
1041+
{
1042+
label: 'component',
1043+
path: 'cli/generate/component',
1044+
},
1045+
{
1046+
label: 'config',
1047+
path: 'cli/generate/config',
1048+
},
1049+
{
1050+
label: 'enum',
1051+
path: 'cli/generate/enum',
1052+
},
1053+
{
1054+
label: 'environments',
1055+
path: 'cli/generate/environments',
1056+
},
1057+
{
1058+
label: 'guard',
1059+
path: 'cli/generate/guard',
1060+
},
1061+
{
1062+
label: 'interceptor',
1063+
path: 'cli/generate/interceptor',
1064+
},
1065+
{
1066+
label: 'interface',
1067+
path: 'cli/generate/interface',
1068+
},
1069+
{
1070+
label: 'library',
1071+
path: 'cli/generate/library',
1072+
},
1073+
{
1074+
label: 'module',
1075+
path: 'cli/generate/module',
1076+
},
1077+
{
1078+
label: 'pipe',
1079+
path: 'cli/generate/pipe',
1080+
},
1081+
{
1082+
label: 'resolver',
1083+
path: 'cli/generate/resolver',
1084+
},
1085+
{
1086+
label: 'service-worker',
1087+
path: 'cli/generate/service-worker',
1088+
},
1089+
{
1090+
label: 'service',
1091+
path: 'cli/generate/service',
1092+
},
1093+
{
1094+
label: 'web-worker',
1095+
path: 'cli/generate/web-worker',
1096+
},
1097+
],
9711098
},
9721099
{
9731100
label: 'ng lint',
@@ -1112,6 +1239,11 @@ const REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [
11121239
path: 'errors/NG0507',
11131240
contentPath: 'reference/errors/NG0507',
11141241
},
1242+
{
1243+
label: 'NG0602: HTML content was altered after server-side rendering',
1244+
path: 'errors/NG0602',
1245+
contentPath: 'reference/errors/NG0602',
1246+
},
11151247
{
11161248
label: 'NG05104: Root element was not found',
11171249
path: 'errors/NG05104',
@@ -1127,6 +1259,26 @@ const REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [
11271259
path: 'errors/NG0912',
11281260
contentPath: 'reference/errors/NG0912',
11291261
},
1262+
{
1263+
label: 'NG0950: Required input is accessed before a value is set.',
1264+
path: 'errors/NG0950',
1265+
contentPath: 'reference/errors/NG0950',
1266+
},
1267+
{
1268+
label: 'NG0951: Child query result is required but no value is available.',
1269+
path: 'errors/NG0951',
1270+
contentPath: 'reference/errors/NG0951',
1271+
},
1272+
{
1273+
label: 'NG0955: Track expression resulted in duplicated keys for a given collection',
1274+
path: 'errors/NG0955',
1275+
contentPath: 'reference/errors/NG0955',
1276+
},
1277+
{
1278+
label: 'NG0956: Tracking expression caused re-creation of the DOM structure',
1279+
path: 'errors/NG0956',
1280+
contentPath: 'reference/errors/NG0956',
1281+
},
11301282
{
11311283
label: 'NG1001: Argument Not Literal',
11321284
path: 'errors/NG1001',
@@ -1148,9 +1300,9 @@ const REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [
11481300
contentPath: 'reference/errors/NG3003',
11491301
},
11501302
{
1151-
label: 'NG5000: Hydration with unsupported Zone.js instance.',
1152-
path: 'errors/NG5000',
1153-
contentPath: 'reference/errors/NG5000',
1303+
label: 'NG05000: Hydration with unsupported Zone.js instance.',
1304+
path: 'errors/NG05000',
1305+
contentPath: 'reference/errors/NG05000',
11541306
},
11551307
{
11561308
label: 'NG6100: NgModule.id Set to module.id anti-pattern',
@@ -1239,6 +1391,10 @@ const REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [
12391391
path: 'reference/versions',
12401392
contentPath: 'reference/versions',
12411393
},
1394+
{
1395+
label: 'Update guide',
1396+
path: 'update-guide',
1397+
},
12421398
{
12431399
label: 'Configurations',
12441400
children: [

adev-es/src/content/best-practices/a11y.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ The following example shows how to make a progress bar accessible by using host
7676
The ARIA attribute `aria-valuenow` is bound to the user's input.
7777
* In the template, the `aria-label` attribute ensures that the control is accessible to screen readers.
7878

79-
<docs-code-multifile
80-
path="adev/src/content/examples/accessibility/src/app/app.component.ts"
81-
preview>
79+
<docs-code-multifile>
8280
<docs-code
8381
path="adev/src/content/examples/accessibility/src/app/progress-bar.component.ts"
82+
language="ts"
8483
linenums
8584
highlight="[12, 20]"/>
8685
<docs-code
8786
path="adev/src/content/examples/accessibility/src/app/app.component.html"
87+
language="html"
8888
linenums
8989
highlight="[8, 9]"/>
9090
</docs-code-multifile>

adev-es/src/content/best-practices/runtime-performance/skipping-subtrees.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ If Angular handles an event within a component with OnPush strategy, the framewo
5959

6060
As an example, if Angular handles an event within `MainComponent`, the framework will run change detection in the entire component tree. Angular will ignore the subtree with root `LoginComponent` because it has `OnPush` and the event happened outside of its scope.
6161

62-
<img alt="Change detection propagation from OnPush component" src="assets/images/best-practices/runtime-performance/on-push-trigger.svg">
63-
6462
```mermaid
6563
graph TD;
6664
app[AppComponent] --- header[HeaderComponent];

adev-es/src/content/best-practices/runtime-performance/slow-computations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ For example, in the preceding screenshot, the second recorded change detection c
1919
Here are several techniques to remove slow computations:
2020

2121
* **Optimizing the underlying algorithm**. This is the recommended approach. If you can speed up the algorithm that is causing the problem, you can speed up the entire change detection mechanism.
22-
* **Caching using pure pipes**. You can move the heavy computation to a pure [pipe](/guide/pipes). Angular reevaluates a pure pipe only if it detects that its inputs have changed, compared to the previous time Angular called it.
22+
* **Caching using pure pipes**. You can move the heavy computation to a pure [pipe](guide/pipes). Angular reevaluates a pure pipe only if it detects that its inputs have changed, compared to the previous time Angular called it.
2323
* **Using memoization**. [Memoization](https://en.wikipedia.org/wiki/Memoization) is a similar technique to pure pipes, with the difference that pure pipes preserve only the last result from the computation where memoization could store multiple results.
2424
* **Avoid repaints/reflows in lifecycle hooks**. Certain [operations](https://web.dev/avoid-large-complex-layouts-and-layout-thrashing/) cause the browser to either synchronously recalculate the layout of the page or re-render it. Since reflows and repaints are generally slow, you want to avoid performing them in every change detection cycle.
2525

adev-es/src/content/best-practices/runtime-performance/zone-pollution.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AppComponent implements OnInit {
3535

3636
The preceding snippet instructs Angular to call `setInterval` outside the Angular Zone and skip running change detection after `pollForUpdates` runs.
3737

38-
Third-party libraries commonly trigger unnecessary change detection cycles because they weren't authored with Zone.js in mind. Avoid these extra cycles by calling library APIs outside the Angular zone:
38+
Third-party libraries commonly trigger unnecessary change detection cycles when their APIs are invoked within the Angular zone. This phenomenon particularly affects libraries that setup event listeners or initiate other tasks (such as timers, XHR requests, etc.). Avoid these extra cycles by calling library APIs outside the Angular zone:
3939

4040
<docs-code header="Move the plot initialization outside of the Zone" language='ts' linenums>
4141
import { Component, NgZone, OnInit } from '@angular/core';
@@ -57,3 +57,67 @@ class AppComponent implements OnInit {
5757
Running `Plotly.newPlot('chart', data);` within `runOutsideAngular` instructs the framework that it shouldn’t run change detection after the execution of tasks scheduled by the initialization logic.
5858

5959
For example, if `Plotly.newPlot('chart', data)` adds event listeners to a DOM element, Angular does not run change detection after the execution of their handlers.
60+
61+
But sometimes, you may need to listen to events dispatched by third-party APIs. In such cases, it's important to remember that those event listeners will also execute outside of the Angular zone if the initialization logic was done there:
62+
63+
<docs-code header="Check whether the handler is called outside of the Zone" language='ts' linenums>
64+
import { Component, NgZone, OnInit, output } from '@angular/core';
65+
import * as Plotly from 'plotly.js-dist-min';
66+
67+
@Component(...)
68+
class AppComponent implements OnInit {
69+
plotlyClick = output<Plotly.PlotMouseEvent>();
70+
71+
constructor(private ngZone: NgZone) {}
72+
73+
ngOnInit() {
74+
this.ngZone.runOutsideAngular(() => {
75+
this.createPlotly();
76+
});
77+
}
78+
79+
private async createPlotly() {
80+
const plotly = await Plotly.newPlot('chart', data);
81+
82+
plotly.on('plotly_click', (event: Plotly.PlotMouseEvent) => {
83+
// This handler will be called outside of the Angular zone because
84+
// the initialization logic is also called outside of the zone. To check
85+
// whether we're in the Angular zone, we can call the following:
86+
console.log(NgZone.isInAngularZone());
87+
this.plotlyClick.emit(event);
88+
});
89+
}
90+
}
91+
</docs-code>
92+
93+
If you need to dispatch events to parent components and execute specific view update logic, you should consider re-entering the Angular zone to instruct the framework to run change detection or run change detection manually:
94+
95+
<docs-code header="Re-enter the Angular zone when dispatching event" language='ts' linenums>
96+
import { Component, NgZone, OnInit, output } from '@angular/core';
97+
import * as Plotly from 'plotly.js-dist-min';
98+
99+
@Component(...)
100+
class AppComponent implements OnInit {
101+
plotlyClick = output<Plotly.PlotMouseEvent>();
102+
103+
constructor(private ngZone: NgZone) {}
104+
105+
ngOnInit() {
106+
this.ngZone.runOutsideAngular(() => {
107+
this.createPlotly();
108+
});
109+
}
110+
111+
private async createPlotly() {
112+
const plotly = await Plotly.newPlot('chart', data);
113+
114+
plotly.on('plotly_click', (event: Plotly.PlotMouseEvent) => {
115+
this.ngZone.run(() => {
116+
this.plotlyClick.emit(event);
117+
});
118+
});
119+
}
120+
}
121+
</docs-code>
122+
123+
The scenario of dispatching events outside of the Angular zone may also arise. It's important to remember that triggering change detection (for example, manually) may result to the creation/update of views outside of the Angular zone.

adev-es/src/content/best-practices/style-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ If the property is hard to construct a default value for, use `?` to explicitly
730730

731731
You may want to have a required `@Input` field, meaning all your component users are required to pass that attribute.
732732
In such cases, use a default value.
733-
Just suppressing the TypeScript error with `!` is insufficient and should be avoided because it will prevent the type checker ensure the input value is provided.
733+
Just suppressing the TypeScript error with `!` is insufficient and should be avoided because it will prevent the type checker from ensuring the input value is provided.
734734

735735
<docs-code header="app/heroes/hero/hero.component.ts" path="adev/src/content/examples/styleguide/src/05-18/app/heroes/hero/hero.component.avoid.ts" visibleRegion="example"/>
736736

0 commit comments

Comments
 (0)