chai-dom
chai-dom copied to clipboard
Fix `visible` to work with elements in the Shadow DOM
As a follow-up to #63 and #64, this applies the same shadow DOM fix for visible.
I have modified the check for both displayed and visible to restore backwards-compatibility: on older browsers that don't support .getRootNode, it'll fall back to the older check of document.body.contains(el).
I also modified the test from #64, which was returning false positives (passing both before and after the fix). The new test successfully passes with the fixes, and fails without the fixes.
Looks good!
@nathanboktae this will bring visible into parity with displayed - let me know if there's any changed you'd like.