diff --git a/package.json b/package.json index 58e90014..d999d992 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "create-react-class": "^15.6.3", "cross-env": "^7.0.2", "dumi": "^2.1.3", - "eslint": "~7.31.0", + "eslint": "~7.32.0", "father": "^4.1.3", "glob": "^7.1.6", "husky": "^8.0.3", diff --git a/src/Dom/isVisible.ts b/src/Dom/isVisible.ts index 825f79fa..13dea10c 100644 --- a/src/Dom/isVisible.ts +++ b/src/Dom/isVisible.ts @@ -1,23 +1,25 @@ -export default (element: HTMLElement | SVGGraphicsElement): boolean => { +export default (element: Element): boolean => { if (!element) { return false; } - if (element instanceof HTMLElement && element.offsetParent) { - return true; - } - - if (element instanceof SVGGraphicsElement && element.getBBox) { - const { width, height } = element.getBBox(); - if (width || height) { + if (element instanceof Element) { + if ((element as HTMLElement).offsetParent) { return true; } - } - if (element instanceof HTMLElement && element.getBoundingClientRect) { - const { width, height } = element.getBoundingClientRect(); - if (width || height) { - return true; + if ((element as SVGGraphicsElement).getBBox) { + const { width, height } = (element as SVGGraphicsElement).getBBox(); + if (width || height) { + return true; + } + } + + if (element.getBoundingClientRect) { + const { width, height } = element.getBoundingClientRect(); + if (width || height) { + return true; + } } }