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
getScrollBarSize.tsx 中的方法getTargetScrollBarSize在Firefox 52.9及其以前版本中报错“NS_ERROR_NOT_AVAILABLE” #261
Comments
在较新的浏览器上CSSStyleDeclaration稳定地表现为对象,但是在Firefox较早版本里表现飘忽不定,表现更像是一个数组,但是在偶然情况下又表现为一个对象,具体在什么场景下表现为什么还没有找到规律 |
+1 |
win 10 firefox 52.0.2 下也有问题 |
Firefox 60,遇到同样的问题。自己写了一个 Proxy,凑合用 const ua = navigator.userAgent;
const m = ua.match(/Firefox\/(\d+)/i);
if (m && parseInt(m[1]) <= 60) {
const _getComputedStyle = getComputedStyle;
const handler = {
get: function (obj: any, prop: string) {
try {
return obj[prop];
} catch (e) {
console.log("catch getComputedStyle error", e);
/**
* 如果是 width 或者 height,需要返回字符串,因为 rc-util 直接对接过进行正则匹配,返回空会报错
* https://github.com/react-component/util/blob/780a217fc67a15fc1f9170c107df001b21975f5e/src/getScrollBarSize.tsx#L57
*/
if (prop == "width" || prop == "height") return "";
else return undefined;
}
},
};
window.getComputedStyle = (
elt: Element,
pseudoElt?: string | null | undefined
): CSSStyleDeclaration => {
return new Proxy(_getComputedStyle(elt, pseudoElt), handler);
};
console.log("Firefox 60 以下版本,替换 getComputedStyle 完成");
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2021.5.20的更新中加入的片段
环境:
windows xp 32位
firefox 52.9 esr 32位
Ref:
util/src/getScrollBarSize.tsx
Line 57 in 88be0cb
在firefox52.9(32位)及其以前版本(测试了51\47\46)会提示**"NS_ERROR_NOT_AVAILABLE"**的错误。
我想应该是getComputedStyle返回的CSSStyleDeclaration对象(浏览器中显示CSS2Properties)不可访问导致的。
如何修正这个问题?
The text was updated successfully, but these errors were encountered: