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

Method preinstallEmbed

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

* Preinstalls built-ins and legacy elements in the emebedded ampdoc. * @param {!./ampdoc-impl.AmpDoc} ampdoc * @param {!Array<{extensionId: string, extensionVersion: string}>} extensions * @restricted

(ampdoc, extensions)

Source from the content-addressed store, hash-verified

454 * @restricted
455 */
456 preinstallEmbed(ampdoc, extensions) {
457 const topWin = this.win;
458 const childWin = ampdoc.win;
459
460 // Install built-ins and legacy elements.
461 copyBuiltinElementsToChildWindow(topWin, childWin);
462 stubLegacyElements(childWin);
463
464 // Stub extensions.
465 extensions.forEach(({extensionId, extensionVersion}) => {
466 // Declare the extension version on ampdoc so it doesn't request the
467 // extension again.
468 ampdoc.declareExtension(extensionId, extensionVersion);
469
470 // This will extend automatic upgrade of custom elements from top
471 // window to the child window.
472 if (!LEGACY_ELEMENTS.includes(extensionId)) {
473 stubElementIfNotKnown(childWin, extensionId);
474 }
475 });
476 }
477
478 /**
479 * Installs all ampdoc factories previously registered with

Callers 2

test-extensions.jsFile · 0.80

Calls 5

stubElementIfNotKnownFunction · 0.90
stubLegacyElementsFunction · 0.85
declareExtensionMethod · 0.80
forEachMethod · 0.45

Tested by

no test coverage detected