fix bug.
fix bug with attribute setting. also assume no attributes & children if none are provided.
This commit is contained in:
parent
416d31b1ad
commit
05cd4cb3c9
1 changed files with 4 additions and 4 deletions
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue