From 05cd4cb3c9e098e8914c9649672bf121057a7c1c Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Sun, 16 Jul 2023 15:01:34 +0200 Subject: [PATCH] fix bug. fix bug with attribute setting. also assume no attributes & children if none are provided. --- js/main.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/main.mjs b/js/main.mjs index e4947fd..344612f 100644 --- a/js/main.mjs +++ b/js/main.mjs @@ -15,13 +15,13 @@ function json_as_html (json, state = new Map()) { return json_as_html(json(state), state); } - const [type, attributes, children] = json; + const [type, attributes = [], children = []] = json; const elem = document.createElement(type); - attributes.forEach(([key, value]) => - elem[key] = value); - // elem.setAttribute(key, value)); + attributes.forEach(([key, value]) => { + elem.setAttribute(key, value); + }); const child_nodes = use_as_array(children).map(child => json_as_html(child, state)) child_nodes.forEach(child => elem.appendChild(child));