element.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. var isSVG = function (target) { return target instanceof SVGElement && 'getBBox' in target; };
  2. var isHidden = function (target) {
  3. if (isSVG(target)) {
  4. var _a = target.getBBox(), width = _a.width, height = _a.height;
  5. return !width && !height;
  6. }
  7. var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
  8. return !(offsetWidth || offsetHeight || target.getClientRects().length);
  9. };
  10. var isElement = function (obj) {
  11. var _a;
  12. if (obj instanceof Element) {
  13. return true;
  14. }
  15. var scope = (_a = obj === null || obj === void 0 ? void 0 : obj.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
  16. return !!(scope && obj instanceof scope.Element);
  17. };
  18. var isReplacedElement = function (target) {
  19. switch (target.tagName) {
  20. case 'INPUT':
  21. if (target.type !== 'image') {
  22. break;
  23. }
  24. case 'VIDEO':
  25. case 'AUDIO':
  26. case 'EMBED':
  27. case 'OBJECT':
  28. case 'CANVAS':
  29. case 'IFRAME':
  30. case 'IMG':
  31. return true;
  32. }
  33. return false;
  34. };
  35. export { isSVG, isHidden, isElement, isReplacedElement };