Translation of this issue:
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

比如我这一行能 展示超过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, 就会卡死
因为我是单独抽取了这个组件来用,我把代码简单改了一下

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