* Parse the metadata attributes from the name and add them to * the class instance. * @param {string} data * @private
(data)
| 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. |
no test coverage detected