MCPcopy Index your code
hub / github.com/adobe/react-spectrum / isStyleVisible

Function isStyleVisible

packages/react-aria/src/utils/isElementVisible.ts:18–42  ·  view source on GitHub ↗
(element: Element)

Source from the content-addressed store, hash-verified

16 typeof Element !== 'undefined' && 'checkVisibility' in Element.prototype;
17
18function isStyleVisible(element: Element) {
19 const windowObject = getOwnerWindow(element);
20 if (
21 !(element instanceof windowObject.HTMLElement) &&
22 !(element instanceof windowObject.SVGElement)
23 ) {
24 return false;
25 }
26
27 let {display, visibility} = element.style;
28
29 let isVisible = display !== 'none' && visibility !== 'hidden' && visibility !== 'collapse';
30
31 if (isVisible) {
32 const {getComputedStyle} = getOwnerWindow(element);
33 let {display: computedDisplay, visibility: computedVisibility} = getComputedStyle(element);
34
35 isVisible =
36 computedDisplay !== 'none' &&
37 computedVisibility !== 'hidden' &&
38 computedVisibility !== 'collapse';
39 }
40
41 return isVisible;
42}
43
44function isAttributeVisible(element: Element, childElement?: Element) {
45 return (

Callers 1

isElementVisibleFunction · 0.85

Calls 1

getOwnerWindowFunction · 0.90

Tested by

no test coverage detected