({element, id, src, className, title, styles, type, innerHTML, attributes, eventListeners, appendTo})
| 10 | */ |
| 11 | |
| 12 | function 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 | |
| 40 | function createSvgElement({element, id, className, attributes, styles, textContent, appendTo}) { |
| 41 | const svgns = 'http://www.w3.org/2000/svg'; |
no outgoing calls
no test coverage detected