/**
 *
 * @param thing
 * @param klass
 * @returns {boolean}
 */
function isInstanceOf(thing, klass) {
    if (klass === undefined) {
        return false;
    }
    if (klass === null) {
        return false;
    }

    if (typeof klass !== "object") {
        return false;
    }


    return thing instanceof klass;
}

/**
 * Based on the article about focusable events: https://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus
 * @param {Element} el
 */
export function isHTMLElementFocusable(el) {
    return isInstanceOf(el, HTMLInputElement)
        || isInstanceOf(el, HTMLSelectElement)
        || isInstanceOf(el, HTMLTextAreaElement)
        || isInstanceOf(el, HTMLAnchorElement)
        || isInstanceOf(el, HTMLButtonElement)
        || isInstanceOf(el, HTMLAreaElement)
}