Repository navigation
fix: look up tab nodes by data-node-key attribute without unescaped selector interpolation - #1031
mokshupadhyay wants to merge 1 commit into
Conversation
…elector interpolation
|
@mokshupadhyay is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough标签尺寸更新改用节点键映射查找对应节点,不再为每个标签单独构造选择器并查询。新增回归测试,覆盖含反斜杠或换行符的标签键及其 ink bar 宽度。 Changes标签尺寸查询
Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk:
|
TabNavListmeasures the size of each tab by looking up its node withquerySelector('[data-node-key="..."]'), with the key written into the selector aftergenDataNodeKeyreplaced only double quotes. A tab key that contains a backslash or a newline makes an invalid selector, and the tabs throw while measuring:(The same class of error as react-component/cascader#674, where option values with a backslash or newline broke a selector.) A key such as a Windows path (
C:\files) or a value that came from user data reaches this.The measurement now reads the
data-node-keyattribute of the nodes once into aMapand looks each tab up bygenDataNodeKey(key), so no selector is built from keys.TabNodestill writesdata-node-key={genDataNodeKey(key)}, so both sides use the same value.Test:
key contains backslash or newline should not crash and still measures tab sizeintests/index.test.tsxfails onmasterwith theSyntaxErrorabove and passes now.npm test(6 suites, 112 tests),npm run tsc,npm run lint(0 errors) and prettier on the changed files pass.Summary by CodeRabbit