nwsapi: v2.2.3 DOMException [SyntaxError]: '.disabled):not(:disabled)' is not a valid selector
The following selector was used successfully in v2.2.2 but raises a syntax error v2.2.3:
[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)
This selector is used by the Bootstrap library:
Script to reproduce:
const jsdom = require('jsdom');
const dom = new jsdom.JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
dom.window.document.querySelectorAll('[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)');
$ node test.js
.../node_modules/nwsapi/src/nwsapi.js:559
throw err;
^
DOMException [SyntaxError]: '.disabled):not(:disabled)' is not a valid selector
at emit (.../node_modules/nwsapi/src/nwsapi.js:557:17)
at Object._matches [as match] (.../node_modules/nwsapi/src/nwsapi.js:1400:9)
at Array.Resolver (eval at compile (.../node_modules/nwsapi/src/nwsapi.js:760:17), <anonymous>:3:105)
at collect (.../node_modules/nwsapi/src/nwsapi.js:1552:21)
at Object._querySelectorAll [as select] (.../node_modules/nwsapi/src/nwsapi.js:1509:36)
at DocumentImpl.querySelectorAll (.../node_modules/jsdom/lib/jsdom/living/nodes/ParentNode-impl.js:78:26)
at Document.querySelectorAll (.../node_modules/jsdom/lib/jsdom/living/generated/Document.js:1051:58)
at Object.<anonymous> (.../test.js:4:21)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
Node.js v18.15.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 26 (6 by maintainers)
I have exactly the same issue. I’m also using Chakra and React testing library. I had to use
overrideslike thisThis resolves the issue but I wonder how this can be resolved permanently.
I also use chraka-ui and 2.2.4 also does not work for me. This is what I get: SyntaxError: ‘:disabled):not([disabled]’ is not a valid selector I get this when running component tests with jest. If I override to 2.2.2, it all works fine.
Confirm the problem with Chakra and React testing library.
We were having the same issue, it is saying that the selector is not valid, rolling back to the 2.2.2 version in the
package-lock.jsonworks fine for us.for yarn
It helped, thanks. However, I’m looking forward permanent solution.
Also confirming, and for anyone who struggles with it, for overrides to work properly you need npm 8.6.0.
For me 2.2.4 does not work. I use chakra-ui and they use this selector “button:not(:disabled):not([disabled])”. I used “resolutions” in package.json to force 2.2.4. My tests still fail. With 2.2.2 they work.
@dperini the fix in your commit appears to be working, though I don’t see it in v2.2.4. Will it be released in v2.2.5 soon?
In the package.json file below the “devDependencies”