Skip to content

Commit 7a01bd2

Browse files
committed
Use existing default-tab attribute
1 parent 181fc4a commit 7a01bd2

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ import '@github/tab-container-element'
3131
</tab-container>
3232
```
3333

34-
If none of the tabs have `aria-selected=true`, then the first tab will be selected automatically. You can also add the `default-tab-index=N` attribute to avoid having to set `aria-selected=true` on the desired tab, where `N` is the 0-based tab index:
34+
If none of the tabs have `aria-selected=true`, then the first tab will be selected automatically. You can also add the `default-tab=N` attribute to avoid having to set `aria-selected=true` on the desired tab, where `N` is the 0-based tab index:
3535

3636
```html
3737
<!-- The _second_ tab will be selected -->
38-
<tab-container default-tab-index="1">
38+
<tab-container default-tab="1">
3939
<button type="button" id="tab-one" role="tab">Tab one</button>
4040
<button type="button" id="tab-two" role="tab">Tab two</button>
4141
<button type="button" id="tab-three" role="tab">Tab three</button>

src/tab-container-element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ export class TabContainerElement extends HTMLElement {
255255
}
256256

257257
get defaultTabIndex(): number {
258-
return Number(this.getAttribute('default-tab-index') || -1)
258+
return Number(this.getAttribute('default-tab') || -1)
259259
}
260260

261261
set defaultTabIndex(index: number) {
262-
this.setAttribute('default-tab-index', String(index))
262+
this.setAttribute('default-tab', String(index))
263263
}
264264

265265
selectTab(index: number): void {

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe('tab-container', function () {
111111
describe('after tree insertion with defaulTabIndex', function () {
112112
beforeEach(function () {
113113
document.body.innerHTML = `
114-
<tab-container defaultTabIndex=1>
114+
<tab-container default-tab="1">
115115
<button type="button" role="tab">Tab one</button>
116116
<button type="button" role="tab">Tab two</button>
117117
<button type="button" role="tab">Tab three</button>

0 commit comments

Comments
 (0)