Fix class attribute

This commit is contained in:
Eric Eastwood 2022-02-03 00:43:59 -06:00
parent 8356fbf70f
commit ca1e45e04e

View file

@ -292,6 +292,11 @@ export class TemplateBuilder<T extends IObservableValue> {
const attrMap = {}; const attrMap = {};
if(attributes) { if(attributes) {
for(let [key, value] of Object.entries(attributes)) { for(let [key, value] of Object.entries(attributes)) {
let attrName = key;
if (key === "className") {
attrName = "class";
}
// binding for className as object of className => enabled // binding for className as object of className => enabled
if (typeof value === "object") { if (typeof value === "object") {
if (key !== "className" || value === null) { if (key !== "className" || value === null) {
@ -300,16 +305,17 @@ export class TemplateBuilder<T extends IObservableValue> {
} }
if (objHasFns(value)) { if (objHasFns(value)) {
//this._addClassNamesBinding(node, value); //this._addClassNamesBinding(node, value);
attrMap[key] = classNames(value, value); attrMap[attrName] = classNames(value, value);
} else { } else {
attrMap[key] = classNames(value, this._value); attrMap[attrName] = classNames(value, this._value);
} }
} else if (this._isEventHandler(key, value)) { } else if (this._isEventHandler(key, value)) {
// no-op // no-op
} else if (typeof value === "function") { } else if (typeof value === "function") {
this._addAttributeBinding(node, key, value); //this._addAttributeBinding(node, key, value);
attrMap[attrName] = value(this._value);
} else { } else {
attrMap[key] = value; attrMap[attrName] = value;
} }
} }
} }