From 8c48a816f03dfa61c52ab85bd1798fd123b9c7e8 Mon Sep 17 00:00:00 2001 From: Jeremie Pardou-Piquemal <571533+jrmi@users.noreply.github.com> Date: Thu, 9 Jul 2020 21:18:15 +0200 Subject: [PATCH] Fix bug when no classes --- src/utils/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 20e9898..176c65d 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -4,10 +4,16 @@ * @param {string} className */ export const insideClass = (element, className) => { - if (element.className && element.className.split(" ").includes(className)) + if ( + typeof element.className === "string" && + element.className.split(" ").includes(className) + ) { return element; - if (!element.parentNode) return false; - return element.parentNode && insideClass(element.parentNode, className); + } + if (!element.parentNode) { + return false; + } + return insideClass(element.parentNode, className); }; export const isPointInsideRect = (point, rect) => {