15 lines
293 B
JavaScript
15 lines
293 B
JavaScript
'use strict';
|
|
|
|
function findClosest(element, callback) {
|
|
let el = element;
|
|
do {
|
|
if (callback(el)) {
|
|
return el;
|
|
}
|
|
el = el.parentElement;
|
|
}while (el && el !== element.ownerDocument.body)
|
|
return undefined;
|
|
}
|
|
|
|
exports.findClosest = findClosest;
|