From 59a1f836a25c8b65abb00aa67fe7336560d8f660 Mon Sep 17 00:00:00 2001
From: Pawel Kozlowski
Date: Fri, 13 Mar 2015 22:44:42 +0100
Subject: [PATCH] fix: allow creation of var with camelCased names
Closes #957
---
.../core/compiler/pipeline/compile_element.js | 2 +-
.../test/core/compiler/integration_spec.js | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/modules/angular2/src/core/compiler/pipeline/compile_element.js b/modules/angular2/src/core/compiler/pipeline/compile_element.js
index 5ef49c036a..2ec4bb7bcf 100644
--- a/modules/angular2/src/core/compiler/pipeline/compile_element.js
+++ b/modules/angular2/src/core/compiler/pipeline/compile_element.js
@@ -134,7 +134,7 @@ export class CompileElement {
// 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
// it.
- MapWrapper.set(this.variableBindings, variableValue, variableName);
+ MapWrapper.set(this.variableBindings, variableValue, dashCaseToCamelCase(variableName));
}
addEventBinding(eventName:string, expression:AST) {
diff --git a/modules/angular2/test/core/compiler/integration_spec.js b/modules/angular2/test/core/compiler/integration_spec.js
index 475d34c899..96cca00458 100644
--- a/modules/angular2/test/core/compiler/integration_spec.js
+++ b/modules/angular2/test/core/compiler/integration_spec.js
@@ -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: 'Hello
'}));
+
+ 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) => {
tplResolver.setTemplate(MyComp, new Template({
inline: '',