feat(core): @Attribute annotation

Closes #1091
Fixes #622
This commit is contained in:
Marc Laval
2015-03-25 09:42:19 +01:00
parent 3ce0f1146f
commit b1dc6239ef
9 changed files with 114 additions and 6 deletions

View File

@ -22,6 +22,7 @@ export class CompileElement {
textNodeBindings:Map;
propertyBindings:Map;
eventBindings:Map;
attributes:Map;
/// Store directive name to template name mapping.
/// Directive name is what the directive exports the variable as
@ -144,6 +145,13 @@ export class CompileElement {
MapWrapper.set(this.eventBindings, eventName, expression);
}
addAttribute(attributeName:string, attributeValue:string) {
if (isBlank(this.attributes)) {
this.attributes = MapWrapper.create();
}
MapWrapper.set(this.attributes, attributeName, attributeValue);
}
addDirective(directive:DirectiveMetadata) {
var annotation = directive.annotation;
this._allDirectives = null;

View File

@ -72,6 +72,8 @@ export class PropertyBindingParser extends CompileStep {
var ast = this._parseInterpolation(attrValue, desc);
if (isPresent(ast)) {
current.addPropertyBinding(attrName, ast);
} else {
current.addAttribute(attrName, attrValue);
}
}
});

View File

@ -59,6 +59,7 @@ export class ProtoElementInjectorBuilder extends CompileStep {
current.inheritedProtoElementInjector.exportImplicitName = exportImplicitName;
}
}
current.inheritedProtoElementInjector.attributes = current.attributes;
} else {
current.inheritedProtoElementInjector = parentProtoElementInjector;