Skip to content

Commit

Permalink
chore: use data-aria-label instead to avoid audit conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
DRiFTy17 committed Jun 12, 2024
1 parent 1349f46 commit c9057bd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/tabs/tab-bar/tab-bar-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export class TabBarAdapter extends BaseAdapter<ITabBarComponent> implements ITab
}

public initialize(): void {
this._forwardObserver = forwardAttributes(this._component, TAB_BAR_CONSTANTS.forwardedAttributes, (name, value) => {
toggleAttribute(this._scrollContainer, !!value, name, value ?? undefined);
this._forwardObserver = forwardAttributes(this._component, Object.keys(TAB_BAR_CONSTANTS.forwardedAttributes), (name, value) => {
toggleAttribute(this._scrollContainer, !!value, TAB_BAR_CONSTANTS.forwardedAttributes[name], value ?? undefined);
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/lib/tabs/tab-bar/tab-bar-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ const attributes = {
...observedAttributes
};

const forwardedAttributes = ['aria-label'];
const forwardedAttributes = {
'data-aria-label': 'aria-label'
};

const selectors = {
ROOT: '.forge-tab-bar',
Expand Down
1 change: 1 addition & 0 deletions src/lib/tabs/tab-bar/tab-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ declare global {
* @attribute {boolean} [secondary=false] - Controls whether the tabs are styled as secondary tab navigation.
* @attribute {boolean} [auto-activate=false] - Controls whether the tabs are automatically activated when receiving focus.
* @attribute {boolean} [scroll-buttons=false] - Controls whether scroll buttons are displayed when the tabs overflow their container.
* @attribute {string} [data-aria-label] - The ARIA label to forward to the internal tablist element.
*
* @event {CustomEvent<ITabBarChangeEventData>} forge-tab-bar-change - Dispatches when the active tab changes.
*
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tabs/tabs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Tabs', () => {

expect(scrollContainerEl.hasAttribute('aria-label')).to.be.false;

el.setAttribute('aria-label', 'Test');
el.setAttribute('data-aria-label', 'Test');
await elementUpdated(el);

expect(scrollContainerEl.getAttribute('aria-label')).to.equal('Test');
Expand Down
1 change: 1 addition & 0 deletions src/stories/components/tabs/Tabs.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const meta = {

return html`
<forge-tab-bar
data-aria-label="Demo tabs"
.disabled=${args.disabled}
.activeTab=${args.activeTab}
.vertical=${args.vertical}
Expand Down

0 comments on commit c9057bd

Please sign in to comment.