fix bug with attribute setting.
(with a hack solution made without understanding how setting different kinds of element attributes work.)
This commit is contained in:
parent
05cd4cb3c9
commit
9f5473cea8
|
@ -20,7 +20,11 @@ function json_as_html (json, state = new Map()) {
|
|||
const elem = document.createElement(type);
|
||||
|
||||
attributes.forEach(([key, value]) => {
|
||||
// from testing: class only works with the former, onclick only work with the latter. so both are used here :)
|
||||
// also from testing: this only works in this specific order.
|
||||
// TODO: learn how element attribute setting works and create something more reliable.
|
||||
elem.setAttribute(key, value);
|
||||
elem[key] = value;
|
||||
});
|
||||
|
||||
const child_nodes = use_as_array(children).map(child => json_as_html(child, state))
|
||||
|
@ -34,7 +38,8 @@ function json_as_html (json, state = new Map()) {
|
|||
const demo = [
|
||||
"div",
|
||||
[
|
||||
["id", "wrapper"]
|
||||
["id", "wrapper"],
|
||||
["class", "demo_div"],
|
||||
],
|
||||
[
|
||||
["h1", [], "header :)"],
|
||||
|
|
Loading…
Reference in New Issue