mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
docs: improve spelling and grammar for error NG0956 (#57164)
PR Close #57164
This commit is contained in:
committed by
Dylan Hunn
parent
f1c8f9765e
commit
2eb2d445db
@@ -1,6 +1,6 @@
|
||||
# Tracking expression caused re-creation of the DOM structure.
|
||||
|
||||
The identity track expression specified in the `@for` loop caused re-creation of the DOM corresponding to _all_ items. This is very expensive operation that commonly occurs when working with immutable data structures, Example:
|
||||
The identity track expression specified in the `@for` loop caused re-creation of the DOM corresponding to _all_ items. This is a very expensive operation that commonly occurs when working with immutable data structures. For example:
|
||||
|
||||
```typescript
|
||||
@Component({
|
||||
@@ -25,13 +25,13 @@ export class App {
|
||||
}
|
||||
```
|
||||
|
||||
In the provided example the entire list, with all the views (DOM nodes, Angular directives, components, queries etc.) are re-created (!) after toggling the "done" status of items. Here a relatively inexpensive binding update to the `done` property would suffice.
|
||||
In the provided example, the entire list with all the views (DOM nodes, Angular directives, components, queries, etc.) are re-created (!) after toggling the "done" status of items. Here, a relatively inexpensive binding update to the `done` property would suffice.
|
||||
|
||||
Apart from having high performance penalty, re-creating the DOM tree results in loss of state in the DOM elements (ex.: focus, text selection, sites loaded in an iframe etc.).
|
||||
Apart from having a high performance penalty, re-creating the DOM tree results in loss of state in the DOM elements (ex.: focus, text selection, sites loaded in an iframe, etc.).
|
||||
|
||||
## Fixing the error
|
||||
|
||||
Change the tracking expression such that it uniquely identifies an item in a collection, regardless of its object identity. In the discussed example the correct track expression would use the unique `id` property (`item.id`):
|
||||
Change the tracking expression such that it uniquely identifies an item in a collection, regardless of its object identity. In the discussed example, the correct track expression would use the unique `id` property (`item.id`):
|
||||
|
||||
```typescript
|
||||
@Component({
|
||||
|
||||
Reference in New Issue
Block a user