extensions/amp-bind/0.1/amp-state.js
/**
   * Parses JSON in child script element and updates state.
   * @private
   */
Parses JSON in child script element and updates state.
@private
Parses JSON in child script element and updates state . @private
parseChildAndUpdateState_() {
    const TAG = this.getName_();
    const children = this.element.children;
    if (children.length != 1) {
      this.user().error(
          TAG, 'Should contain exactly one <script> child.');
      return;
    }
    const firstChild = children[0];
    if (!isJsonScriptTag(firstChild)) {
      this.user().error(TAG,
          'State should be in a <script> tag with type="application/json".');
      return;
    }
    const json = tryParseJson(firstChild.textContent, e => {
      this.user().error(
          TAG, 'Failed to parse state. Is it valid JSON?', e);
    });
    this.updateState_(json,  true);
  }
parseChildAndUpdateState_ ( ) { const TAG = this . getName_ ( ) ; const children = this . element . children ; if ( children . length != 1 ) { this . user ( ) . error ( TAG , 'Should contain exactly one <script> child.' ) ; return ; } const firstChild = children [ 0 ] ; if ( ! isJsonScriptTag ( firstChild ) ) { this . user ( ) . error ( TAG , 'State should be in a <script> tag with type="application/json".' ) ; return ; } const json = tryParseJson ( firstChild . textContent , e => { this . user ( ) . error ( TAG , 'Failed to parse state. Is it valid JSON?' , e ) ; } ) ; this . updateState_ ( json , true ) ; }
Parses JSON in child script element and updates state.
Parses JSON in child script element and updates state .
/* isInit */