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

Function replaceCustomElementScript

build-system/server/app-video-testbench.js:277–289  ·  view source on GitHub ↗
(
  doc, fromExtension, toExtension, version = '0.1')

Source from the content-addressed store, hash-verified

275
276
277function replaceCustomElementScript(
278 doc, fromExtension, toExtension, version = '0.1') {
279
280 const selector = `script[custom-element=${fromExtension}]`;
281 const script = doc.querySelector(selector);
282
283 script.setAttribute('custom-element', toExtension);
284
285 // TODO(alanorozco): Use config.urls.cdn value. This file is not available
286 // under the Node.JS context.
287 script.setAttribute('src',
288 `https://cdn.ampproject.org/v0/${toExtension}-${version}.js`);
289}
290
291
292function removeAttrs(node) {

Callers 1

replaceExtensionFunction · 0.85

Calls 1

setAttributeMethod · 0.45

Tested by

no test coverage detected