fix: wrong type for html boolean attrs (#1731)

This commit is contained in:
Marvin Hagemeister
2023-09-05 01:00:33 +02:00
committed by GitHub
parent 575e7813b7
commit 63c90ddc67
5 changed files with 182 additions and 63 deletions
+8 -1
View File
@@ -323,7 +323,14 @@ function _walkInner(
};
for (let i = 0; i < sib.attributes.length; i++) {
const attr = sib.attributes[i];
props[attr.nodeName] = attr.nodeValue;
// Boolean attributes are always `true` when present.
// See: https://developer.mozilla.org/en-US/docs/Glossary/Boolean/HTML
props[attr.nodeName] =
// deno-lint-ignore no-explicit-any
typeof (sib as any)[attr.nodeName] === "boolean"
? true
: attr.nodeValue;
}
const vnode = h(sib.localName, props);
addPropsChild(parentVNode, vnode);