Skip to content

Commit 59a1f83

Browse files
pkozlowski-opensourcemhevery
authored andcommitted
fix: allow creation of var with camelCased names
Closes angular#957
1 parent 28aa746 commit 59a1f83

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

modules/angular2/src/core/compiler/pipeline/compile_element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class CompileElement {
134134
// by the "value", or exported identifier. For example, ng-repeat sets a view local of "index".
135135
// When this occurs, a lookup keyed by "index" must occur to find if there is a var referencing
136136
// it.
137-
MapWrapper.set(this.variableBindings, variableValue, variableName);
137+
MapWrapper.set(this.variableBindings, variableValue, dashCaseToCamelCase(variableName));
138138
}
139139

140140
addEventBinding(eventName:string, expression:AST) {

modules/angular2/test/core/compiler/integration_spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,23 @@ export function main() {
419419
})
420420
}));
421421

422+
423+
it('should assign the element instance to a user-defined variable with camelCase using dash-case', inject([AsyncTestCompleter], (async) => {
424+
tplResolver.setTemplate(MyComp,
425+
new Template({inline: '<p><div var-super-alice><i>Hello</i></div></p>'}));
426+
427+
compiler.compile(MyComp).then((pv) => {
428+
createView(pv);
429+
expect(view.locals).not.toBe(null);
430+
431+
var value = view.locals.get('superAlice');
432+
expect(value).not.toBe(null);
433+
expect(value.tagName.toLowerCase()).toEqual('div');
434+
435+
async.done();
436+
})
437+
}));
438+
422439
it('should provide binding configuration config to the component', inject([AsyncTestCompleter], (async) => {
423440
tplResolver.setTemplate(MyComp, new Template({
424441
inline: '<push-cmp #cmp></push-cmp>',

0 commit comments

Comments
 (0)