fix(compiler): allow identifiers with - in the template bindings as keys.

This commit is contained in:
Tobias Bosch
2014-12-01 16:05:44 -08:00
parent 63053438ea
commit 0758165fb5
4 changed files with 47 additions and 10 deletions

View File

@ -79,8 +79,10 @@ export class ViewSplitter extends CompileStep {
var binding = bindings[i];
if (isPresent(binding.name)) {
compileElement.addVariableBinding(binding.key, binding.name);
} else {
} else if (isPresent(binding.expression)) {
compileElement.addPropertyBinding(binding.key, binding.expression);
} else {
compileElement.element.setAttribute(binding.key, '');
}
}
}

View File

@ -72,6 +72,14 @@ export function main() {
expect(results[1].variableBindings).toEqual(MapWrapper.createFromStringMap({'varName': 'mapName'}));
});
it('should add entries without value as attribute to the element', () => {
var rootElement = createElement('<div><div template="varname"></div></div>');
var results = createPipeline().process(rootElement);
expect(results[1].attrs()).toEqual(MapWrapper.createFromStringMap({'varname': ''}));
expect(results[1].propertyBindings).toBe(null);
expect(results[1].variableBindings).toBe(null);
});
});
});