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

Lint for duplicate id's #11

Open
ecerta opened this issue Jan 18, 2019 · 7 comments
Open

Lint for duplicate id's #11

ecerta opened this issue Jan 18, 2019 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@ecerta
Copy link
Contributor

ecerta commented Jan 18, 2019

Is your feature request related to a problem? Please describe.
Screen readers depend on the id attribute to correctly associate labels, aria-describedby's and aria-labelledby's. Duplicate id's confuse them, and are just plain old bad code.

Describe the solution you'd like
Have the linter check if an id has been used before on the page, and throw an error if so.

Describe alternatives you've considered
It's possible a user is using other good HTML linters to check for this issue, but I think it's still worth including in this one.

@ecerta
Copy link
Contributor Author

ecerta commented Jan 18, 2019

WCAG 4.1.1. states that the site should pass a parsing check (no stray or mismatched tags, for instance) so really any kind of good HTML linting could be a welcome change, but I picked the one the most likely to actually impact a screen reader user.

@mvdschee mvdschee added the enhancement New feature or request label Jan 18, 2019
@mvdschee
Copy link
Owner

@ecerta Thanks for the report, I will take a look in a couple of days and will give a better response than this message, I'm insanely busy at the moment!

@mvdschee
Copy link
Owner

mvdschee commented Feb 4, 2019

I have started implementing the check, but it's going to be a very resource intensive functionality.
This is because every time it finds an id its going to trigger the check and has to do a full document search for duplicated id's.
This is not a performance problem at the moment, but I'm almost sure it's going to be with multiple checks that need to do a full document search.
So if you have any suggestions on how to tackle this problem, I'm all ears.

@ecerta
Copy link
Contributor Author

ecerta commented Feb 4, 2019

What if every time any id is found it's added to an array, and then just that array is checked?

@mvdschee
Copy link
Owner

mvdschee commented Feb 5, 2019

That is possible but requires a function that keeps track of those id's that are already in the array and remove them if they changed. I think that would be a complicated function with a logic that will break.
I think I will have to do a refactor for those sort of cases and deal with them separately.

mvdschee pushed a commit that referenced this issue Feb 8, 2019
@mvdschee
Copy link
Owner

I have tried to implement the logic for duplicated values, in this case for the ID's, but I keep running into problems with the collection of the ID's. So for the next update (0.2.4), this functionality will be held back. I have started a new branch to refactor the whole setup for all the rules, and the feature for duplicated values will be part of the major update (0.3.0). So, for now, This issue will stay open a little longer 😞

@mvdschee mvdschee self-assigned this Feb 17, 2019
@ecerta
Copy link
Contributor Author

ecerta commented Feb 17, 2019

This isn't extremely high priority so don't kill yourself over it. If there's a way to do it it'd be a nice perk but if not, there's other ways to make the linter more useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

No branches or pull requests

2 participants