consul/ui/packages/consul-ui/app/utils/dom/closest.js

16 lines
320 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
export default function (sel, el) {
// basic DOM closest utility to cope with no support
// TODO: instead of degrading gracefully
// add a while polyfill for closest
try {
return el.closest(sel);
} catch (e) {
return;
}
}