MCPcopy Create free account
hub / github.com/ampproject/amphtml / getDataForHistory_

Method getDataForHistory_

extensions/amp-bind/0.1/bind-impl.js:401–415  ·  view source on GitHub ↗

* Returns data that should be saved in browser history on AMP.setState() or * AMP.pushState(). This enables features like restoring browser tabs. * @return {!Promise<?JsonObject>}

()

Source from the content-addressed store, hash-verified

399 * @return {!Promise<?JsonObject>}
400 */
401 getDataForHistory_() {
402 const data = {
403 'data': {'amp-bind': this.state_},
404 'title': this.localWin_.document.title,
405 };
406 if (!this.viewer_.isEmbedded()) {
407 // CC doesn't recognize !JsonObject as a subtype of (JsonObject|null).
408 return /** @type {!Promise<?JsonObject>} */ (Promise.resolve(data));
409 }
410 // Only pass state for history updates to trusted viewers, since they
411 // may contain user data e.g. form input.
412 return this.viewer_.isTrustedViewer().then((trusted) => {
413 return trusted ? data : null;
414 });
415 }
416
417 /**
418 * Removes bindings from `removedElements` and adds new bindings in

Callers 2

Calls 4

resolveMethod · 0.80
isEmbeddedMethod · 0.45
thenMethod · 0.45
isTrustedViewerMethod · 0.45

Tested by

no test coverage detected