fix: use :scope instead of & in relative querySelector - #4131
Open
fastfrwrd wants to merge 1 commit into
Open
Conversation
getRowToScroll/getCellToScroll build a relative selector to find the focused row/cell within the grid element. They prefix it with the CSS-nesting `&` combinator. Chromium happens to accept `&` at the start of a querySelector argument, but the standard token for "the element querySelector was called on" is `:scope`. Environments whose selector engine follows the spec strictly — for example jsdom (nwsapi), widely used in unit tests — throw `SyntaxError: '& > [role="row"]...' is not a valid selector`, breaking header and cell focus. Use `:scope`, which is equivalent in the browser and valid everywhere.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4131 +/- ##
=======================================
Coverage 97.54% 97.54%
=======================================
Files 39 39
Lines 1588 1588
Branches 515 515
=======================================
Hits 1549 1549
Misses 39 39
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getRowToScroll/getCellToScrollinsrc/utils/domUtils.tsbuild a relative selector to locate the focused row/cell inside the grid element, prefixed with the CSS-nesting&combinator:Chromium accepts a leading
&in aquerySelectorargument, but the standard token for "the elementquerySelectorwas called on" is:scope. Selector engines that follow the spec strictly — notably jsdom (nwsapi), widely used in unit tests — throw:This breaks header/cell focus (
selectHeaderCell→setPosition→getCellToScroll) in any jsdom-based test that clicks a header, and anywhere the engine doesn't special-case&.Change
Replace the leading
&with:scopein both helpers.:scope > …is equivalent in the browser and valid across DOM implementations. No in-browser behavior change; the existing browser test suite is unaffected.🤖 Generated with Claude Code