Skip to content

Commit

Permalink
♻️ Simply ts-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
awtkns committed Nov 15, 2023
1 parent dbe6777 commit 0e0e691
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tarsier/tag_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ interface Window {
}

const elIsClean = (el: HTMLElement) => {
if (el.style && el.style.display === "none") return false;
if (el.hidden) return false;
// @ts-ignore
if (el.disabled) return false;

const rect = el.getBoundingClientRect();
if (rect.width === 0 || rect.height === 0) return false;

if (el.tagName === "SCRIPT") return false;
if (el.tagName === "STYLE") return false;
// @ts-ignore
const isHidden = el.style?.display === "none" || el.hidden || el.disabled;
const isZeroSize = rect.width === 0 || rect.height === 0;
const isScriptOrStyle = el.tagName === "SCRIPT" || el.tagName === "STYLE";

return true;
return !isHidden && !isZeroSize && !isScriptOrStyle;
};

const inputs = ["a", "button", "textarea", "select", "details", "label"];
Expand Down

0 comments on commit 0e0e691

Please sign in to comment.