From 0162e97ecb799b3e7348aeb6d0e8a76edfdea7a9 Mon Sep 17 00:00:00 2001 From: Diogo Cunha Date: Fri, 30 Nov 2018 12:02:09 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20error=20on=20IE=20while?= =?UTF-8?q?=20running=20native=20findIndex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- package.json | 1 + src/selectors/nodes.js | 5 +++-- yarn.lock | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f9b9e59..e3c87c6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ /umd npm-debug.log* /gh-pages -package-lock.json \ No newline at end of file +package-lock.json +yarn-error.log \ No newline at end of file diff --git a/package.json b/package.json index 8c61aa6..0904baa 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "classnames": "^2.2.5", "lodash": "^4.17.4", "lodash.debounce": "^4.0.8", + "lodash.findindex": "^4.6.0", "lodash.isequal": "^4.5.0", "lodash.omit": "^4.5.0", "material-icons": "^0.1.0", diff --git a/src/selectors/nodes.js b/src/selectors/nodes.js index dfe24f3..fb88037 100644 --- a/src/selectors/nodes.js +++ b/src/selectors/nodes.js @@ -1,5 +1,6 @@ import {createSelector} from 'reselect'; import omit from 'lodash.omit'; +import findIndex from 'lodash.findindex'; import {UPDATE_TYPE} from '../contants'; @@ -47,7 +48,7 @@ export const replaceNodeFromTree = (nodes, updatedNode, operation = NODE_OPERATI return NODE_CHANGE_OPERATIONS[operation](nodes, updatedNode); } - const parentIndex = nodes.findIndex(n => n.id === parents[0]); + const parentIndex = findIndex(nodes, n => n.id === parents[0]); const preSiblings = nodes.slice(0, parentIndex); const postSiblings = nodes.slice(parentIndex + 1); @@ -94,4 +95,4 @@ export const addNode = node => ({ type: UPDATE_TYPE.ADD, }); -export const getRowIndexFromId = (flattenedTree, id) => flattenedTree.findIndex(node => node.id === id); +export const getRowIndexFromId = (flattenedTree, id) => findIndex(flattenedTree, node => node.id === id); diff --git a/yarn.lock b/yarn.lock index 4214cb1..e79fb12 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6191,6 +6191,11 @@ lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" +lodash.findindex@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.findindex/-/lodash.findindex-4.6.0.tgz#a3245dee61fb9b6e0624b535125624bb69c11106" + integrity sha1-oyRd7mH7m24GJLU1ElYku2nBEQY= + lodash.flattendeep@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2"