feat(compiler): allow setting attributes on a host element
Closes #1402
This commit is contained in:
@ -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: {
|
||||
|
Reference in New Issue
Block a user