Skip to content

Update code to use new cache of idRefs to improve performance #2647

@straker

Description

@straker

From @WilcoFiers in regards to #2635:

I think there are a lot more places in axe-core that now we have a cache of ID references we could speed up. Probably best to open a tech debt issue for that one instead of pile it onto this PR. Here's a list though:

  • checks
    • aria-required-parent-evaluate
    • explicit-evaluate
    • hidden-explicit-label-evaluate
    • multiple-labels
    • duplicate-id-evaluate
  • matches
    • duplicate-id-active-matches
    • duplicate-id-misc-matches
    • scrollable-region-focusable-matches
  • commons
    • text.labelVirtual
    • dom.findElmsInContext
    • dom.isVisible (usemap lookup)

To make that easier, we can probably simplify by having something like a idrefsReverse function, that takes a node (with an ID) and an attribute and looks up any element references the ID with that attribute. I'll leave it up to you if you want to do that in this PR or another.

const virtualControls = idrefsReverse(ancestorNode, 'aria-labelledby')
	.map(control => getNodeFromTree(control));

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions