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

Function createContainer

3p/beopinion.js:51–82  ·  view source on GitHub ↗

* @param {!Window} global * @param {!Object} data * @return {?Node}

(global, data)

Source from the content-addressed store, hash-verified

49 * @return {?Node}
50 */
51function createContainer(global, data) {
52 // add canonical link tag
53 addCanonicalLinkTag(global);
54
55 // create div
56 const container = global.document.createElement('container');
57 container.className = 'BeOpinionWidget';
58
59 // get content id
60 if (data['content'] !== null) {
61 container.setAttribute('data-content', data['content']);
62 }
63
64 // get my-content value, forcing it to '1' if it is not an amp-ad
65 if (global.context.tagName === 'AMP-BEOPINION') {
66 container.setAttribute('data-my-content', '1');
67 } else if (data['my-content'] !== null) {
68 container.setAttribute('data-my-content', data['my-content']);
69 }
70
71 // get slot name
72 if (data['name'] !== null) {
73 container.setAttribute('data-name', data['name']);
74 }
75
76 setStyles(container, {
77 width: '100%',
78 display: 'block',
79 });
80
81 return container;
82}
83
84/**
85 * @param {*} global

Callers 1

beopinionFunction · 0.70

Calls 3

setStylesFunction · 0.90
addCanonicalLinkTagFunction · 0.70
setAttributeMethod · 0.45

Tested by

no test coverage detected