Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: ':is(:is(button, input)[type=submit], button:not([type])):not([disabled]):not([form])' is not a valid selector #127

Open
Enes5519 opened this issue Sep 11, 2024 · 5 comments

Comments

@Enes5519
Copy link

I am using a button inside a custom elements library to submit a form. When I call this.closest('form') from inside that button, I get this error.

@testing-library/[email protected]
[email protected]
[email protected]
[email protected]

Library: https://github.com/Trendyol/baklava/blob/next/src/components/button/bl-button.ts#L151

SyntaxError: ':is(:is(button, input)[type=submit], button:not([type])):not([disabled]):not([form])' is not a valid selector
    at emit (/Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/nwsapi/src/nwsapi.js:575:17)
    at compileSelector (/Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/nwsapi/src/nwsapi.js:1308:11)
    at compile (/Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/nwsapi/src/nwsapi.js:762:16)
    at match_collect (/Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/nwsapi/src/nwsapi.js:1366:16)
    at _matches (/Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/nwsapi/src/nwsapi.js:1421:35)
    at Object._closest [as closest] (/Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/nwsapi/src/nwsapi.js:1350:13)
    at HTMLElementImpl.closest (/Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:550:20)
    at e.closest (/Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/jsdom/lib/jsdom/living/generated/Element.js:632:58)
    at HTMLFormElement.<anonymous> (file:///Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/@trendyol/baklava/node_modules/element-internals-polyfill/dist/index.js:267:24)
    at HTMLFormElement.callTheUserObjectsOperation (/Users/enes.yildirim/Projects/bc-advert-web-app/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)
@chenshuai2144
Copy link

same error

SyntaxError: ':scope +.ant-select-item-option-selected:not(.ant-select-item-option-disabled))+.ant-select-item-option-selected:not(.ant-select-item-option-disabled' is not a valid selector

vitest + @testing-library/react 只要使用 findAllByxxx 就会报错

@dperini
Copy link
Owner

dperini commented Dec 18, 2024

@chenshuai2144

Yes the selector you showed above is wrong.

document.querySelector(':scope +.ant-select-item-option-selected:not(.ant-select-item-option-disabled))+.ant-select-item-option-selected:not(.ant-select-item-option-disabled');

the first :not() instance terminates with an extra parenthesis.

This is the corrected broken down corrected version:

document.querySelectorAll(':scope
+.ant-select-item-option-selected
:not(.ant-select-item-option-disabled)
+.ant-select-item-option-selected
:not(.ant-select-item-option-disabled)');

@theishinz-maersk
Copy link

I have same issue in a project and I have upgraded to NWSAPI v2.2.16 which is the latest at this point. Is this issue not resolved?

I try to use testing library to click fireEvent.click(anHtmlButtonElement); and it returns.
The selector is calls is not something I have created. It must have been created by jsdom or by nwsapi.

SyntaxError: 'button[type=submit],input[type=submit],button:not([type])):not([disabled]):not([form]' is not a valid selector
    at emit (.../node_modules/nwsapi/src/nwsapi.js:651:17)
    at compileSelector (.../node_modules/nwsapi/src/nwsapi.js:1431:11)
    at compile (.../node_modules/nwsapi/src/nwsapi.js:838:16)
    at match_collect (.../node_modules/nwsapi/src/nwsapi.js:1489:16)
    at Object._matches [as match] (.../node_modules/nwsapi/src/nwsapi.js:1544:35)
    at Array.Resolver (eval at compile (.../node_modules/nwsapi/src/nwsapi.js:853:17), <anonymous>:3:67)
    at match_assert (.../node_modules/nwsapi/src/nwsapi.js:1482:13)
    at _matches (.../node_modules/nwsapi/src/nwsapi.js:1546:14)
    at Object._closest [as closest] (.../node_modules/nwsapi/src/nwsapi.js:1473:13)
    at HTMLElementImpl.closest (.../node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:550:20)

@theishinz-maersk
Copy link

I see it is not released yet. I hope it gets released soon. Isn't there many with this issue and needs it resolved?

@theishinz-maersk
Copy link

For future records. I bypassed the issue by adding polyfill.
In jest.polyfills.js

import "element-internals-polyfill";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants