Skip to content

Commit a33c1ea

Browse files
authored
Merge pull request #31 from alfonso-salces/main
MOBILE-4612: Use ids instead index to track list elements
2 parents 80a3c15 + 640758d commit a33c1ea

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

general/app/development/plugins-development-guide/examples/course-formats.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class mobile {
5353
```html handlebars title="templates/mobile_course.mustache"
5454
{{=<% %>=}}
5555
<core-dynamic-component [component]="coreCourseFormatComponent.allSectionsComponent" [data]="data" class="format-myformat">
56-
@for (section of sections; track $index) {
56+
@for (section of sections; track section.id) {
5757
<ion-item-divider>
5858
<ion-label>
5959
<core-format-text [text]="section.name" contextLevel="course" [contextInstanceId]="course.id">
@@ -70,7 +70,7 @@ class mobile {
7070
</ion-item>
7171
}
7272

73-
@for (module of section.modules; track $index) {
73+
@for (module of section.modules; track module.id) {
7474
@if (module.visibleoncoursepage !== 0) {
7575
<core-course-module [module]="module" [section]="section" (completionChanged)="onCompletionChange()">
7676
</core-course-module>

general/app/development/testing/unit-testing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Most services will be instantiated properly without mocks, but sometimes you may
128128
129129
## Testing components
130130
131-
Angular components have a strong graphical part, but that doesn't mean that you can't test their logic and markup rendering using unit tests with Jest. You can follow [Angular's best practices for testing components](https://angular.io/guide/testing-components-scenarios), and we also provide a couple of helpers that make things easier.
131+
Angular components have a strong graphical part, but that doesn't mean that you can't test their logic and markup rendering using unit tests with Jest. You can follow [Angular's best practices for testing components](https://angular.dev/guide/testing/components-scenarios), and we also provide a couple of helpers that make things easier.
132132
133133
Let's say you want to test the following component that render a list of user names:
134134

general/development/policies/codingstyle-moodleapp.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export class MyService {
435435

436436
### Avoid calling methods in templates
437437

438-
Method calls should be avoided in template rendering, this includes structural directives such as `ngIf` or `ngFor`.
438+
Method calls should be avoided in template rendering, including structural directives like `ngIf` or `ngFor`. The same applies to the new control flow syntax with `@if` or `@for`.
439439

440440
Angular templates can be rendered very often, and calling methods on every render could cause some unintended performance issues. For that reason, it is usually safer to rely on values rather than methods.
441441

@@ -502,7 +502,7 @@ There is a maximum line length of 140 characters for templates. Whenever that le
502502
<ValidExample title="Good">
503503

504504
```html
505-
@for (course of courses; track $index) {
505+
@for (course of courses; track course.id) {
506506
<ion-item
507507
[title]="course.title"
508508
[class.selected]="isSelected(course)" class="ion-text-wrap"
@@ -520,7 +520,7 @@ There is a maximum line length of 140 characters for templates. Whenever that le
520520
<InvalidExample title="Bad">
521521

522522
```html
523-
@for (course of courses; track $index) {
523+
@for (course of courses; track course.id) {
524524
<ion-item
525525
[title]="course.title"
526526
[class.selected]="isSelected(course)"

0 commit comments

Comments
 (0)