Ant-design-pro: Ellipsis组件在firefox下页面加载直接卡死了,报错InternalError: "too much recursion"

Created on 19 Jul 2018  ·  9Comments  ·  Source: ant-design/ant-design-pro

🛑 bug

All 9 comments

Translation of this issue:


Ellipsis component in the firefox page load directly stuck, error InternalError: "too much recursion"

Yes same issue

if (sh <= th) {
shadowNode.innerHTML = text.substring(0, mid + 1) + suffix;
sh = shadowNode.offsetHeight;
if (sh > th) {
return mid;
} else {
begin = mid;
mid = Math.floor((end - begin) / 2) + begin;

            return this.bisection(th, mid, begin, end, text, shadowNode);
        }

if end is 9 and begin is 8, then begin is always 8

还有一个问题,
componentWillReceiveProps(nextProps) {
const { lines } = this.props;
if (lines !== nextProps.lines) {
this.computeLine();
}
}

如果组件的children更新了,组件不会被更新;

@nikogu

@weichunyan @jieliu218 最好能给个 demo 重现。

@sbyps 这个 componentWillReceiveProps 跟子组件更新没有什么关系吧,给个 demo?

@nikogu
image

比如我这一行能 展示超过20个汉字, 但是现在标题只有 八个汉字

if (sh <= th) {
shadowNode.innerHTML = text.substring(0, mid + 1) + suffix;
sh = shadowNode.offsetHeight;
if (sh > th) {
return mid;
} else {
begin = mid;
mid = Math.floor((end - begin) / 2) + begin;
return this.bisection(th, mid, begin, end, text, shadowNode);
}

最终 th = 8, sh = 7, mid = Math.floor((end - begin) / 2) + begin; mid 永远 等于7 , 然后继续调用
this.bisection 就会是死循环, Firefox and IE, 就会卡死

因为我是单独抽取了这个组件来用,我把代码简单改了一下
image

@jieliu218 按照你提供的方式把 Ellipsis 改了下

Was this page helpful?
0 / 5 - 0 ratings

Related issues

skyFi picture skyFi  ·  3Comments

lvzheng0404 picture lvzheng0404  ·  3Comments

yadongxie150 picture yadongxie150  ·  3Comments

952425340 picture 952425340  ·  3Comments

Yoping picture Yoping  ·  3Comments