LCOV - code coverage report
Current view: top level - src/utils - modalUtil.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 53.8 % 26 14
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1            0 : function isElementHidden(style: CSSStyleDeclaration): boolean {
       2            0 :   return (
       3              :     style.display === 'none' ||
       4              :     style.display === 'contents' ||
       5              :     style.visibility === 'hidden' ||
       6              :     style.visibility === 'collapse' ||
       7              :     style.contentVisibility === 'hidden'
       8              :   )
       9              : }
      10              : 
      11            0 : function ancestorHidesDescendants(style: CSSStyleDeclaration): boolean {
      12            0 :   return style.display === 'none' || style.contentVisibility === 'hidden'
      13              : }
      14              : 
      15            0 : function closedDetailsHidesElement(
      16              :   ancestor: HTMLElement,
      17              :   element: Element
      18              : ): boolean {
      19            0 :   if (!(ancestor instanceof HTMLDetailsElement) || ancestor.open) return false
      20              : 
      21              :   const summary = Array.from(ancestor.children).find(
      22              :     (child): child is HTMLElement =>
      23              :       child instanceof HTMLElement && child.tagName === 'SUMMARY'
      24              :   )
      25            0 :   return summary?.contains(element) !== true
      26              : }
      27              : 
      28         4866 : function isRendered(element: Element): boolean {
      29         4866 :   if (element.closest('[hidden], [aria-hidden="true"]') !== null) return false
      30              : 
      31         4800 :   if (typeof element.checkVisibility !== 'function') {
      32            0 :     if (isElementHidden(getComputedStyle(element))) return false
      33              : 
      34            0 :     for (
      35              :       let current = element.parentElement;
      36              :       current;
      37              :       current = current.parentElement
      38              :     ) {
      39            0 :       if (closedDetailsHidesElement(current, element)) return false
      40            0 :       if (ancestorHidesDescendants(getComputedStyle(current))) return false
      41              :     }
      42              : 
      43            0 :     return true
      44              :   }
      45              : 
      46         4668 :   return element.checkVisibility({ visibilityProperty: true })
      47              : }
      48              : 
      49         1613 : function hasOpenRekaDialog(): boolean {
      50         1613 :   return Array.from(
      51              :     document.querySelectorAll('[role="dialog"][data-state="open"]')
      52              :   ).some(
      53              :     (dialog) =>
      54              :       dialog.closest('[data-reka-popper-content-wrapper]') === null &&
      55              :       isRendered(dialog)
      56              :   )
      57              : }
      58              : 
      59         1607 : function hasOpenNativeDialog(): boolean {
      60         1607 :   return Array.from(document.querySelectorAll('dialog[open]')).some(isRendered)
      61              : }
      62              : 
      63         1623 : function hasVisibleAriaModal(): boolean {
      64         1623 :   return Array.from(
      65              :     document.querySelectorAll('[role="dialog"][aria-modal="true"]')
      66              :   ).some(isRendered)
      67              : }
      68              : 
      69         1607 : function hasVisibleLegacyModal(): boolean {
      70         1607 :   return Array.from(document.querySelectorAll('.comfy-modal')).some(isRendered)
      71              : }
      72              : 
      73         1645 : export function isModalOpen(managedDialogCount: number): boolean {
      74         1645 :   return (
      75              :     managedDialogCount > 0 ||
      76              :     hasVisibleAriaModal() ||
      77              :     hasOpenRekaDialog() ||
      78              :     hasOpenNativeDialog() ||
      79              :     hasVisibleLegacyModal()
      80              :   )
      81              : }
        

Generated by: LCOV version 2.0-1