getScrollBarSize.tsx 中的方法getTargetScrollBarSize在Firefox 52.9及其以前版本中报错“NS_ERROR_NOT_AVAILABLE”
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- frontend
调研方向
从 src/getScrollBarSize.tsx 中的 getTargetScrollBarSize 开始,重点检查使用 ::-webkit-scrollbar 伪元素的 getComputedStyle 调用。在 Firefox 52.9 ESR 或更早版本中复现该问题,并检查现有的 ensureSize 路径。完成的标准是旧版 Firefox 错误不再发生,同时滚动条的宽度和高度仍可供调用方使用。
由索引模型根据 Issue 内容生成。
描述
2021.5.20的更新中加入的片段
环境:
windows xp 32位
firefox 52.9 esr 32位
function ensureSize(str: string) {
const match = str.match(/^(.*)px$/);
const value = Number(match?.[1]);
return Number.isNaN(value) ? getScrollBarSize() : value;
}
export function getTargetScrollBarSize(target: HTMLElement) {
if (typeof document === 'undefined' || !target) {
return { width: 0, height: 0 };
}
const { width, height } = getComputedStyle(target, '::-webkit-scrollbar'); // 此行在Firefox中提示错误
return {
width: ensureSize(width),
height: ensureSize(height),
};
}
在firefox52.9(32位)及其以前版本(测试了51\47\46)会提示**"NS_ERROR_NOT_AVAILABLE"**的错误。
我想应该是getComputedStyle返回的CSSStyleDeclaration对象(浏览器中显示CSS2Properties)不可访问导致的。
如何修正这个问题?
- 主要语言
- TypeScript
- 星标
- 670
- 派生
- 205
- 平均合并
- 15 天 17 小时
- 30 天内合并 PR
- 6
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
react-component/util 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
react-component/util#816 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
react-component/util#671 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
react-component/util#738 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 25/100
react-component/util#710 ·
-
难度 3/5 1-2 天 新手友好度 25/100
react-component/util#647 · 5 条评论 ·
查看 react-component/util 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
ontola/atomic-server#1625 ·
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
melgarafael/DeskcommCRM#1451 ·
-
难度 1/5 1 小时以内 新手友好度 82/100
-
bug via-triage
难度 2/5 1-3 小时 新手友好度 78/100
-
bot:ai-assisted component:compact-js status:untriaged
难度 2/5 1-3 小时 新手友好度 84/100
midnightntwrk/midnight-sdk#403 ·