inline-critical
inline-critical copied to clipboard
document.querySelector throws error with bad selector
This library is being run via rollup-plugin-critical -> critical -> inline-critical
When trying to generate an inline stylesheet, the code falls over at https://github.com/bezoerb/inline-critical/blob/main/index.js#L80-L81 with an error of:
ERROR 'noscript)>[rel="stylesheet"]' 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 _querySelectorAll (node_modules/nwsapi/src/nwsapi.js:1509:36)
at Object._querySelector [as first] (node_modules/nwsapi/src/nwsapi.js:1415:14)
at DocumentImpl.querySelector (node_modules/inline-critical/node_modules/jsdom/lib/jsdom/living/nodes/ParentNode-impl.js:69:44)
at Document.querySelector (node_modules/inline-critical/node_modules/jsdom/lib/jsdom/living/generated/Document.js:1026:58)
at Dom.querySelector (node_modules/inline-critical/src/dom.js:155:26)
at inline (node_modules/inline-critical/index.js:85:27)
This isn't the selector being passed in (that would be :not(noscript) > [rel="stylesheet"]
) but somewhere around the nwsapi
it gets mangled and comes out as a bad selector.
If I comment out these selectors in the code, it works. Adding a selector as an option has no effect as all selectors are evaluated.