feat(compiler): allow binding to className using class alias
Closes #2364
This commit is contained in:
@ -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>' +
|
||||
|
@ -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', () => {
|
||||
|
Reference in New Issue
Block a user