axe-core icon indicating copy to clipboard operation
axe-core copied to clipboard

"td-has-header" or no other rule fails when the 'headers' attribute on a <th> element is empty

Open iamrafan opened this issue 5 years ago • 3 comments

td-has-header fails when <td> element has headers="" but not when <th> element has headers=""

Expectation: Flag <th> elements with headers=""

Actual: <th> elements with headers="" are not flagged

Motivation: There is a chance an author might have missed pointing the <th> (i.e. sub-heading) element to the parent header

Repro example:

    <table>
        <tr>
            <th rowspan="2" id="h">Homework</th>
            <th colspan="3" id="e">Exams</th>
            <th colspan="3" id="p">Projects</th>
        </tr>
        <tr>
            <th id="e1" headers="e">1</th>
            <th id="e2" headers="e">2</th>
            <th id="ef" headers="e">Final</th>
            <th id="p1" headers="p">1</th>
            <th id="p2" headers="">2</th>
            <th id="pf" headers="p">Final</th>
        </tr>
        <tr>
            <td headers="h">15%</td>
            <td headers="e e1">15%</td>
            <td headers="e e2">15%</td>
            <td headers="e ef">20%</td>
            <td headers="p p1">10%</td>
            <td headers="p p2">10%</td>
            <td headers="p pf">15%</td>
        </tr>
    </table>

axe-core version: 3.4.1-canary.6e4ed6b
axe-Coconut version: v4.2.1 

iamrafan avatar Feb 06 '20 22:02 iamrafan

Thanks for the issue.

straker avatar Feb 07 '20 18:02 straker

I'm not sure this should fail. I don't think we can say that with any kind of certainty. I'd be more inclined to mark an empty headers attribute for review in the td-headers-attr rule instead. Perhaps we can include th elements in that rule?

WilcoFiers avatar Feb 11 '20 17:02 WilcoFiers

@iamrafan any thoughts?

WilcoFiers avatar Aug 28 '20 12:08 WilcoFiers