UNPKG

maycur-business

Version:

maycur business react components of web

30 lines (24 loc) 671 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = closest; var _matches = require("./matches"); /** * Ponyfill to get the closest parent element * @param {Element} element - child of parent to be returned * @param {String} parentSelector - selector to match the parent if found * @return {Element} */ function closest(element, parentSelector) { var _closest = Element.prototype.closest || function (selector) { var el = this; while (el) { if (_matches.matches.call(el, selector)) { return el; } el = el.parentElement; } }; return _closest.call(element, parentSelector); }