Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Deloser throws error when a form has an input with name id #227

Open
kevicency opened this issue Jan 26, 2023 · 2 comments
Open

[Bug] Deloser throws error when a form has an input with name id #227

kevicency opened this issue Jan 26, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@kevicency
Copy link

https://github.com/microsoft/tabster/blob/master/src/Deloser.ts#L299

This check has a false positive for forms with an input named id since element.id will point to the input element in the form.

Sandbox for reproduction: https://codesandbox.io/s/agitated-khorana-hzqyu2?file=/src/index.tsx

@kevicency kevicency changed the title [Bug] Tabster throws error when a form has an input with name id [Bug] Deloser throws error when a form has an input with name id Jan 26, 2023
@ling1726 ling1726 added the bug Something isn't working label Jan 30, 2023
@tsingson
Copy link

tsingson commented Feb 23, 2023

in Deloser.ts line 299:

    if (element.id) {
        selector.push(
            "#" + element.id.replace(escapeRegExp, escapeReplaceValue)
        );
    }

change to

    if (element.id) {
        const  el = element.id.toString();
        selector.push(
            "#" + el .replace(escapeRegExp, escapeReplaceValue)
        );
    }

will ignore error, but maybe need more testing.

@lgoeckener
Copy link
Contributor

I have added a pull request to resolve this, as I had come across this bug as well.

Using getAttribute should be a more robust approach to retrieving the element's id.

see: #287

PS: @tsingson

in Deloser.ts line 299:

    if (element.id) {
        selector.push(
            "#" + element.id.replace(escapeRegExp, escapeReplaceValue)
        );
    }

change to

    if (element.id) {
        const  el = element.id.toString();
        selector.push(
            "#" + el .replace(escapeRegExp, escapeReplaceValue)
        );
    }

will ignore error, but maybe need more testing.

This will make the error go away, but you're still unable to retrieve the id of the form (el would be [object HTMLFormElement])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants