Skip to content

Commit

Permalink
feat(icon): move aria-hidden from host element to svg
Browse files Browse the repository at this point in the history
  • Loading branch information
samrichardsontylertech committed Sep 29, 2023
1 parent 5633ef2 commit be2c5a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/lib/icon/icon-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { BaseAdapter, IBaseAdapter } from '../core';
import { ICON_CONSTANTS } from './icon-constants';

export interface IIconAdapter extends IBaseAdapter {
initialize(): void;
canLazyLoad(): boolean;
observeVisibility(listener: () => void): void;
destroyVisibilityObserver(): void;
Expand All @@ -17,12 +16,6 @@ export class IconAdapter extends BaseAdapter<IIconComponent> implements IIconAda
super(component);
}

public initialize(): void {
if (!this._component.hasAttribute('aria-hidden')) {
this._component.setAttribute('aria-hidden', 'true');
}
}

public canLazyLoad(): boolean {
return !!window.IntersectionObserver;
}
Expand All @@ -48,6 +41,9 @@ export class IconAdapter extends BaseAdapter<IIconComponent> implements IIconAda
const shadowRoot = this._component.shadowRoot as ShadowRoot;
const styleTag = shadowRoot.querySelector('style');
shadowRoot.innerHTML = content;
if (content) {
shadowRoot.firstElementChild?.setAttribute('aria-hidden', 'true');
}
if (styleTag) {
shadowRoot.appendChild(styleTag);
}
Expand Down
1 change: 0 additions & 1 deletion src/lib/icon/icon-foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class IconFoundation implements IIconFoundation {
}

public initialize(): void {
this._adapter.initialize();
this._applyIcon();
}

Expand Down

0 comments on commit be2c5a6

Please sign in to comment.