fix(transfer): fix compatibility es2015 function, close #944

This commit is contained in:
afc163 2016-01-27 16:46:42 +08:00
parent f540b1c201
commit 31ae114a19

View File

@ -28,12 +28,12 @@ class Transfer extends Component {
if (targetKeys.length > 0) { if (targetKeys.length > 0) {
targetKeys.forEach((targetKey) => { targetKeys.forEach((targetKey) => {
rightDataSource.push(leftDataSource.find((data, index) => { rightDataSource.push(leftDataSource.filter((data, index) => {
if (data.key === targetKey) { if (data.key === targetKey) {
leftDataSource.splice(index, 1); leftDataSource.splice(index, 1);
return true; return true;
} }
})); })[0]);
}); });
} }
@ -133,7 +133,12 @@ class Transfer extends Component {
handleSelect(direction, selectedItem, checked) { handleSelect(direction, selectedItem, checked) {
const { leftCheckedKeys, rightCheckedKeys } = this.state; const { leftCheckedKeys, rightCheckedKeys } = this.state;
const holder = direction === 'left' ? leftCheckedKeys : rightCheckedKeys; const holder = direction === 'left' ? leftCheckedKeys : rightCheckedKeys;
const index = holder.findIndex((key) => key === selectedItem.key); let index;
holder.forEach((key, i) => {
if (key === selectedItem.key) {
index = i;
}
});
if (index > -1) { if (index > -1) {
holder.splice(index, 1); holder.splice(index, 1);
} }