Merge branch 'main' into export
This commit is contained in:
commit
53fd5eccca
1 changed files with 4 additions and 4 deletions
8
main.mjs
8
main.mjs
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue