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

jsx-a11y/control-has-associated-label: dangerouslySetInnerHTML should pass? #954

Open
thomasmattheussen opened this issue Sep 12, 2023 · 3 comments

Comments

@thomasmattheussen
Copy link

<td
  dangerouslySetInnerHTML={parseMarkdownLinks(
    prop.description,
  )}
></td>

throws a jsx-a11y/control-has-associated-label error.

I believe this should pass in the same way as #64 ?

Also, the documentation says "Enforce that a control (an interactive element) has a text label." I was a bit confused because a <td> is not an interactive element I think?

@ljharb
Copy link
Member

ljharb commented Sep 12, 2023

We can't parse HTMl in dangerouslySetInnerHTML, and in this case it's not even a static value, so there'd be nothing we can do (there's a reason it's "dangerous" and shouldn't be used).

I'm not sure why it's warning on a td. The example in #64 is because anything there ensures that the header has content; in this case, we'd need to know what the content is.

@thomasmattheussen
Copy link
Author

thomasmattheussen commented Sep 14, 2023

I get the dynamic value issue, so feel free to close. (The HTML in this case is not dangerous at all btw, no worries of XSS).

I don't understand why a <td> can't be empty though?

@ljharb
Copy link
Member

ljharb commented Sep 14, 2023

It definitely seems like a bug, to be clear - td isn't a control or a label, so it should just be ignoring it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants