side_menu/src/lib/createElement.js
Simon Vieille 951dd742d8
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending
ci/woodpecker/pr/woodpecker Pipeline was successful
add accessibility to open and close buttons (#311)
refactor the way to focus apps when the menu is opened (#301)
2024-02-14 12:12:08 +01:00

18 lines
412 B
JavaScript

module.exports = (tagName, attributes) => {
const element = document.createElement(tagName)
if (typeof attributes === 'object') {
for (let i in attributes) {
if (i === 'text') {
element.textContent = attributes[i]
} else if (i === 'html') {
element.innerHTML = attributes[i]
} else {
element.setAttribute(i, attributes[i])
}
}
}
return element
}