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 not matched unless element has autofocus property set #122

Open
mattclough1 opened this issue Aug 6, 2024 · 0 comments
Open

Comments

@mattclough1
Copy link

mattclough1 commented Aug 6, 2024

I'm trying my best to follow the source code, but the logic for the :focus-visible selector:

nwsapi/src/nwsapi.js

Lines 1098 to 1103 in 088475f

case 'focus-visible':
source = 'hasFocus' in doc ?
'if(s.isFocusable(e)){' +
'n=s.doc.activeElement;if(e!==n){while(e){e=e.parentElement;if(e===n)break;}}}' +
'if((e===n&&e.autofocus)){' + source + '}' : source;
break;

seems to only match an element if it's the same element as document.activeElement and has the property autofocus. If this is true, why? For context, some code I'm testing that uses .match(':focus-visible') matches in the browser, but fails to match in JSDOM unless I add autofocus to the element. I don't think this property is part of the general heuristics that browsers use to determine a match on this selector.

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

1 participant