MCPcopy
hub / github.com/ampproject/amphtml / installExtensionInDoc

Method installExtensionInDoc

src/service/extensions-impl.js:501–515  ·  view source on GitHub ↗

* Installs all ampdoc factories for the specified extension. * @param {!./ampdoc-impl.AmpDoc} ampdoc * @param {string} extensionId * @param {string=} version * @return {!Promise}

(ampdoc, extensionId, version = DEFAULT_VERSION)

Source from the content-addressed store, hash-verified

499 * @return {!Promise}
500 */
501 installExtensionInDoc(ampdoc, extensionId, version = DEFAULT_VERSION) {
502 ampdoc.declareExtension(extensionId, version);
503 return this.waitFor_(this.getExtensionHolder_(extensionId, version)).then(
504 () => {
505 const holder = this.getExtensionHolder_(extensionId, version);
506 holder.docFactories.forEach((factory) => {
507 try {
508 factory(ampdoc);
509 } catch (e) {
510 rethrowAsync('Doc factory failed: ', e, extensionId);
511 }
512 });
513 }
514 );
515 }
516
517 /**
518 * Creates or returns an existing extension holder.

Callers 3

test-extensions.jsFile · 0.80

Calls 7

waitFor_Method · 0.95
getExtensionHolder_Method · 0.95
rethrowAsyncFunction · 0.90
declareExtensionMethod · 0.80
factoryFunction · 0.50
thenMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected