mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-02-06 06:08:10 +00:00
16 lines
418 B
TypeScript
16 lines
418 B
TypeScript
import { toKebabCase } from "core/utils";
|
|
|
|
export default function closest(proto: Object, key: string): any {
|
|
const kebab: string = toKebabCase(key);
|
|
return Object.defineProperty(proto, key, {
|
|
configurable: true,
|
|
get() {
|
|
return findClosest(this, kebab);
|
|
},
|
|
});
|
|
}
|
|
|
|
function findClosest(element: HTMLElement, key: string): HTMLElement {
|
|
return element.closest(key);
|
|
}
|