happy-dom icon indicating copy to clipboard operation
happy-dom copied to clipboard

Invalid selector "[q\\:shadowroot]"

Open ianlet opened this issue 4 months ago • 0 comments

I'm one of the maintainers of https://github.com/ianlet/qwik-testing-library and I'm working on adding support for happy-dom for devs who prefer using it.

Unfortunately, we're not yet able to even start a test suite because of an Invalid selector "[q\\:shadowroot]" error is raised when trying to render a Qwik app.

Describe the bug In Qwik, we use different selectors which contain a : colon to query the DOM, but it seems to be rejected by happy-dom even though they are valid selectors (and accepted by all browsers + jsdom).

Here's are some examples:

document.querySelectorAll("[q\\:shadowroot]");
document.querySelectorAll("[on\\:qvisible]");
document.querySelectorAll("[on\\:qinit]");
// ...

Which will trigger the following error with happy-dom:

DOMException: Invalid selector: "[q\:shadowroot]"
    at Function.getSelectorGroups (file:///home/ian/Projects/noma/node_modules/.pnpm/[email protected]/node_modules/happy-dom/src/query-selector/SelectorParser.ts:214:10)
    at Function.querySelectorAll (file:///home/ian/Projects/noma/node_modules/.pnpm/[email protected]/node_modules/happy-dom/src/query-selector/QuerySelector.ts:116:33)
    at HTMLDocument.querySelectorAll (file:///home/ian/Projects/noma/node_modules/.pnpm/[email protected]/node_modules/happy-dom/src/nodes/document/Document.ts:658:24)

Expected behavior Valid selectors shouldn't be rejected.

Additional context

    "happy-dom": "^15.7.4",

Seems to be related to those issues: https://github.com/capricorn86/happy-dom/issues/1559 https://github.com/capricorn86/happy-dom/issues/1558

ianlet avatar Oct 07 '24 19:10 ianlet