-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove deprecation warning from
isVisible
method (#1675)
update `isVisible` logic to match implementation in `jest-dom`
- Loading branch information
Showing
12 changed files
with
73 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './compile-template' | ||
export * from './create-component-stubs' | ||
export * from './is-visible' | ||
export * from './util' | ||
export * from './validators' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*! | ||
* isElementVisible | ||
* Ported from https://github.com/testing-library/jest-dom | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
function isStyleVisible(element) { | ||
const { display, visibility, opacity } = element.style | ||
return ( | ||
display !== 'none' && | ||
visibility !== 'hidden' && | ||
visibility !== 'collapse' && | ||
opacity !== '0' && | ||
opacity !== 0 | ||
) | ||
} | ||
|
||
function isAttributeVisible(element, previousElement) { | ||
return ( | ||
!element.hasAttribute('hidden') && | ||
(element.nodeName === 'DETAILS' && previousElement.nodeName !== 'SUMMARY' | ||
? element.hasAttribute('open') | ||
: true) | ||
) | ||
} | ||
|
||
export function isElementVisible(element, previousElement) { | ||
return ( | ||
element.nodeName !== '#comment' && | ||
isStyleVisible(element) && | ||
isAttributeVisible(element, previousElement) && | ||
(!element.parentElement || isElementVisible(element.parentElement, element)) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters