Fix class attribute
This commit is contained in:
parent
8356fbf70f
commit
ca1e45e04e
1 changed files with 10 additions and 4 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue