Skip to content

Commit f31f979

Browse files
committed
refactor(icon): add afterNextRender for SSR, add aria-hidden attribute, improve testing
1 parent a1eba80 commit f31f979

File tree

8 files changed

+47
-31
lines changed

8 files changed

+47
-31
lines changed

projects/coreui-icons-angular/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 creativeLabs Łukasz Holeczek
3+
Copyright (c) 2024 creativeLabs Łukasz Holeczek
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

projects/coreui-icons-angular/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,5 @@ Thanks to all the backers and sponsors! Support this project by [becoming a back
169169
170170
## Copyright and license
171171
172-
Copyright 2023 creativeLabs Łukasz Holeczek. Code released under the [MIT License](https://github.com/coreui/coreui-angular/blob/main/LICENSE). Docs released under [Creative Commons](https://creativecommons.org/licenses/by/3.0/).
172+
Copyright 2024 creativeLabs Łukasz Holeczek. Code released under the [MIT License](https://github.com/coreui/coreui-angular/blob/main/LICENSE). Docs released under [Creative Commons](https://creativecommons.org/licenses/by/3.0/).
173173

projects/coreui-icons-angular/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "@coreui/icons-angular",
3-
"version": "4.7.16",
3+
"version": "5.0.0-next.23",
44
"description": "CoreUI Icons Angular component and service",
5-
"copyright": "Copyright 2023 creativeLabs Łukasz Holeczek",
5+
"copyright": "Copyright 2024 creativeLabs Łukasz Holeczek",
66
"license": "MIT",
77
"homepage": "https://coreui.io/angular",
88
"author": {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './public-api';
Lines changed: 30 additions & 25 deletions
Loading

projects/coreui-icons-angular/src/lib/icon/icon.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgClass, NgIf } from '@angular/common';
1+
import { NgClass } from '@angular/common';
22
import { AfterViewInit, Component, ElementRef, Input, Renderer2, ViewChild } from '@angular/core';
33
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
44

@@ -12,7 +12,7 @@ import { toCamelCase } from './icon.utils';
1212
templateUrl: './icon.component.svg',
1313
styleUrls: ['./icon.component.scss'],
1414
standalone: true,
15-
imports: [NgClass, NgIf, HtmlAttributesDirective],
15+
imports: [NgClass, HtmlAttributesDirective],
1616
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
1717
host: { ngSkipHydration: 'true' }
1818
})

projects/coreui-icons-angular/src/lib/icon/icon.directive.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@ describe('IconDirective', () => {
5353
expect(svgEl.nativeElement).toHaveClass('icon-lg');
5454
expect(svgEl.nativeElement).toHaveClass('test');
5555
});
56+
it('icon attributes should be applied', () => {
57+
expect(svgEl.nativeElement.getAttribute('aria-hidden')).toBe('true');
58+
expect(svgEl.nativeElement.getAttribute('pointer-events')).toBe('none');
59+
expect(svgEl.nativeElement.getAttribute('role')).toBe('img');
60+
expect(svgEl.nativeElement.getAttribute('title')).toBe('Test');
61+
expect(svgEl.nativeElement.getAttribute('viewBox')).toBeDefined();
62+
expect(svgEl.nativeElement.getAttribute('xmlns')).toBe('http://www.w3.org/2000/svg');
63+
});
5664
});

projects/coreui-icons-angular/src/lib/icon/icon.directive.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export class IconDirective implements IIcon {
3333

3434
private _viewBox!: string;
3535

36+
@HostBinding('attr.aria-hidden') ariaHidden = true;
37+
3638
@HostBinding('attr.xmlns')
3739
@Input() xmlns = 'http://www.w3.org/2000/svg';
3840

0 commit comments

Comments
 (0)