MCPcopy Create free account
hub / github.com/adobe/react-spectrum / isStyleVisible

Function isStyleVisible

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

Source from the content-addressed store, hash-verified

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

Callers 1

isElementVisibleFunction · 0.85

Calls 1

getOwnerWindowFunction · 0.90

Tested by

no test coverage detected