Skip to content

Commit

Permalink
modules/domComplexity/scope.js: query for iframes just once
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre committed May 24, 2024
1 parent 793dba5 commit c2578e3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions modules/domComplexity/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@
})();

// count <iframe> tags
document.querySelectorAll("iframe").forEach(function (iframe) {
phantomas.incrMetric("iframesCount"); // @desc number of iframe nodes
const iframes = document.querySelectorAll("iframe");
phantomas.setMetric("iframesCount", iframes.length); // @desc number of iframe nodes

for (const iframe of iframes) {
phantomas.log(`iframe: ${iframe.src}`);

phantomas.addOffender("iframesCount", {
element: phantomas.getDOMPath(iframe),
url: iframe.src,
});
});
}

phantomas.spyEnabled(true);
});
Expand Down

0 comments on commit c2578e3

Please sign in to comment.