UNPKG

tippy.js

Version:

Vanilla JS Tooltip Library

22 lines (19 loc) • 556 B
import matches from './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} */ export default function closest(element, parentSelector) { const _closest = Element.prototype.closest || function(selector) { let el = this while (el) { if (matches.call(el, selector)) { return el } el = el.parentElement } } return _closest.call(element, parentSelector) }