Angular
angular/table-tbody
Table rows in Angular templates sit inside an explicit tbody (or thead/tfoot); the browser inserts one and hydration fails.
umiarkowanastatycznefe-angular
Dlaczego
When the server sends <table><tr>, the browser's parser adds a <tbody> the template does not know about. During hydration Angular finds a different DOM than it rendered and reports a mismatch; the component is then rendered again on the client, which costs time and can flash or shift the table.
Poprawka
Wrap rows in <tbody> (and header rows in <thead>) in the template itself. It is valid HTML either way and also keeps the table structure clear for assistive technology.
Przykłady
<!-- bad -->
<table>
@for (order of orders(); track order.id) { <tr><td>{{ order.number }}</td></tr> }
</table>
<!-- good -->
<table>
<tbody>
@for (order of orders(); track order.id) { <tr><td>{{ order.number }}</td></tr> }
</tbody>
</table>Źródła
Fakty
- Identyfikator
angular/table-tbody- Waga
- umiarkowana
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
angular- Tylko w projektach z
angular- Uczy jej skill
fe-angularAngular components- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain angular/table-tbody