Code Monkey home page Code Monkey logo

Comments (6)

DeronW avatar DeronW commented on September 16, 2024 1

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 完成");
}

from util.

ppmmwozuiai avatar ppmmwozuiai commented on September 16, 2024

@zombieJ

from util.

ppmmwozuiai avatar ppmmwozuiai commented on September 16, 2024

在较新的浏览器上CSSStyleDeclaration稳定地表现为对象,但是在Firefox较早版本里表现飘忽不定,表现更像是一个数组,但是在偶然情况下又表现为一个对象,具体在什么场景下表现为什么还没有找到规律

from util.

shaodahong avatar shaodahong commented on September 16, 2024

image

看了一下 -webkit-scrollbar 是有兼容性的问题,但是时好时坏这个……

from util.

jaryway avatar jaryway commented on September 16, 2024

+1

from util.

jaryway avatar jaryway commented on September 16, 2024

win 10 firefox 52.0.2 下也有问题

from util.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.