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

axecore error Cannot read properties of undefined

Open rajsite opened this issue 1 year ago • 1 comments

Product

axe-core

Product Version

4.8.4

Latest Version

  • [X] I have tested the issue with the latest version of the product

Issue Description

Expectation

I expect axe-core to be able to run without error on pages that include a shadow root such as the following: https://axecore-lighthouse-failure.glitch.me/

Actual

Notice in the console of the above page that axe-core runs with a result of incomplete. The incomplete item has:

description: "Ensures role attribute has an appropriate value for the element"

error stack:

TypeError: Cannot read properties of undefined (reading 'props')
    at prepareContext (https://unpkg.com/[email protected]/axe.js:12625:23)
    at _accessibleTextVirtual (https://unpkg.com/[email protected]/axe.js:12573:17)
    at accessibleText (https://unpkg.com/[email protected]/axe.js:9588:14)
    at https://unpkg.com/[email protected]/axe.js:9604:33
    at Array.reduce (<anonymous>)
    at arialabelledbyText (https://unpkg.com/[email protected]/axe.js:9603:19)
    at hasAccessibleName (https://unpkg.com/[email protected]/axe.js:11698:45)
    at section (https://unpkg.com/[email protected]/axe.js:11799:16)
    at implicitRole2 (https://unpkg.com/[email protected]/axe.js:11992:16)
    at getElementUnallowedRoles (https://unpkg.com/[email protected]/axe.js:19359:27)

impact: null

How to Reproduce

See above, example page and discussion to view the axe-core result in the console. Page url preproduced as follows: https://axecore-lighthouse-failure.glitch.me/

Additional context

Any thing else we should know about the issue?

The axe-core error results in lighthouse failing to report any accessibility score at all for the page. Filed lighthouse a separate issue to be more robust to axe-core incomplete results: https://github.com/GoogleChrome/lighthouse/issues/15828

rajsite avatar Feb 22 '24 01:02 rajsite

Thanks for the issue. I took a quick look at it appears that the issue is the aria-labelledby on the section element which points to the slot element. The slot element isn't tracked in our virtual tree so that's why the code is failing.

straker avatar Feb 22 '24 15:02 straker