validator icon indicating copy to clipboard operation
validator copied to clipboard

Redundant aria attributes only detected when native boolean attribute has a value

Open dd8 opened this issue 4 years ago • 1 comments

The message 'Attribute aria-readonly must not be specified on elements that have attribute readonly' only fires for the third example here:

<input type='text' readonly aria-readonly='false' />
<input type='text' readonly='' aria-readonly='false' />
<input type='text' readonly='readonly' aria-readonly='false' />

The message 'Attribute aria-disabled must not be specified on elements that have attribute disabled' only fires for the third example here:

<input type='text' disabled aria-disabled='false' />
<input type='text' disabled='' aria-disabled='false' />
<input type='text' disabled='disabled' aria-disabled='false' />

The same problem happens with

<input type='text' required aria-required='false' />
<input type='text' required='' aria-required='false' />
<input type='text' required='required' aria-required='false' />

<div hidden aria-hidden='false'></div>
<div hidden='' aria-hidden='false'></div>
<div hidden='hidden' aria-hidden='false'></div>

We can submit some test cases as a WPT PR - would that be useful?

dd8 avatar Jul 22 '21 09:07 dd8

I had a look at the code in Assertions.java - I think the problem is

.1762 boolean isEmptyAtt = "".equals(atts.getValue(i));

This is set for all empty attributes - including native ones like disabled and readonly - but should probably only be set for empty aria-* attributes (and perhaps renamed isEmptyAriaAtt).

https://github.com/validator/validator/commit/1eac20b7e5c186a3172fadd2a246bbb160e17411

dd8 avatar Jul 23 '21 10:07 dd8