| 126 | // If something like :focus-within or a more specific selector like `.blah:has(:focus-visible)` for elements inside, | 126 | // If something like :focus-within or a more specific selector like `.blah:has(:focus-visible)` for elements inside, |
| 127 | // it should be manually defined in CSS. | 127 | // it should be manually defined in CSS. |
| 128 | const focusSelector = rule.selectorText.replace(/:hover/g, ':focus-visible'); | 128 | const focusSelector = rule.selectorText.replace(/:hover/g, ':focus-visible'); |
| | 129 | |
| | 130 | // Skip pseudo-elements (::before, ::after, ::-webkit-scrollbar, etc.) |
| | 131 | // as they cannot have :focus-visible appended (invalid CSS syntax) |
| | 132 | if (focusSelector.includes('::')) { |
| | 133 | return; |
| | 134 | } |
| 129 | let focusRule = `${focusSelector} { ${rule.style.cssText} }`; | 135 | let focusRule = `${focusSelector} { ${rule.style.cssText} }`; |
| 130 | | 136 | |
| 131 | // Wrap the generated rule into the same @media/@supports/@container chain (if any) | 137 | // Wrap the generated rule into the same @media/@supports/@container chain (if any) |