Merge branch 'main' into export

This commit is contained in:
trans_soup 2023-07-16 15:02:37 +02:00
commit 53fd5eccca
1 changed files with 4 additions and 4 deletions

View File

@ -15,13 +15,13 @@ export 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));