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

Method setupMetadata_

3p/ampcontext.js:332–352  ·  view source on GitHub ↗

* Parse the metadata attributes from the name and add them to * the class instance. * @param {string} data * @private

(data)

Source from the content-addressed store, hash-verified

330 * @private
331 */
332 setupMetadata_(data) {
333 // TODO(alanorozco): Use metadata utils in 3p/frame-metadata
334 const dataObject = devAssert(
335 typeof data === 'string' ? tryParseJson(data) : data,
336 'Could not setup metadata.'
337 );
338
339 const context = dataObject._context || dataObject.attributes._context;
340
341 this.data = dataObject.attributes || dataObject;
342
343 // TODO(alanorozco, #10576): This is really ugly. Find a better structure
344 // than passing context values via data.
345 if ('_context' in this.data) {
346 delete this.data['_context'];
347 }
348
349 this.setupMetadataFromContext_(context);
350
351 this.embedType_ = dataObject.type || null;
352 }
353
354 /**
355 * Set the metadata attributes from the "context" instance directly.

Callers 1

findAndSetMetadata_Method · 0.95

Calls 3

devAssertFunction · 0.90
tryParseJsonFunction · 0.90

Tested by

no test coverage detected