mirror of https://github.com/n2geoff/um
all scalar values should be supported
This commit is contained in:
parent
c8e5fbf5e4
commit
c996aac35a
|
@ -9,8 +9,11 @@
|
||||||
export default function tag(tag, ...args) {
|
export default function tag(tag, ...args) {
|
||||||
const el = document.createElement(tag);
|
const el = document.createElement(tag);
|
||||||
|
|
||||||
|
// support all scalar values as TextNodes
|
||||||
|
const isScalar = (value) => ["boolean", "string", "number"].includes(typeof value);
|
||||||
|
|
||||||
args.forEach((arg) => {
|
args.forEach((arg) => {
|
||||||
if (typeof arg === "string" || typeof arg === "number") {
|
if (isScalar(arg)) {
|
||||||
el.appendChild(document.createTextNode(arg));
|
el.appendChild(document.createTextNode(arg));
|
||||||
} else if (Array.isArray(arg)) {
|
} else if (Array.isArray(arg)) {
|
||||||
el.append(...arg);
|
el.append(...arg);
|
||||||
|
|
Loading…
Reference in New Issue