Skip to content

include/exclude option may not be matching correctly #2436

@straker

Description

@straker

When calling audit.run and passing it an include/exclude context, we do not flatten the tree anywhere, so are passing actual DOM nodes into rule.run which tries to gather the nodes using querySelectorAll but doesn't pass virtual nodes, causing them to never match the context due to matchesExpression requiring virtual nodes to match.

All the errors are being swallowed by axe so I only stumbled upon it in the tests when turning on break on caught exceptions.

"TypeError: Cannot read property 'nodeType' of undefined
    at matchesTag (http://localhost:9876/tmp/core/core.js:30296:26)
    at matchExpression (http://localhost:9876/tmp/core/core.js:30331:14)
    at matchesExpression (http://localhost:9876/tmp/core/core.js:30517:21)
    at matchExpressions (http://localhost:9876/tmp/core/core.js:32447:147)
    at querySelectorAllFilter (http://localhost:9876/tmp/core/core.js:32504:14)
    at select (http://localhost:9876/tmp/core/core.js:33233:109)
    at Rule.gather (http://localhost:9876/tmp/core/core.js:23224:75)
    at Rule.gatherAndMatchNodes (http://localhost:9876/tmp/core/core.js:23538:24)
    at Rule.run (http://localhost:9876/tmp/core/core.js:23317:22)
    at http://localhost:9876/tmp/core/core.js:21372:14"

(I'm not sure if it's any different if passing include/exclude from axe.run)

Metadata

Metadata

Assignees

No one assigned

    Labels

    prA pr has been created for the issuetech debtTechnical debt related tasks

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions