Skip to content

Commit bb826df

Browse files
Merge branch 'v0.17.0' into feat-fix-aria
2 parents db2d9ed + a895b28 commit bb826df

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export default {
9191
| spacePadding | Number | 0 | Stage padding option adds left and right padding style (in pixels) onto VueCarousel-inner. |
9292
| spacePaddingMaxOffsetFactor | Number | 0 | Specify by how much should the space padding value be multiplied of, to re-arange the final slide padding. |
9393
| speed | Number | 500 | Slide transition speed. Number of milliseconds accepted. |
94+
| tagName | String | slide | Name (tag) of slide component. Overwrite with coponent name when extending slide component. |
9495
| value | Number | | Support for v-model functionality. Setting this value will change the current page to the number inputted (if between 0 and pageCount). |
9596

9697

src/Carousel.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ export default {
309309
type: Number,
310310
default: 500
311311
},
312+
/**
313+
* Name (tag) of slide component
314+
* Overwrite when extending slide component
315+
*/
316+
tagName: {
317+
type: String,
318+
default: "slide"
319+
},
312320
/**
313321
* Support for v-model functionality
314322
*/
@@ -633,7 +641,9 @@ export default {
633641
(this.$slots &&
634642
this.$slots.default &&
635643
this.$slots.default.filter(
636-
slot => slot.tag && slot.tag.indexOf("slide") > -1
644+
slot =>
645+
slot.tag &&
646+
slot.tag.match(`^vue-component-\\d+-${this.tagName}$`) !== null
637647
).length) ||
638648
0;
639649
},
@@ -643,7 +653,9 @@ export default {
643653
*/
644654
getSlide(index) {
645655
const slides = this.$children.filter(
646-
child => child.$vnode.tag.indexOf("slide") > -1
656+
child =>
657+
child.$vnode.tag.match(`^vue-component-\\d+-${this.tagName}$`) !==
658+
null
647659
);
648660
return slides[index];
649661
},

tests/client/components/__snapshots__/carousel.spec.js.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,21 @@ exports[`Carousel should not reset autoplay when switching slide with autoplayHo
175175
"
176176
`;
177177

178+
exports[`Carousel should only count slides matching tagName 1`] = `
179+
".VueCarousel-wrapper
180+
.VueCarousel-inner(role='listbox', style='transform: translate(0px, 0); visibility: hidden; height: auto;')
181+
.VueCarousel-slide(tabindex='-1')
182+
.VueCarousel-slide(tabindex='-1')
183+
.VueCarousel-slide(tabindex='-1')
184+
|
185+
.VueCarousel-pagination(style='display: none;')
186+
ul.VueCarousel-dot-container(role='tablist')
187+
li.VueCarousel-dot.VueCarousel-dot--active(aria-hidden='false', role='presentation', aria-selected='true', style='margin-top: 20px; padding: 10px;')
188+
button.VueCarousel-dot-button(type='button', role='button', aria-label='\`Item \${index}\`', title='Item 0', tabindex='0', style='width: 10px; height: 10px; background: rgb(0, 0, 0);')
189+
//
190+
"
191+
`;
192+
178193
exports[`Carousel should register 0 slides when 0 slides are added to the slots 1`] = `
179194
".VueCarousel-wrapper
180195
.VueCarousel-inner(style='transform: translate(0px, 0); visibility: hidden; height: auto;')

tests/client/components/carousel.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,24 @@ describe('Carousel', () => {
292292
return utils.expectToMatchSnapshot(wrapper.vm);
293293
});
294294

295+
it('should only count slides matching tagName', () => {
296+
const CustomSlide = {
297+
extends: Slide,
298+
name: 'CustomSlide',
299+
};
300+
const wrapper = mount(Carousel, {
301+
propsData: {
302+
tagName: 'CustomSlide'
303+
},
304+
slots: {
305+
default: [CustomSlide, CustomSlide, Slide]
306+
}
307+
});
308+
expect(wrapper.vm.tagName).toBe('CustomSlide');
309+
expect(wrapper.vm.slideCount).toBe(2);
310+
return utils.expectToMatchSnapshot(wrapper.vm);
311+
});
312+
295313
it('should set carousel height to slide height', done => {
296314
const wrapper = mount(Carousel, {
297315
propsData: {

0 commit comments

Comments
 (0)