* Produces the attributes for the ad template. * @param {!Window} parentWindow * @param {!AmpElement} element * @param {string=} opt_type * @param {Object=} opt_context * @return {!JsonObject} Contains * - type, width, height, src attributes of tag. These have * precedence
(parentWindow, element, opt_type, opt_context)
| 31 | * - A _context object for internal use. |
| 32 | */ |
| 33 | function getFrameAttributes(parentWindow, element, opt_type, opt_context) { |
| 34 | const type = opt_type || element.getAttribute('type'); |
| 35 | userAssert(type, 'Attribute type required for <amp-ad>: %s', element); |
| 36 | const sentinel = generateSentinel(parentWindow); |
| 37 | let attributes = {}; |
| 38 | // Do these first, as the other attributes have precedence. |
| 39 | addDataAndJsonAttributes_(element, attributes); |
| 40 | attributes = getContextMetadata(parentWindow, element, sentinel, attributes); |
| 41 | attributes['type'] = type; |
| 42 | Object.assign(attributes['_context'], opt_context); |
| 43 | return attributes; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Creates the iframe for the embed. Applies correct size and passes the embed |
no test coverage detected