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

Function validateDimensions

ads/google/utils.js:163–181  ·  view source on GitHub ↗

* A helper function for determining whether a given width or height violates * some condition. * * Checks the width and height against their corresponding conditions. If * either of the conditions fail, the errorBuilder function will be called with * the appropriate arguments, its result will b

(
  width,
  height,
  widthCond,
  heightCond,
  errorBuilder
)

Source from the content-addressed store, hash-verified

161 * @return {boolean}
162 */
163function validateDimensions(
164 width,
165 height,
166 widthCond,
167 heightCond,
168 errorBuilder
169) {
170 const badParams = [];
171 if (widthCond(width)) {
172 badParams.push({dim: 'width', val: width});
173 }
174 if (heightCond(height)) {
175 badParams.push({dim: 'height', val: height});
176 }
177 if (badParams.length) {
178 user().warn('AMP-AD', errorBuilder(badParams));
179 }
180 return !badParams.length;
181}
182
183/**
184 * Calculates height of responsive matched content slot based on its width.

Callers 1

getMultiSizeDimensionsFunction · 0.85

Calls 3

userFunction · 0.90
warnMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected