Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/VueLazyYoutubeVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ export default (Vue as WithRefs<Refs, WithEvents<Events>>).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' : ''
}`

Expand Down
6 changes: 3 additions & 3 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ 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({
propsData: getDefaultProps({ query }),
})
iframe = await TestManager.clickAndGetIframe(wrapper)
expect(iframe.element.getAttribute('src')).toBe(
`${defaultProps.src}${query}&autoplay=1`
`${defaultProps.src}${query}`
)
})

Expand Down Expand Up @@ -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`
)
})

Expand Down