Skip to content

querySelector(":is([a],b):not(.c)") throws a "not a valid selector" error #3686

@ginpei

Description

@ginpei

Basic info:

  • Node.js version: v20.11.1
  • jsdom version: 24.0.0

jsdom v23.2.0 didn't show this issue.

Minimal reproduction case

const { JSDOM } = require("jsdom");
const dom = new JSDOM('');

dom.window.document.querySelector(`:is([a],b):not(.c)`)
// Uncaught DOMException [SyntaxError]: '[a],b):not(.c' is not a valid selector

dom.window.document.querySelector(`:is(a,[b]):not(.c)`);
// Uncaught DOMException [SyntaxError]: 'a,[b]):not(.c' is not a valid selector

// the followings work
dom.window.document.querySelector(`:is(a,b):not(.c)`);
dom.window.document.querySelector(`:is(a,b):not([c])`);
dom.window.document.querySelector(`:is(a):not([b],.c)`);
dom.window.document.querySelector(`:is(a,[b])`);
dom.window.document.querySelector(`:is(a,[b]):first-child`);
dom.window.document.querySelector(`:is([b]):not(.c)`);

How does similar code behave in browsers?

They don't throw the error.

https://codepen.io/ginpei/pen/BabXQzv

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