Skip to content

Commit

Permalink
Tree: remove arrayContains function
Browse files Browse the repository at this point in the history
  • Loading branch information
tecvan committed Jun 10, 2019
1 parent 74191d0 commit 2a58f4d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/tree/src/model/node.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import objectAssign from 'element-ui/src/utils/merge';
import { markNodeData, NODE_KEY } from './util';
import { arrayContains } from 'element-ui/src/utils/util';
import { arrayFindIndex } from 'element-ui/src/utils/util';

export const getChildState = node => {
let all = true;
Expand Down Expand Up @@ -437,7 +437,7 @@ export default class Node {

newData.forEach((item, index) => {
const key = item[NODE_KEY];
const isNodeExists = !!key && arrayContains(oldData, data => data[NODE_KEY] === key);
const isNodeExists = !!key && arrayFindIndex(oldData, data => data[NODE_KEY] === key) >= 0;
if (isNodeExists) {
newDataMap[key] = { index, data: item };
} else {
Expand Down
4 changes: 0 additions & 4 deletions src/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ export const arrayFindIndex = function(arr, pred) {
return -1;
};

export const arrayContains = function(arr, pred) {
return arrayFindIndex(arr, pred) >= 0;
};

export const arrayFind = function(arr, pred) {
const idx = arrayFindIndex(arr, pred);
return idx !== -1 ? arr[idx] : undefined;
Expand Down

0 comments on commit 2a58f4d

Please sign in to comment.