MCPcopy Create free account
hub / github.com/adobe/leonardo / createHtmlElement

Function createHtmlElement

docs/ui/src/js/createHtmlElement.js:12–38  ·  view source on GitHub ↗
({element, id, src, className, title, styles, type, innerHTML, attributes, eventListeners, appendTo})

Source from the content-addressed store, hash-verified

10*/
11
12function createHtmlElement({element, id, src, className, title, styles, type, innerHTML, attributes, eventListeners, appendTo}) {
13 const el = document.createElement(element);
14 if (id) el.id = id;
15 if (className) el.className = className;
16 if (src) el.src = src;
17 if (styles) {
18 for (const [prop, value] of Object.entries(styles)) {
19 el.style[prop] = value;
20 }
21 }
22 if (type) el.type = type;
23 if (innerHTML) el.innerHTML = innerHTML;
24 if (attributes) {
25 for (const [prop, value] of Object.entries(attributes)) {
26 el.setAttribute(prop, value);
27 }
28 }
29 if (title) el.title = title;
30 if (eventListeners) {
31 for (const [event, func] of Object.entries(eventListeners)) {
32 el.addEventListener(event, func);
33 }
34 }
35
36 const dest = document.getElementById(appendTo);
37 dest.appendChild(el);
38}
39
40function createSvgElement({element, id, className, attributes, styles, textContent, appendTo}) {
41 const svgns = 'http://www.w3.org/2000/svg';

Callers 2

createColorWheelDotsFunction · 0.90
createSamplesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected