MCPcopy Create free account
hub / github.com/ampproject/amphtml / isAdLike

Function isAdLike

src/iframe-helper.js:524–541  ·  view source on GitHub ↗
(element)

Source from the content-addressed store, hash-verified

522 * @visibleForTesting
523 */
524export function isAdLike(element) {
525 const {height, width} = element.getLayoutSize();
526 for (let i = 0; i < adSizes.length; i++) {
527 const refWidth = adSizes[i][0];
528 const refHeight = adSizes[i][1];
529 if (refHeight > height) {
530 continue;
531 }
532 if (refWidth > width) {
533 continue;
534 }
535 // Fuzzy matching to account for padding.
536 if (height - refHeight <= 20 && width - refWidth <= 20) {
537 return true;
538 }
539 }
540 return false;
541}
542
543/**
544 * @param {!Element} iframe

Callers 2

onLayoutMeasureMethod · 0.90
test-amp-iframe.jsFile · 0.90

Calls 1

getLayoutSizeMethod · 0.45

Tested by

no test coverage detected