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

label-has-for fails for bound id/label #15

Open
sem4phor opened this issue May 20, 2019 · 6 comments
Open

label-has-for fails for bound id/label #15

sem4phor opened this issue May 20, 2019 · 6 comments

Comments

@sem4phor
Copy link

sem4phor commented May 20, 2019

When using a dynamic for / id attribute on label / input elements the rule label-has-for fails.

error: Form label must have associated control (vue-a11y/label-has-for)

<template>
  <label :for="_uid">
    <input :id="_uid">
  </label>
</template>

Expected behaviour:
The rule passes.

@sem4phor
Copy link
Author

same for vue-a11y/alt-text rule

@maranran
Copy link
Owner

lastest version ? I fail to reappear this bug @sem4phor

@sem4phor
Copy link
Author

sem4phor commented May 21, 2019

yes on the latest version. Did you test it with input nested in label and a bound for?

@venikman
Copy link

venikman commented Jul 2, 2019

I got it work. The problem that looks like that rule was taken from react rules. You can see it in documentation for rule. Name of rule for react. jsx-a11y/label-has-for".
So what I had to do it to add options for it.

"vue-a11y/label-has-for": [ 2, {
            "components": [ "label" ],
            "required": {
                "every": [ "nesting", "id" ]
            },
            "allowChildren": false
        }]

I changed jsx to vue and Label to label
I will probably can open a PR to fix it.

@andresdameson
Copy link

I changed the rule made by venikman to support nesting OR id:

  "vue-a11y/label-has-for": [ 2, {
        "components": [ "label" ],
        "required": {
            "some": [ "nesting", "id" ]
        },
        "allowChildren": false
 }]

@ZebulanStanphill
Copy link

It's worth noting that eslint-plugin-jsx-a11y's label-has-for has recently been deprecated and replaced by label-has-associated-control. This plugin should probably follow suit.

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

No branches or pull requests

5 participants