Files
wallet-web/src/core/utils/closest-deco.ts
Fran Jurmanović 8754b4391b fixed types
2021-06-02 23:29:05 +02:00

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);
}