MCPcopy Index your code
hub / github.com/ampproject/amphtml / github

Function github

3p/github.js:26–58  ·  view source on GitHub ↗
(global, data)

Source from the content-addressed store, hash-verified

24 * @param {!Object} data
25 */
26export function github(global, data) {
27 userAssert(
28 data.gistid,
29 'The data-gistid attribute is required for <amp-gist> %s',
30 data.element
31 );
32
33 let gistUrl =
34 'https://gist.github.com/' + encodeURIComponent(data.gistid) + '.js';
35
36 if (data.file) {
37 gistUrl += '?file=' + encodeURIComponent(data.file);
38 }
39
40 getGistJs(global, gistUrl, function () {
41 // Dimensions are given by the parent frame.
42 delete data.width;
43 delete data.height;
44 const gistContainer = global.document.querySelector('#c .gist');
45
46 // get all links in the embed
47 const gistLinks = global.document.querySelectorAll('.gist-meta a');
48 for (let i = 0; i < gistLinks.length; i++) {
49 // have the links open in a new tab #8587
50 gistLinks[i].target = '_BLANK';
51 }
52
53 context.updateDimensions(
54 gistContainer./*OK*/ offsetWidth,
55 gistContainer./*OK*/ offsetHeight
56 );
57 });
58}

Callers

nothing calls this directly

Calls 3

userAssertFunction · 0.90
getGistJsFunction · 0.85
updateDimensionsMethod · 0.80

Tested by

no test coverage detected