Skip to content

Commit

Permalink
Merge pull request #31 from alfonso-salces/main
Browse files Browse the repository at this point in the history
MOBILE-4612: Use ids instead index to track list elements
  • Loading branch information
dpalou authored Jul 10, 2024
2 parents 80a3c15 + 640758d commit a33c1ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class mobile {
```html handlebars title="templates/mobile_course.mustache"
{{=<% %>=}}
<core-dynamic-component [component]="coreCourseFormatComponent.allSectionsComponent" [data]="data" class="format-myformat">
@for (section of sections; track $index) {
@for (section of sections; track section.id) {
<ion-item-divider>
<ion-label>
<core-format-text [text]="section.name" contextLevel="course" [contextInstanceId]="course.id">
Expand All @@ -70,7 +70,7 @@ class mobile {
</ion-item>
}

@for (module of section.modules; track $index) {
@for (module of section.modules; track module.id) {
@if (module.visibleoncoursepage !== 0) {
<core-course-module [module]="module" [section]="section" (completionChanged)="onCompletionChange()">
</core-course-module>
Expand Down
2 changes: 1 addition & 1 deletion general/app/development/testing/unit-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Most services will be instantiated properly without mocks, but sometimes you may
## Testing components
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.
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.
Let's say you want to test the following component that render a list of user names:
Expand Down
6 changes: 3 additions & 3 deletions general/development/policies/codingstyle-moodleapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export class MyService {

### Avoid calling methods in templates

Method calls should be avoided in template rendering, this includes structural directives such as `ngIf` or `ngFor`.
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`.

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.

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

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

```html
@for (course of courses; track $index) {
@for (course of courses; track course.id) {
<ion-item
[title]="course.title"
[class.selected]="isSelected(course)"
Expand Down

0 comments on commit a33c1ea

Please sign in to comment.