feat(compiler): special-case class attribute in hostAttributes
Closes #1774 Closes #1841
This commit is contained in:

committed by
Misko Hevery

parent
cfba38b462
commit
3011cd86bd
@ -100,9 +100,7 @@ export class DirectiveParser extends CompileStep {
|
||||
}
|
||||
if (isPresent(directive.hostAttributes)) {
|
||||
MapWrapper.forEach(directive.hostAttributes, (hostAttrValue, hostAttrName) => {
|
||||
if (!DOM.hasAttribute(current.element, hostAttrName)) {
|
||||
DOM.setAttribute(current.element, hostAttrName, hostAttrValue);
|
||||
}
|
||||
this._addHostAttribute(hostAttrName, hostAttrValue, current);
|
||||
});
|
||||
}
|
||||
if (isPresent(directive.readAttributes)) {
|
||||
@ -162,6 +160,16 @@ export class DirectiveParser extends CompileStep {
|
||||
directiveBinderBuilder.bindHostProperty(hostPropertyName, ast);
|
||||
}
|
||||
|
||||
_addHostAttribute(attrName, attrValue, compileElement) {
|
||||
if (StringWrapper.equals(attrName, 'class')) {
|
||||
ListWrapper.forEach(attrValue.split(' '), (className) => {
|
||||
DOM.addClass(compileElement.element, className);
|
||||
});
|
||||
} else if (!DOM.hasAttribute(compileElement.element, attrName)) {
|
||||
DOM.setAttribute(compileElement.element, attrName, attrValue);
|
||||
}
|
||||
}
|
||||
|
||||
_splitBindConfig(bindConfig:string) {
|
||||
return ListWrapper.map(bindConfig.split('|'), (s) => s.trim());
|
||||
}
|
||||
|
Reference in New Issue
Block a user