You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/_util/dom-closest.js

25 lines
524 B

/**
* source by `dom-closest`
* https://github.com/necolas/dom-closest.git
*/
import matches from './dom-matches';
/**
* @param element {Element}
* @param selector {String}
* @param context {Element=}
* @return {Element}
*/
export default function(element, selector, context) {
context = context || document;
// guard against orphans
element = { parentNode: element };
while ((element = element.parentNode) && element !== context) {
if (matches(element, selector)) {
return element;
}
}
}