2022-10-16 19:57:32 +02:00
|
|
|
module.exports = (tagName, attributes) => {
|
|
|
|
const element = document.createElement(tagName)
|
|
|
|
|
|
|
|
if (typeof attributes === 'object') {
|
|
|
|
for (let i in attributes) {
|
2024-02-14 12:12:08 +01:00
|
|
|
if (i === 'text') {
|
|
|
|
element.textContent = attributes[i]
|
|
|
|
} else if (i === 'html') {
|
|
|
|
element.innerHTML = attributes[i]
|
|
|
|
} else {
|
|
|
|
element.setAttribute(i, attributes[i])
|
|
|
|
}
|
2022-10-16 19:57:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return element
|
|
|
|
}
|