Skip to content

Commit

Permalink
Fixed tooltip not being displayed in IE when title is set using Angul…
Browse files Browse the repository at this point in the history
…ar binding syntax

Fixes #138
  • Loading branch information
devoto13 committed Aug 9, 2019
1 parent 591f275 commit f8bf1ff
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/lib/icon/icon.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,36 @@ describe('FaIconComponent', () => {
expect(spy).not.toHaveBeenCalledWith();
});

it('should render a <title> element', () => {
@Component({
selector: 'fa-host',
template: '<fa-icon [icon]="faUser" title="User John Smith"></fa-icon>'
})
class HostComponent {
faUser = faUser;
}

const fixture = initTest(HostComponent);
fixture.detectChanges();
expect(queryByCss(fixture, 'svg > title')).toBeTruthy();
expect(queryByCss(fixture, 'svg > title').innerHTML).toBe('User John Smith');
});

it('should have title attribute, when title input is set using Angular binding syntax', () => {
@Component({
selector: 'fa-host',
template: `<fa-icon [icon]="faUser" [title]="'User John Smith'"></fa-icon>`
})
class HostComponent {
faUser = faUser;
}

const fixture = initTest(HostComponent);
fixture.detectChanges();
expect(queryByCss(fixture, 'svg')).toBeTruthy();
expect(queryByCss(fixture, 'fa-icon').getAttribute('title')).toBe('User John Smith');
});

describe('custom service configuration', () => {

let fixture: ComponentFixture<HostComponent>;
Expand Down
7 changes: 7 additions & 0 deletions src/lib/icon/icon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ import { FaIconService } from './icon.service';
template: ``,
host: {
class: 'ng-fa-icon',
'[attr.title]': 'title',
}
})
export class FaIconComponent implements OnChanges {
@Input() icon: IconProp;

/**
* Specify a title for the icon.
* This text will be displayed in a tooltip on hover and presented to the
* screen readers.
*/
@Input() title?: string;
@Input() spin?: boolean;
@Input() pulse?: boolean;
Expand Down

0 comments on commit f8bf1ff

Please sign in to comment.