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

':focus-visible' is not supported, yet claims to be in the wiki #54

Closed
sambehrens opened this issue Mar 2, 2022 · 7 comments
Closed

Comments

@sambehrens
Copy link

I ran into an issue where I was using jsdom which uses nwsapi for matching selectors and it was giving me the error SyntaxError: ':focus-visible' is not a valid selector. It doesn't seem like I should be getting this error because in the wiki for nwsapi, it says that the :focus-visible is supported.

Then I looked through the nwsapi repo and didn't see focus-visible where I thought it should exist. Here with the other user actions: https://github.com/dperini/nwsapi/blob/master/src/nwsapi.js#L83

It would be great if this could be supported. Alternatively, the documentation could be updated explaining that it is actually not supported and why.

Reproduce:

<script
  type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/nwsapi@2.2.0/src/nwsapi.js"
></script>
<script>
  NW.Dom.match(":focus-visible", document, () => {});
</script>

Results in Uncaught DOMException: ':focus-visible' is not a valid selector.

On another note, it looks like focus-within throws the same error, even though it looks like it is available in the source code. Not sure why that would be though.

@dospunk
Copy link

dospunk commented Mar 3, 2023

I'm having the same issue with :focus-within and jsdom as well. The error stack trace does come back to nwsapi

The relevant lines of the stack trace are:

at emit (node_modules/nwsapi/src/nwsapi.js:570:17)
at compileSelector (node_modules/nwsapi/src/nwsapi.js:1310:11)
at compile (node_modules/nwsapi/src/nwsapi.js:758:16)
at match_collect (node_modules/nwsapi/src/nwsapi.js:1363:16)
at Object._matches [as match] (node_modules/nwsapi/src/nwsapi.js:1418:35)

@samschurter
Copy link

I've run into problems with :focus-within as well. Perhaps the issues are related to #47 for that selector.

@dperini
Copy link
Owner

dperini commented Mar 13, 2023

I have also tested a different approach to solve this issue. I used the following regular expression, slightly modified:

useraction: '(hover|active|focus[^-]|focus-within)\\b',

which enforces checking for the :focus pseudo-class not being followed by a dash and it seems it works well.

Please test in your environment and report results here.

@dperini dperini closed this as completed Mar 13, 2023
dperini added a commit that referenced this issue Mar 13, 2023
@dospunk
Copy link

dospunk commented May 2, 2023

I'm still getting the SyntaxError: ':focus-within' is not a valid selector error on nwsapi@2.2.4

Edit: Maybe this should be reopened since the fix for focus-within was reverted in 23f9e23

@dperini
Copy link
Owner

dperini commented May 4, 2023

@dospunk
you are correct ... reopening and working on it.
Thank you for reporting the problem.

@dperini
Copy link
Owner

dperini commented May 10, 2024

@sambehrens @samschurter @dospunk
I hope I did resolve this and nwsapi will be ready for 2.2.10 release.

@dperini dperini closed this as completed May 10, 2024
@cbix
Copy link

cbix commented Dec 10, 2024

@dperini apparently this just got reintroduced in 2.2.16, likely with a react-testing-library minor version update on our project:

SyntaxError: 'button#:r3m:.types__StyledButton-sc-ws60qy-0 :focus-visible' is not a valid selector
[...]
      at emit (node_modules/nwsapi/src/nwsapi.js:651:17)
      at _querySelectorAll (node_modules/nwsapi/src/nwsapi.js:1646:9)
      at Object._querySelector [as first] (node_modules/nwsapi/src/nwsapi.js:1555:14)
      at HTMLButtonElement.value [as querySelector] (node_modules/@primer/react/lib/node_modules/@oddbird/popover-polyfill/dist/popover-fn.js:389:23)
      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 Object._matches [as match] (node_modules/nwsapi/src/nwsapi.js:1500:16)
          at Array.forEach (<anonymous>)
          at Array.forEach (<anonymous>)
      at getComputedStyleImplementation (node_modules/dom-accessibility-api/sources/accessible-name-and-description.ts:84:16)
      at isHidden (node_modules/dom-accessibility-api/sources/accessible-name-and-description.ts:570:4)
      at computeTextAlternative (node_modules/dom-accessibility-api/sources/accessible-name-and-description.ts:721:3)
      at computeAccessibleName (node_modules/dom-accessibility-api/sources/accessible-name.ts:40:31)
      at node_modules/@testing-library/dom/dist/queries/role.js:173:82
          at Array.filter (<anonymous>)
      at queryAllByRole (node_modules/@testing-library/dom/dist/queries/role.js:168:6)
      at node_modules/@testing-library/dom/dist/query-helpers.js:74:17
      at node_modules/@testing-library/dom/dist/query-helpers.js:52:17
      at node_modules/@testing-library/dom/dist/query-helpers.js:95:19
      at container.container (node_modules/@testing-library/dom/dist/query-helpers.js:87:14)
      at runWithExpensiveErrorDiagnosticsDisabled (node_modules/@testing-library/dom/dist/config.js:47:12)
      at checkCallback (node_modules/@testing-library/dom/dist/wait-for.js:124:77)
      at checkRealTimersCallback (node_modules/@testing-library/dom/dist/wait-for.js:118:16)

Just checked again and 2.2.13 is the latest working version, the ones between throw a "document not found" error.

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

5 participants