feat(compiler): allow binding to className using class alias

Closes #2364
This commit is contained in:
Pawel Kozlowski
2015-08-12 10:44:46 +02:00
parent f2f4b905e5
commit a7a1851c0f
5 changed files with 36 additions and 1 deletions

View File

@ -212,6 +212,26 @@ export function main() {
});
}));
it('should consume binding to className using class alias',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View({template: '<div class="initial" [class]="ctxProp"></div>'}))
.createAsync(MyComp)
.then((rootTC) => {
var nativeEl = rootTC.componentViewChildren[0].nativeElement;
rootTC.componentInstance.ctxProp = 'foo bar';
rootTC.detectChanges();
expect(nativeEl).toHaveCssClass('foo');
expect(nativeEl).toHaveCssClass('bar');
expect(nativeEl).not.toHaveCssClass('initial');
async.done();
});
}));
it('should consume directive watch expression change.',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
var tpl = '<div>' +

View File

@ -104,6 +104,12 @@ export function main() {
var pv = builder.build(new DomElementSchemaRegistry(), templateCloner);
expect(pv.elementBinders[0].propertyBindings[0].property).toEqual('readOnly');
});
it('should normalize "class" to "className"', () => {
builder.bindElement(el('<div></div>')).bindProperty('class', emptyExpr());
var pv = builder.build(new DomElementSchemaRegistry(), templateCloner);
expect(pv.elementBinders[0].propertyBindings[0].property).toEqual('className');
});
});
describe('property binding', () => {