fix(compiler): preserve native boolean semantics in page branches
This commit is contained in:
1 parent
681679483a
commit
25a421c727
4 files changed
+38
-2
No files matched your search
@@ -511,6 +511,19 @@ function renderLoopBody(node: ViewNode, locals: string[] = []): string {
|
||||
return escLit(` ${name}`);
|
||||
}
|
||||
|
||||
// Native boolean attributes inside #if/#each must use presence semantics,
|
||||
// just like attributes on the page root. disabled="false" still disables
|
||||
// an HTML input. Component props retain their serialized boolean value.
|
||||
if (
|
||||
!componentTag &&
|
||||
!node.attrs.some((a) => a.name === "data-component") &&
|
||||
isHtmlBooleanAttribute(name)
|
||||
) {
|
||||
const expression = wholeAttributeExpression(attr.value);
|
||||
if (expression) return "${(" + expression + ") ? " + JSON.stringify(` ${name}`) + ' : ""}';
|
||||
if (attr.value === "false") return "";
|
||||
}
|
||||
|
||||
return escLit(` ${name}="`) + bakeLoopAttr(attr.value, componentTag) + escLit(`"`);
|
||||
})
|
||||
.join("");
|
||||
|
||||
Reference in new issue
Block a user