feat(compiler): allow setting attributes on a host element

Closes #1402
This commit is contained in:
Pawel Kozlowski
2015-05-01 13:41:56 +02:00
parent 7225416661
commit 51839ca677
12 changed files with 107 additions and 1 deletions

View File

@ -617,6 +617,21 @@ export function main() {
});
}));
it('should support updating host element via hostAttributes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideView(MyComp, new View({
template: '<div update-host-attributes></div>',
directives: [DirectiveUpdatingHostAttributes]
}));
tb.createView(MyComp, {context: ctx}).then((view) => {
view.detectChanges();
expect(DOM.getAttribute(view.rootNodes[0], "role")).toEqual("button");
async.done();
});
}));
it('should support updating host element via hostProperties', inject([TestBed, AsyncTestCompleter], (tb, async) => {
tb.overrideView(MyComp, new View({
template: '<div update-host-properties></div>',
@ -1095,6 +1110,15 @@ class DirectiveEmitingEvent {
}
}
@Directive({
selector: '[update-host-attributes]',
hostAttributes: {
'role' : 'button'
}
})
class DirectiveUpdatingHostAttributes {
}
@Directive({
selector: '[update-host-properties]',
hostProperties: {