From d4715e1783a72f781bd5d290221097f560429378 Mon Sep 17 00:00:00 2001 From: zombiej Date: Mon, 17 Dec 2018 16:09:41 +0800 Subject: [PATCH] pass props to fix IE <= 10 not support constructor fix #13540 --- components/table/SelectionCheckboxAll.tsx | 28 +++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/components/table/SelectionCheckboxAll.tsx b/components/table/SelectionCheckboxAll.tsx index e2af502976..14dd61f330 100644 --- a/components/table/SelectionCheckboxAll.tsx +++ b/components/table/SelectionCheckboxAll.tsx @@ -58,8 +58,13 @@ export default class SelectionCheckboxAll extends React.Component< }); } - checkSelection(data: T[], type: string, byDefaultChecked: boolean) { - const { store, getCheckboxPropsByItem, getRecordKey } = this.props; + checkSelection( + props: SelectionCheckboxAllProps, + data: T[], + type: string, + byDefaultChecked: boolean, + ) { + const { store, getCheckboxPropsByItem, getRecordKey } = props || this.props; // type should be 'every' | 'some' if (type === 'every' || type === 'some') { return byDefaultChecked @@ -93,8 +98,9 @@ export default class SelectionCheckboxAll extends React.Component< checked = false; } else { checked = store.getState().selectionDirty - ? this.checkSelection(data, 'every', false) - : this.checkSelection(data, 'every', false) || this.checkSelection(data, 'every', true); + ? this.checkSelection(props, data, 'every', false) + : this.checkSelection(props, data, 'every', false) || + this.checkSelection(props, data, 'every', true); } return checked; } @@ -106,15 +112,17 @@ export default class SelectionCheckboxAll extends React.Component< indeterminate = false; } else { indeterminate = store.getState().selectionDirty - ? this.checkSelection(data, 'some', false) && !this.checkSelection(data, 'every', false) - : (this.checkSelection(data, 'some', false) && - !this.checkSelection(data, 'every', false)) || - (this.checkSelection(data, 'some', true) && !this.checkSelection(data, 'every', true)); + ? this.checkSelection(props, data, 'some', false) && + !this.checkSelection(props, data, 'every', false) + : (this.checkSelection(props, data, 'some', false) && + !this.checkSelection(props, data, 'every', false)) || + (this.checkSelection(props, data, 'some', true) && + !this.checkSelection(props, data, 'every', true)); } return indeterminate; } - handleSelectAllChagne = (e: CheckboxChangeEvent) => { + handleSelectAllChange = (e: CheckboxChangeEvent) => { const checked = e.target.checked; this.props.onSelect(checked ? 'all' : 'removeAll', 0, null); }; @@ -171,7 +179,7 @@ export default class SelectionCheckboxAll extends React.Component< checked={checked} indeterminate={indeterminate} disabled={disabled} - onChange={this.handleSelectAllChagne} + onChange={this.handleSelectAllChange} /> {customSelections}