We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d063692 commit 8c8b92dCopy full SHA for 8c8b92d
1 file changed
src/ellipsisText/index.tsx
@@ -78,6 +78,9 @@ const EllipsisText = (props: IEllipsisTextProps) => {
78
* @return {*}
79
*/
80
const getStyle = (dom: NewHTMLElement, attr: string) => {
81
+ if (!dom) {
82
+ return null;
83
+ }
84
// Compatible width IE8
85
// @ts-ignore
86
return window.getComputedStyle(dom)[attr] || dom.currentStyle[attr];
@@ -203,7 +206,11 @@ const EllipsisText = (props: IEllipsisTextProps) => {
203
206
204
207
205
208
const onResize = () => {
- const ellipsisNode = ellipsisRef.current!;
209
+ if (!ellipsisRef.current) {
210
+ return;
211
212
+
213
+ const ellipsisNode = ellipsisRef.current;
214
const parentElement = ellipsisNode.parentElement!;
215
const rangeWidth = getRangeWidth(ellipsisNode);
216
const containerWidth = getContainerWidth(parentElement);
0 commit comments