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

Function buildLinkMaybe

tools/experiments/experiments.js:216–227  ·  view source on GitHub ↗

* If link is available, builds the anchor. Otherwise, it'd return a basic span. * @param {string} text * @param {?string} link * @return {!Element}

(text, link)

Source from the content-addressed store, hash-verified

214 * @return {!Element}
215 */
216function buildLinkMaybe(text, link) {
217 let element;
218 if (link) {
219 element = document.createElement('a');
220 element.setAttribute('href', link);
221 element.setAttribute('target', '_blank');
222 } else {
223 element = document.createElement('span');
224 }
225 element.textContent = text;
226 return element;
227}
228
229/**
230 * Updates states of all experiments in the table.

Callers 1

buildExperimentRowFunction · 0.85

Calls 1

setAttributeMethod · 0.45

Tested by

no test coverage detected