chore(refactor): easier to make sense of attr-to-prop map (even if a bit reduntant)

This commit is contained in:
Yegor Jbanov
2015-02-27 22:11:08 -08:00
parent 757eae8ad3
commit cbe7b8c671
4 changed files with 23 additions and 26 deletions

View File

@ -91,26 +91,12 @@ function roleSetter(element, value) {
}
}
// special mapping for cases where attribute name doesn't match property name
var _lazyAttrToProp;
function attrToProp() {
if (!isPresent(_lazyAttrToProp)) {
_lazyAttrToProp = StringMapWrapper.merge({
"inner-html": "innerHTML",
"readonly": "readOnly",
"tabindex": "tabIndex",
}, DOM.attrToPropMap);
}
return _lazyAttrToProp;
}
// tells if an attribute is handled by the ElementBinderBuilder step
export function isSpecialProperty(propName:string) {
return StringWrapper.startsWith(propName, ARIA_PREFIX)
|| StringWrapper.startsWith(propName, CLASS_PREFIX)
|| StringWrapper.startsWith(propName, STYLE_PREFIX)
|| StringMapWrapper.contains(attrToProp(), propName);
|| StringMapWrapper.contains(DOM.attrToPropMap, propName);
}
/**
@ -257,7 +243,7 @@ export class ElementBinderBuilder extends CompileStep {
}
_resolvePropertyName(attrName:string) {
var mappedPropName = StringMapWrapper.get(attrToProp(), attrName);
var mappedPropName = StringMapWrapper.get(DOM.attrToPropMap, attrName);
return isPresent(mappedPropName) ? mappedPropName : attrName;
}
}