superdesk/superdesk-client-core

View on GitHub
scripts/core/helpers/dom/querySelectorParent.ts

Summary

Maintainability
A
0 mins
Test Coverage
import {findParent} from './findParent';

export const querySelectorParent = (
    element: HTMLElement,
    selector: string,
    options?: {
        self: boolean; // will check the current element too if set to true
    },
): HTMLElement | null => {
    return findParent(
        element,
        (el) => el.matches(selector),
        options?.self ?? false,
    );
};