@@ -326,7 +326,7 @@ export class AbstractAmpContext {
326
326
/**
327
327
* Parse the metadata attributes from the name and add them to
328
328
* the class instance.
329
- * @param {!Object| string } data
329
+ * @param {string } data
330
330
* @private
331
331
*/
332
332
setupMetadata_ ( data ) {
@@ -346,6 +346,17 @@ export class AbstractAmpContext {
346
346
delete this . data [ '_context' ] ;
347
347
}
348
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.
356
+ * @param {!Object } context
357
+ * @private
358
+ */
359
+ setupMetadataFromContext_ ( context ) {
349
360
this . canary = context . canary ;
350
361
this . canonicalUrl = context . canonicalUrl ;
351
362
this . clientId = context . clientId ;
@@ -367,8 +378,6 @@ export class AbstractAmpContext {
367
378
this . sourceUrl = context . sourceUrl ;
368
379
this . startTime = context . startTime ;
369
380
this . tagName = context . tagName ;
370
-
371
- this . embedType_ = dataObject . type || null ;
372
381
}
373
382
374
383
/**
@@ -403,8 +412,11 @@ export class AbstractAmpContext {
403
412
} else if ( this . win_ . AMP_CONTEXT_DATA ) {
404
413
if ( typeof this . win_ . AMP_CONTEXT_DATA == 'string' ) {
405
414
this . sentinel = this . win_ . AMP_CONTEXT_DATA ;
415
+ // If AMP_CONTEXT_DATA is an Object, Assume that it is the Context Object
416
+ // and not inside the attributes._context which is the structure
417
+ // parsed from "name" on other instances.
406
418
} else if ( isObject ( this . win_ . AMP_CONTEXT_DATA ) ) {
407
- this . setupMetadata_ ( this . win_ . AMP_CONTEXT_DATA ) ;
419
+ this . setupMetadataFromContext_ ( this . win_ . AMP_CONTEXT_DATA ) ;
408
420
}
409
421
} else {
410
422
this . setupMetadata_ ( this . win_ . name ) ;
0 commit comments