/* Loops through the previous siblings of a DOM element
   and returns the first element which matches the selector.
   If no match is found null is returned. */
export function previousUntil(elem, selector) {
    if (elem.previousElementSibling !== null) {
        elem = elem.previousElementSibling;
    }
    while (elem) {
        if (elem.matches(selector)) {
            return elem;
        }
        if (elem.previousElementSibling !== null) {
            elem = elem.previousElementSibling;
        }
        else {
            break;
        }
    }
    return null;
}
//# sourceMappingURL=previousUntil.js.map