@@ -410,11 +410,12 @@ export const toBePartial = comparator((actual, expected) => {
410410
411411/**
412412 * Hidden elements are elements that have:
413- * 1. Display property set to "none"
414- * 2. Width and height set to 0 (check not applied in jest)
415- * 3. A hidden parent element (this also hides child elements)
416- * 4. Type equal to "hidden" (only for form elements)
417- * 5. A "hidden" attribute
413+ * 1. Display or visibility style properties set to "none" or "hidden"
414+ * 2. Display or visibility computed styles set to "none" or "hidden"
415+ * 3. Width and height set to 0 (check not applied in jest)
416+ * 4. A hidden parent element (this also hides child elements)
417+ * 5. Type equal to "hidden" (only for form elements)
418+ * 6. A "hidden" attribute
418419 */
419420function isHidden ( elOrSelector : HTMLElement | string ) : boolean {
420421 let el = $ ( elOrSelector ) [ 0 ] ;
@@ -425,8 +426,8 @@ function isHidden(elOrSelector: HTMLElement | string): boolean {
425426
426427 const hiddenWhen = [
427428 ( el ) => ! ( el . offsetWidth || el . offsetHeight || el . getClientRects ( ) . length ) ,
428- ( el ) => el . style . display === 'none' ,
429- ( el ) => el . style . visibility === 'hidden' ,
429+ ( el ) => el . style . display === 'none' || window . getComputedStyle ( el ) . getPropertyValue ?. ( 'display' ) === 'none' ,
430+ ( el ) => el . style . visibility === 'hidden' || window . getComputedStyle ( el ) . getPropertyValue ?. ( 'visibility' ) === 'hidden' ,
430431 ( el ) => el . type === 'hidden' ,
431432 ( el ) => el . hasAttribute ( 'hidden' ) ,
432433 ] ;
@@ -454,11 +455,12 @@ function isHidden(elOrSelector: HTMLElement | string): boolean {
454455
455456/**
456457 * Hidden elements are elements that have:
457- * 1. Display property set to "none"
458- * 2. Width and height set to 0
459- * 3. A hidden parent element (this also hides child elements)
460- * 4. Type equal to "hidden" (only for form elements)
461- * 5. A "hidden" attribute
458+ * 1. Display or visibility style properties set to "none" or "hidden"
459+ * 2. Display or visibility computed styles set to "none" or "hidden"
460+ * 3. Width and height set to 0 (check not applied in jest)
461+ * 4. A hidden parent element (this also hides child elements)
462+ * 5. Type equal to "hidden" (only for form elements)
463+ * 6. A "hidden" attribute
462464 *
463465 * expect('div').toBeHidden();
464466 *
0 commit comments