MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / isShownInternal

Function isShownInternal

javascript/atoms/typescript/is-displayed.ts:368–471  ·  view source on GitHub ↗
(elem: Element, ignoreOpacity: boolean, displayedFn: (element: Node) => boolean)

Source from the content-addressed store, hash-verified

366 }
367
368 function isShownInternal(elem: Element, ignoreOpacity: boolean, displayedFn: (element: Node) => boolean): boolean {
369 if (!isElement(elem)) {
370 throw new Error('Argument to isShown must be of type Element');
371 }
372
373 if (isElement(elem, 'BODY')) {
374 return true;
375 }
376
377 if (isElement(elem, 'OPTION') || isElement(elem, 'OPTGROUP')) {
378 var select = (elem as Element).closest('select');
379 return !!select && isShownInternal(select, true, displayedFn);
380 }
381
382 var imageMap = maybeFindImageMap(elem);
383 if (imageMap) {
384 return !!imageMap.image && imageMap.rect.width > 0 && imageMap.rect.height > 0 &&
385 isShownInternal(imageMap.image, ignoreOpacity, displayedFn);
386 }
387
388 if (isElement(elem, 'INPUT') && (elem as HTMLInputElement).type.toLowerCase() === 'hidden') {
389 return false;
390 }
391
392 if (isElement(elem, 'NOSCRIPT')) {
393 return false;
394 }
395
396 var visibility = getEffectiveStyle(elem, 'visibility');
397 if (visibility === 'collapse' || visibility === 'hidden') {
398 return false;
399 }
400
401 if (!displayedFn(elem)) {
402 return false;
403 }
404
405 if (!ignoreOpacity && getOpacity(elem) === 0) {
406 return false;
407 }
408
409 function positiveSize(element: Element): boolean {
410 var rect = getClientRect(element);
411 if (rect.height > 0 && rect.width > 0) {
412 return true;
413 }
414
415 if (isElement(element, 'PATH') && (rect.height > 0 || rect.width > 0)) {
416 var strokeWidth = getEffectiveStyle(element, 'stroke-width');
417 return !!strokeWidth && parseInt(strokeWidth, 10) > 0;
418 }
419
420 var elementVisibility = getEffectiveStyle(element, 'visibility');
421 if (elementVisibility === 'collapse' || elementVisibility === 'hidden') {
422 return false;
423 }
424
425 if (!displayedFn(element)) {

Callers 1

is-displayed.tsFile · 0.85

Calls 6

maybeFindImageMapFunction · 0.85
getEffectiveStyleFunction · 0.85
getOpacityFunction · 0.85
isElementFunction · 0.70
positiveSizeFunction · 0.70
hiddenByOverflowFunction · 0.70

Tested by

no test coverage detected