forked from mystiq/hydrogen-web
support bool values for attribute
This commit is contained in:
parent
eb2eb291d3
commit
553bda2837
1 changed files with 8 additions and 1 deletions
|
@ -2,8 +2,15 @@ export function setAttribute(el, name, value) {
|
|||
if (name === "className") {
|
||||
name = "class";
|
||||
}
|
||||
if (value === false) {
|
||||
el.removeAttribute(name);
|
||||
} else {
|
||||
if (value === true) {
|
||||
value = name;
|
||||
}
|
||||
el.setAttribute(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
export function el(elementName, attrs, children) {
|
||||
const e = document.createElement(elementName);
|
||||
|
|
Loading…
Reference in a new issue