fix: allow creation of var with camelCased names

Closes #957
This commit is contained in:
Pawel Kozlowski 2015-03-13 22:44:42 +01:00 committed by Misko Hevery
parent 28aa7466bd
commit 59a1f836a2
2 changed files with 18 additions and 1 deletions

View File

@ -134,7 +134,7 @@ export class CompileElement {
// by the "value", or exported identifier. For example, ng-repeat sets a view local of "index". // by the "value", or exported identifier. For example, ng-repeat sets a view local of "index".
// When this occurs, a lookup keyed by "index" must occur to find if there is a var referencing // When this occurs, a lookup keyed by "index" must occur to find if there is a var referencing
// it. // it.
MapWrapper.set(this.variableBindings, variableValue, variableName); MapWrapper.set(this.variableBindings, variableValue, dashCaseToCamelCase(variableName));
} }
addEventBinding(eventName:string, expression:AST) { addEventBinding(eventName:string, expression:AST) {

View File

@ -419,6 +419,23 @@ export function main() {
}) })
})); }));
it('should assign the element instance to a user-defined variable with camelCase using dash-case', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MyComp,
new Template({inline: '<p><div var-super-alice><i>Hello</i></div></p>'}));
compiler.compile(MyComp).then((pv) => {
createView(pv);
expect(view.locals).not.toBe(null);
var value = view.locals.get('superAlice');
expect(value).not.toBe(null);
expect(value.tagName.toLowerCase()).toEqual('div');
async.done();
})
}));
it('should provide binding configuration config to the component', inject([AsyncTestCompleter], (async) => { it('should provide binding configuration config to the component', inject([AsyncTestCompleter], (async) => {
tplResolver.setTemplate(MyComp, new Template({ tplResolver.setTemplate(MyComp, new Template({
inline: '<push-cmp #cmp></push-cmp>', inline: '<push-cmp #cmp></push-cmp>',