Skip to content

[Bug] anchor-has-content fires when an anchor contains a child div using v-html #191

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

Closed
richardtallent opened this issue Jul 7, 2021 · 4 comments · Fixed by #313
Closed

Comments

@richardtallent
Copy link

We're using the v-html attribute to give an anchor its readable contents, but the plugin is only looking for anchors to contain a child element that has inner text.

When an anchor uses v-html or any of its child elements do, that should count as readable content. (Sure, the v-html might return a blank value, but so can a template {{ variable }}).

@chuckmah
Copy link

I experienced the same

@kddnewton
Copy link
Collaborator

Can one of you attach the source file that's not working? This test line: https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility/blob/main/src/rules/__tests__/anchor-has-content.test.ts#L9 I believe covers what you're talking about, so I need a snippet that violates to reproduce.

@richardtallent
Copy link
Author

The problem arises when the v-html is part of a child node rather than the anchor itself. Here's a minimal test case:

<a href="http://google.com">
	<span v-html="googleLabel" />
</a>

For my real-world use case, my anchor tag has both an icon and a label, the label div has the v-html attribute..

@kddnewton
Copy link
Collaborator

Ahh!! I see. I will get this fixed, thanks for the repro!

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