Skip to content

Commit

Permalink
Pass data along to window.context (#10354)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorozco authored and erwinmombay committed Jul 11, 2017
1 parent d3726f8 commit 8997bab
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion 3p/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ const FALLBACK_CONTEXT_DATA = dict({
// Need to cache iframeName as it will be potentially overwritten by
// masterSelection, as per below.
const iframeName = window.name;

// TODO(alanorozco): Remove references to this and try to find a more suitable
// data structure.
const data = getData(iframeName);

window.context = data['_context'];
Expand Down Expand Up @@ -444,11 +447,19 @@ window.draw3p = function(opt_configCallback, opt_allowed3pTypes,
delete data['_context'];
manageWin(window);
installEmbedStateListener();
draw3p(window, data, opt_configCallback);

if (isAmpContextExperimentOn()) {
// Ugly type annotation is due to Event.prototype.data being blacklisted
// and the compiler not being able to discern otherwise
// TODO(alanorozco): Do this more elegantly once old impl is cleaned up.
draw3p(
window,
(/** @type {!IntegrationAmpContext} */ (window.context)).data || {},
opt_configCallback);

window.context.bootstrapLoaded();
} else {
draw3p(window, data, opt_configCallback);
updateVisibilityState(window);

// Subscribe to page visibility updates.
Expand Down

0 comments on commit 8997bab

Please sign in to comment.