web-accessibility icon indicating copy to clipboard operation
web-accessibility copied to clipboard

[div onclick="doStuff()"] should trigger an error

Open Dan503 opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe. Dev's will commonly use <div> elements for buttons when they should be using <button> elements instead.

Describe the solution you'd like <div onclick="doStuff()"> should trigger an error different to the typical "Use Semantic HTML5 or specify a WAI-ARIA role [role=""]" warning.

It should say something like "Use a <button> element instead of a <div> element for interactive controls."

Dan503 avatar Jun 06 '20 09:06 Dan503

He @Dan503 I think that's a good addition to the check, will look in to it!

mvdschee avatar Sep 30 '20 19:09 mvdschee

There are legitimate cases for adding div[onclick] so there should also be a way to ignore this rule.

(eg. Making a card clickable without wrapping the whole card in a link while making the heading inside the card an <a> element)

Dan503 avatar Sep 30 '20 20:09 Dan503