MCPcopy
hub / github.com/ampproject/amphtml / buildCallback

Method buildCallback

extensions/amp-script/0.1/amp-script.js:155–188  ·  view source on GitHub ↗

@override

()

Source from the content-addressed store, hash-verified

153
154 /** @override */
155 buildCallback() {
156 this.sandboxed_ = this.element.hasAttribute('sandboxed');
157 this.nodom_ = this.sandboxed_ || this.element.hasAttribute('nodom');
158 this.development_ =
159 this.element.hasAttribute('data-ampdevmode') ||
160 this.element.ownerDocument.documentElement.hasAttribute(
161 'data-ampdevmode'
162 );
163
164 if (this.development_) {
165 user().warn(
166 TAG,
167 'JavaScript size and script hash requirements are disabled in development mode.',
168 this.element
169 );
170 }
171
172 if (
173 this.nodom_ &&
174 (this.element.hasAttribute('width') ||
175 this.element.hasAttribute('height') ||
176 this.element.hasAttribute('layout'))
177 ) {
178 user().warn(
179 TAG,
180 'Cannot set width, height, or layout of a nodom <amp-script>',
181 this.element
182 );
183 }
184
185 return getElementServiceForDoc(this.element, TAG, TAG).then((service) => {
186 this.setService(/** @type {!AmpScriptService} */ (service));
187 });
188 }
189
190 /**
191 * @override

Callers 1

test-amp-script.jsFile · 0.45

Calls 5

setServiceMethod · 0.95
userFunction · 0.90
getElementServiceForDocFunction · 0.90
warnMethod · 0.80
thenMethod · 0.45

Tested by

no test coverage detected