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

Support selectors for disabledRule #53

Closed
Eric-B-Wu opened this issue May 3, 2022 · 10 comments
Closed

Support selectors for disabledRule #53

Eric-B-Wu opened this issue May 3, 2022 · 10 comments

Comments

@Eric-B-Wu
Copy link

Currently, when disabling a rule, it can only be disabled for the specific story or globally. Supporting selectors would be a safer way of ignoring a violation across stories as Axe will then only ignore very specific elements and keep reporting violations on other elements of this rule.

@ahuth
Copy link
Contributor

ahuth commented May 4, 2022

Good idea, and I agree it would be safer. Thanks for suggesting!

Not sure how to implement this, though. axe-core's API lets us target specific selectors to check, but I'm not aware of any way to exclude selectors from rules.

@jeremiah-clothier
Copy link
Contributor

Not sure how to implement this, though. axe-core's API lets us target specific selectors to check, but I'm not aware of any way to exclude selectors from rules.

I did some digging and may have found an API that would support this functionality using an include-exclude object in axe-core's run method

I'm not sure what the integration would look like, but we may be able to update the code to accept this object and pass it along to where we call axe.run(...)?

@ahuth
Copy link
Contributor

ahuth commented Jun 16, 2022

If I'm reading it right, that would let us exclude elements from being checked at all, but wouldn't let us exclude elements per rule.

Although maybe excluding elements from being checked at all is the best option we have.

@jeremiah-clothier
Copy link
Contributor

If I'm reading it right, that would let us exclude elements from being checked at all, but wouldn't let us exclude elements per rule.

🤦 Oh right, yeah I think you're right and this wouldn't allow that

@ahuth
Copy link
Contributor

ahuth commented Jun 16, 2022

Could still be useful, though!

@ahuth ahuth closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2023
@leandroferreira
Copy link

@ahuth Is there still appetite for this feature? I'm looking into a way to send Context to axe - similarly to sending options - where it can exclude certain elements from being tested.

@ahuth ahuth reopened this Jul 25, 2024
@ahuth
Copy link
Contributor

ahuth commented Jul 25, 2024

If there's a need for it, then definitely, @leandroferreira.

The only complication: I think the context will have to be json serializable, since it would have to be passed from Node to Playwright to the browser.

So I can imagine something like this totally working:

parameters: {
  axe: {
    context: {
      exclude: '.ad-banner'
      // or include: ...
      // or fromFrames: ...
      // etc.
    }
  }
}

but you wouldn't be able to use something like document.querySelectorAll('whatever') as the context.

@ahuth ahuth mentioned this issue Jul 25, 2024
@ahuth
Copy link
Contributor

ahuth commented Jul 25, 2024

#98

@leandroferreira
Copy link

Oh wow that was unbelievably quick, thank you so much! This will work perfectly for my use case 🥇

@ahuth
Copy link
Contributor

ahuth commented Jul 25, 2024

@ahuth ahuth closed this as completed Jul 25, 2024
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

4 participants