src/service/extensions-impl.js
/**
   * Registers a new extension. This method is called by the extension's script
   * itself when it's loaded using the regular `AMP.push()` callback.
   * @param {string} extensionId
   * @param {function(!Object)} factory
   * @param {!Object} arg
   * @private
   * @restricted
   */
Registers a new extension. This method is called by the extension's script
itself when it's loaded using the regular `AMP.push()` callback.
Registers a new extension . This method is called by the extension ' s script itself when it ' s loaded using the regular ` AMP . push () ` callback .
registerExtension_(extensionId, factory, arg) {
    const holder = this.getExtensionHolder_(extensionId,  true);
    try {
      this.currentExtensionId_ = extensionId;
      factory(arg);
      if (getMode().localDev || getMode().test) {
        if (Object.freeze) {
          const m = holder.extension;
          m.elements = Object.freeze(m.elements);
          holder.extension = Object.freeze(m);
        }
      }
      holder.loaded = true;
      if (holder.resolve) {
        holder.resolve(holder.extension);
      }
    } catch (e) {
      holder.error = e;
      if (holder.reject) {
        holder.reject(e);
      }
      throw e;
    } finally {
      this.currentExtensionId_ = null;
    }
  }
registerExtension_ ( extensionId , factory , arg ) { const holder = this . getExtensionHolder_ ( extensionId , true ) ; try { this . currentExtensionId_ = extensionId ; factory ( arg ) ; if ( getMode ( ) . localDev || getMode ( ) . test ) { if ( Object . freeze ) { const m = holder . extension ; m . elements = Object . freeze ( m . elements ) ; holder . extension = Object . freeze ( m ) ; } } holder . loaded = true ; if ( holder . resolve ) { holder . resolve ( holder . extension ) ; } } catch ( e ) { holder . error = e ; if ( holder . reject ) { holder . reject ( e ) ; } throw e ; } finally { this . currentExtensionId_ = null ; } }
Registers a new extension.
Registers a new extension .
/* auto */