diff --git a/package.json b/package.json index 0bad613..bc3d672 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "svg-icon", "description": "Angular 18 component and service for inlining SVGs allowing them to be easily styled with CSS.", - "version": "18.0.1", + "version": "18.0.2", "repository": { "type": "git", "url": "https://github.com/czeckd/angular-svg-icon.git" @@ -16,7 +16,6 @@ "scripts": { "ng": "ng", "start": "ng serve", - "build": "ng build --configuration production", "dist": "ng build --configuration production angular-svg-icon && cp README.md LICENSE ./dist/angular-svg-icon/", "test": "ng test --source-map=false angular-svg-icon", "coverage": "ng test --code-coverage angular-svg-icon", diff --git a/projects/angular-svg-icon/package.json b/projects/angular-svg-icon/package.json index 22a0d2d..e1cc0cb 100644 --- a/projects/angular-svg-icon/package.json +++ b/projects/angular-svg-icon/package.json @@ -1,7 +1,7 @@ { "name": "angular-svg-icon", "description": "Angular 18 component and service for inlining SVGs allowing them to be easily styled with CSS.", - "version": "18.0.1", + "version": "18.0.2", "repository": { "type": "git", "url": "https://github.com/czeckd/angular-svg-icon.git" diff --git a/projects/angular-svg-icon/src/lib/svg-icon.component.ts b/projects/angular-svg-icon/src/lib/svg-icon.component.ts index e247f4a..440bfa0 100644 --- a/projects/angular-svg-icon/src/lib/svg-icon.component.ts +++ b/projects/angular-svg-icon/src/lib/svg-icon.component.ts @@ -260,18 +260,19 @@ export class SvgIconComponent implements OnDestroy { } private doAria(label: string) { - const svg = this.element.nativeElement.firstChild; - // If there is not a svgAriaLabel and the SVG has an arial-label, then do not override - // the SVG's aria-label. - if (svg && !(label === undefined && svg.hasAttribute('aria-label'))) { - if (label === '') { - this.renderer.setAttribute(svg, 'aria-hidden', 'true'); - this.renderer.removeAttribute(svg, 'aria-label'); - } else { - this.renderer.removeAttribute(svg, 'aria-hidden'); - this.renderer.setAttribute(svg, 'aria-label', label); - } - } - } - + if (label !== undefined) { + const svg = this.element.nativeElement.firstChild; + // If there is not a svgAriaLabel and the SVG has an arial-label, then do not override + // the SVG's aria-label. + if (svg && !svg.hasAttribute('aria-label')) { + if (label === '') { + this.renderer.setAttribute(svg, 'aria-hidden', 'true'); + this.renderer.removeAttribute(svg, 'aria-label'); + } else { + this.renderer.removeAttribute(svg, 'aria-hidden'); + this.renderer.setAttribute(svg, 'aria-label', label); + } + } + } + } }