MCPcopy Create free account
hub / github.com/kubernetes/test-infra / createElement

Function createElement

triage/render.js:32–57  ·  view source on GitHub ↗
(type, opts, children)

Source from the content-addressed store, hash-verified

30// Create a new DOM node of `type` with `opts` attributes and with given children.
31// If children is a string, or an array with string elements, they become text nodes.
32function createElement(type, opts, children) {
33 var el = document.createElement(type);
34 if (opts) {
35 for (let [key, value] of Object.entries(opts)) {
36 if (typeof value === "object") {
37 for (let [subkey, subvalue] of Object.entries(value)) {
38 el[key][subkey] = subvalue;
39 }
40 } else {
41 el[key] = value;
42 }
43 }
44 }
45 if (children) {
46 if (typeof children === "string") {
47 el.textContent = children;
48 } else {
49 for (let child of children) {
50 if (typeof child === "string")
51 child = document.createTextNode(child);
52 el.appendChild(child);
53 }
54 }
55 }
56 return el;
57}
58
59// Like createElement, but also appends the new node to parent's children.
60function addElement(parent, type, opts, children) {

Callers 7

rerenderFunction · 0.85
addElementFunction · 0.85
addBuildListItemFunction · 0.85
sparkLineSVGFunction · 0.85
renderLatestFunction · 0.85
renderSpansFunction · 0.85
renderClusterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected