utils: append string child directly

Strings can be appended directly without spreading.
pull/2/head
OFF0 2022-11-12 11:47:03 +01:00
parent 380b79038d
commit 5d701c8767
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA
1 changed files with 5 additions and 1 deletions

View File

@ -13,6 +13,10 @@
export function elem(name = 'div', props = {}, children = []) {
const el = document.createElement(name);
Object.assign(el, props);
el.append(...children);
if (typeof children === 'string') {
el.append(children);
} else {
el.append(...children);
}
return el;
}