Skip to content

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

Open
@thomasmattheussen

Description

@thomasmattheussen
<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?

Activity

ljharb

ljharb commented on Sep 12, 2023

@ljharb
Member

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

thomasmattheussen commented on Sep 14, 2023

@thomasmattheussen
Author

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

ljharb commented on Sep 14, 2023

@ljharb
Member

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ljharb@thomasmattheussen

        Issue actions

          jsx-a11y/control-has-associated-label: dangerouslySetInnerHTML should pass? · Issue #954 · jsx-eslint/eslint-plugin-jsx-a11y