isVisible.js 523 B

12345678910111213141516171819
  1. 'use strict';
  2. var getWindow = require('./getWindow.js');
  3. function isVisible(element) {
  4. const window = getWindow.getWindow(element);
  5. for(let el = element; el === null || el === undefined ? undefined : el.ownerDocument; el = el.parentElement){
  6. const { display, visibility } = window.getComputedStyle(el);
  7. if (display === 'none') {
  8. return false;
  9. }
  10. if (visibility === 'hidden') {
  11. return false;
  12. }
  13. }
  14. return true;
  15. }
  16. exports.isVisible = isVisible;