* 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 )
| 161 | * @return {boolean} |
| 162 | */ |
| 163 | function 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. |
no test coverage detected