Skip to content
This repository was archived by the owner on Oct 24, 2018. It is now read-only.

Commit c5047aa

Browse files
author
Evan Brown
committed
Fix bug which causes tab <section>s to have a leading # before id attribute.
1 parent 88b969c commit c5047aa

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to `vue-tabs-component` will be documented in this file
44

5+
## 1.4.1 - 2018-03-06
6+
- Fixed a bug which caused sections within tabs to have a '#' included in their id attribute.
7+
58
## 1.4.0 - 2017-11-06
69
- Added `isDisabled` prop to `Tab`
710

__tests__/__snapshots__/tabs.test.js.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
exports[`vue-tabs-component can accept a prefix and a suffix for the name 1`] = `
44
"
5-
<div id=\\"app\\"><div class=\\"tabs-component\\"><ul role=\\"tablist\\" class=\\"tabs-component-tabs\\"><li role=\\"presentation\\" class=\\"tabs-component-tab is-active\\"><a aria-controls=\\"#first-tab\\" aria-selected=\\"true\\" href=\\"#first-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">prefixFirst tabsuffix</a></li></ul> <div class=\\"tabs-component-panels\\"><section id=\\"#first-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"\\">
5+
<div id=\\"app\\"><div class=\\"tabs-component\\"><ul role=\\"tablist\\" class=\\"tabs-component-tabs\\"><li role=\\"presentation\\" class=\\"tabs-component-tab is-active\\"><a aria-controls=\\"#first-tab\\" aria-selected=\\"true\\" href=\\"#first-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">prefixFirst tabsuffix</a></li></ul> <div class=\\"tabs-component-panels\\"><section id=\\"first-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"\\">
66
First tab content
77
</section></div></div></div>
88
"
99
`;
1010
1111
exports[`vue-tabs-component can mount tabs 1`] = `
1212
"
13-
<div id=\\"app\\"><div class=\\"tabs-component\\"><ul role=\\"tablist\\" class=\\"tabs-component-tabs\\"><li role=\\"presentation\\" class=\\"tabs-component-tab is-active\\"><a aria-controls=\\"#first-tab\\" aria-selected=\\"true\\" href=\\"#first-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">First tab</a></li><li role=\\"presentation\\" class=\\"tabs-component-tab\\"><a aria-controls=\\"#second-tab\\" href=\\"#second-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">Second tab</a></li><li role=\\"presentation\\" class=\\"tabs-component-tab\\"><a aria-controls=\\"#third-tab\\" href=\\"#third-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">Third tab</a></li></ul> <div class=\\"tabs-component-panels\\"><section id=\\"#first-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"\\">
13+
<div id=\\"app\\"><div class=\\"tabs-component\\"><ul role=\\"tablist\\" class=\\"tabs-component-tabs\\"><li role=\\"presentation\\" class=\\"tabs-component-tab is-active\\"><a aria-controls=\\"#first-tab\\" aria-selected=\\"true\\" href=\\"#first-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">First tab</a></li><li role=\\"presentation\\" class=\\"tabs-component-tab\\"><a aria-controls=\\"#second-tab\\" href=\\"#second-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">Second tab</a></li><li role=\\"presentation\\" class=\\"tabs-component-tab\\"><a aria-controls=\\"#third-tab\\" href=\\"#third-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">Third tab</a></li></ul> <div class=\\"tabs-component-panels\\"><section id=\\"first-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"\\">
1414
First tab content
15-
</section> <section aria-hidden=\\"true\\" id=\\"#second-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"display: none;\\">
15+
</section> <section aria-hidden=\\"true\\" id=\\"second-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"display: none;\\">
1616
Second tab content
17-
</section> <section aria-hidden=\\"true\\" id=\\"#third-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"display: none;\\">
17+
</section> <section aria-hidden=\\"true\\" id=\\"third-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"display: none;\\">
1818
Third tab content
1919
</section></div></div></div>
2020
"
@@ -28,11 +28,11 @@ Object {
2828
2929
exports[`vue-tabs-component uses the fragment of the url to determine which tab to open 1`] = `
3030
"
31-
<div id=\\"app\\"><div class=\\"tabs-component\\"><ul role=\\"tablist\\" class=\\"tabs-component-tabs\\"><li role=\\"presentation\\" class=\\"tabs-component-tab\\"><a aria-controls=\\"#first-tab\\" href=\\"#first-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">First tab</a></li><li role=\\"presentation\\" class=\\"tabs-component-tab is-active\\"><a aria-controls=\\"#second-tab\\" aria-selected=\\"true\\" href=\\"#second-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">Second tab</a></li><li role=\\"presentation\\" class=\\"tabs-component-tab\\"><a aria-controls=\\"#third-tab\\" href=\\"#third-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">Third tab</a></li></ul> <div class=\\"tabs-component-panels\\"><section aria-hidden=\\"true\\" id=\\"#first-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"display: none;\\">
31+
<div id=\\"app\\"><div class=\\"tabs-component\\"><ul role=\\"tablist\\" class=\\"tabs-component-tabs\\"><li role=\\"presentation\\" class=\\"tabs-component-tab\\"><a aria-controls=\\"#first-tab\\" href=\\"#first-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">First tab</a></li><li role=\\"presentation\\" class=\\"tabs-component-tab is-active\\"><a aria-controls=\\"#second-tab\\" aria-selected=\\"true\\" href=\\"#second-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">Second tab</a></li><li role=\\"presentation\\" class=\\"tabs-component-tab\\"><a aria-controls=\\"#third-tab\\" href=\\"#third-tab\\" role=\\"tab\\" class=\\"tabs-component-tab-a\\">Third tab</a></li></ul> <div class=\\"tabs-component-panels\\"><section aria-hidden=\\"true\\" id=\\"first-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"display: none;\\">
3232
First tab content
33-
</section> <section id=\\"#second-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"\\">
33+
</section> <section id=\\"second-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"\\">
3434
Second tab content
35-
</section> <section aria-hidden=\\"true\\" id=\\"#third-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"display: none;\\">
35+
</section> <section aria-hidden=\\"true\\" id=\\"third-tab\\" role=\\"tabpanel\\" class=\\"tabs-component-panel\\" style=\\"display: none;\\">
3636
Third tab content
3737
</section></div></div></div>
3838
"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-tabs-component",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "A Vue component to easily render tabs",
55
"main": "dist/index.js",
66
"jsnext:main": "src/index.js",

src/components/Tab.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<section v-show="isActive"
33
:aria-hidden="! isActive"
44
class="tabs-component-panel"
5-
:id="hash"
5+
:id="computedId"
66
role="tabpanel"
77
>
88
<slot />
@@ -29,14 +29,16 @@
2929
return this.prefix + this.name + this.suffix;
3030
},
3131
32+
computedId() {
33+
return this.id ? this.id : this.name.toLowerCase().replace(/ /g, '-');
34+
},
35+
3236
hash() {
3337
if (this.isDisabled) {
3438
return '#';
3539
}
3640
37-
return this.id ?
38-
'#' + this.id :
39-
'#' + this.name.toLowerCase().replace(/ /g, '-');
41+
return '#' + this.computedId;
4042
},
4143
},
4244
};

0 commit comments

Comments
 (0)