Skip to content

Commit c46c49c

Browse files
docs(material/table): refactor table selection master toggle (#22647)
replace ternary operator by if statement with early return replace redundant forEach statement with neat spread operator
1 parent c04bd21 commit c46c49c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components-examples/material/table/table-selection/table-selection-example.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ export class TableSelectionExample {
4444

4545
/** Selects all rows if they are not all selected; otherwise clear selection. */
4646
masterToggle() {
47-
this.isAllSelected() ?
48-
this.selection.clear() :
49-
this.dataSource.data.forEach(row => this.selection.select(row));
47+
if (this.isAllSelected()) {
48+
this.selection.clear();
49+
return;
50+
}
51+
52+
this.selection.select(...this.dataSource.data);
5053
}
5154

5255
/** The label for the checkbox on the passed row */

0 commit comments

Comments
 (0)