Fix #57 split on undefined error

This commit is contained in:
Jeremie Pardou-Piquemal 2020-06-19 19:58:15 +02:00 committed by Jérémie Pardou-Piquemal
parent 61bf3cf354
commit cdf0903583

View file

@ -4,7 +4,8 @@
* @param {string} className
*/
export const insideClass = (element, className) => {
if (element.className.split(" ").includes(className)) return element;
if (element.className && element.className.split(" ").includes(className))
return element;
if (!element.parentNode) return false;
return element.parentNode && insideClass(element.parentNode, className);
};