diff options
author | Ryan Berliner <22206986+RyanBerliner@users.noreply.github.com> | 2022-01-13 11:55:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-13 11:55:05 +0300 |
commit | 14c7dc1e886015f2ed845f0f8e88d3597694250f (patch) | |
tree | 86b1432f333f304c3ead0706fdfd6a01c8f9ecd2 /js/tests/unit/util | |
parent | d581737f784d144a961d61248d42f59440159571 (diff) |
Fix: `isVisible` function behavior in case of a `<details>` element, on chrome 97 (#35682)
Diffstat (limited to 'js/tests/unit/util')
-rw-r--r-- | js/tests/unit/util/index.spec.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js index 52e64faa91..9d8c5ed986 100644 --- a/js/tests/unit/util/index.spec.js +++ b/js/tests/unit/util/index.spec.js @@ -320,6 +320,42 @@ describe('Util', () => { expect(Util.isVisible(div)).toBeFalse() }) + + it('should return true if its a closed details element', () => { + fixtureEl.innerHTML = '<details id="element"></details>' + + const div = fixtureEl.querySelector('#element') + + expect(Util.isVisible(div)).toBeTrue() + }) + + it('should return true if the element is visible inside an open details element', () => { + fixtureEl.innerHTML = [ + '<details open>', + ' <div id="element"></div>', + '</details>' + ].join('') + + const div = fixtureEl.querySelector('#element') + + expect(Util.isVisible(div)).toBeTrue() + }) + + it('should return true if the element is a visible summary in a closed details element', () => { + fixtureEl.innerHTML = [ + '<details>', + ' <summary id="element-1">', + ' <span id="element-2"></span>', + ' </summary>', + '</details>' + ].join('') + + const element1 = fixtureEl.querySelector('#element-1') + const element2 = fixtureEl.querySelector('#element-2') + + expect(Util.isVisible(element1)).toBeTrue() + expect(Util.isVisible(element2)).toBeTrue() + }) }) describe('isDisabled', () => { |