microsoft / tabster

Web Application Keyboard Navigation Tools
https://tabster.io
MIT License
122 stars 36 forks source link

Tabster crashes in Firefox #381

Open petewu100 opened 7 months ago

petewu100 commented 7 months ago

When pressing Tab in a web app that uses Tabster in Firefox, I hit a crash in the following code in Focusable.ts:

private _isHidden(el: HTMLElement): boolean {
    const attrVal = el.getAttribute("aria-hidden");

    if (attrVal && attrVal.toLowerCase() === "true") {
        if (!this._tabster.modalizer?.isAugmented(el)) {
            return true;
        }
    }

    return false;
}

The loop in isAccessible proceeds all the up the DOM to the HTMLDocument element and el.getAttribute is not defined for the HTMLDocument element so it crashes on the first line of _isHidden. Seems like the code should check if el.getAttribute is defined before trying to call it.

ling1726 commented 7 months ago

@petewu100 can you provide a repro for this? Trying to call getAttribute on Firefox I can't see that getAttribute is undefined

image