diff --git a/src/VueLazyYoutubeVideo.ts b/src/VueLazyYoutubeVideo.ts index 10ae738..6601d34 100644 --- a/src/VueLazyYoutubeVideo.ts +++ b/src/VueLazyYoutubeVideo.ts @@ -100,7 +100,9 @@ export default (Vue as WithRefs>).extend({ }, srcAttribute(): string { const hasQuestionMark = this.src.indexOf('?') !== -1 - const src = `${this.src}${hasQuestionMark ? '&' : '?'}autoplay=1${ + const src = `${this.src}${hasQuestionMark ? '&' : '?'}${ + this.autoplay ? 'autoplay=1' : '' + }${ this.enablejsapi ? '&enablejsapi=1' : '' }` diff --git a/test/index.test.ts b/test/index.test.ts index ac408f1..822b83d 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -33,7 +33,7 @@ describe('VueLazyYoutubeVideo', () => { let wrapper = TestManager.createWrapper() let iframe = await TestManager.clickAndGetIframe(wrapper) expect(iframe.element.getAttribute('src')).toBe( - `${defaultProps.src}?autoplay=1` + `${defaultProps.src}` ) const query = '?loop=1' wrapper = TestManager.createWrapper({ @@ -41,7 +41,7 @@ describe('VueLazyYoutubeVideo', () => { }) iframe = await TestManager.clickAndGetIframe(wrapper) expect(iframe.element.getAttribute('src')).toBe( - `${defaultProps.src}${query}&autoplay=1` + `${defaultProps.src}${query}` ) }) @@ -487,7 +487,7 @@ describe('VueLazyYoutubeVideo', () => { }) const iframe = await TestManager.clickAndGetIframe(wrapper) expect(iframe.element.getAttribute('src')).toBe( - `${defaultProps.src}?autoplay=1&rel=0&color=white` + `${defaultProps.src}?rel=0&color=white` ) })