Skip to content

:matches() CSS pseudo-class does not match any elements in querySelectorAll() #3013

@danburzo

Description

@danburzo

Basic info:

  • Node.js version: v14.2.0 (local), v10.21.0 (Runkit)
  • jsdom version: 16.3.0

Minimal reproduction case

let { JSDOM } = require('jsdom');
let doc = new JSDOM(`
    <h2>Heading</h2>
    <h3>Subheading</h3>
`).window.document;

console.log([...doc.querySelectorAll('h2,h3')]); // => 2 elements
console.log([...doc.querySelectorAll(':matches(h2,h3)')]); // => 0 elements

Runkit live demo

How does similar code behave in browsers?

In Firefox 78, which supports the :is() selector, both queries result in two elements. Safari, for :matches(), and Chrome, for :-webkit-any(), give the same result.

I know things are still in flux in regards to the :is() and :where() pseudo-classes, but since the :matches() selector exists in JSDOM it is suprising behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    selectorsCSS Selectors support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions