From c1836e8bf37d060daf0b2f63afcc2e533588bdb3 Mon Sep 17 00:00:00 2001 From: Ivan Stanevich Date: Sun, 9 May 2021 10:36:23 +0300 Subject: [PATCH] docs(material/table): refactor table selection master toggle replace ternary operator by if statement with early return replace redundant forEach statement with neat spread operator --- .../table/table-selection/table-selection-example.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components-examples/material/table/table-selection/table-selection-example.ts b/src/components-examples/material/table/table-selection/table-selection-example.ts index 8aa13f5aaee1..6916c1d920aa 100644 --- a/src/components-examples/material/table/table-selection/table-selection-example.ts +++ b/src/components-examples/material/table/table-selection/table-selection-example.ts @@ -44,9 +44,12 @@ export class TableSelectionExample { /** Selects all rows if they are not all selected; otherwise clear selection. */ masterToggle() { - this.isAllSelected() ? - this.selection.clear() : - this.dataSource.data.forEach(row => this.selection.select(row)); + if (this.isAllSelected()) { + this.selection.clear(); + return; + } + + this.selection.select(...this.dataSource.data); } /** The label for the checkbox on the passed row */