Skip to content

Commit

Permalink
fix(helpers): check for window before adding listeners
Browse files Browse the repository at this point in the history
fixes #6952
  • Loading branch information
johnleider committed Apr 9, 2019
1 parent 0beff68 commit 8f477e6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/vuetify/src/util/helpers.ts
Expand Up @@ -152,14 +152,16 @@ export function addOnceEventListener (el: EventTarget, event: string, cb: () =>

let passiveSupported = false
try {
const testListenerOpts = Object.defineProperty({}, 'passive', {
get: () => {
passiveSupported = true
}
})
if (typeof window !== 'undefined') {
const testListenerOpts = Object.defineProperty({}, 'passive', {
get: () => {
passiveSupported = true
}
})

window.addEventListener('testListener', testListenerOpts, testListenerOpts)
window.removeEventListener('testListener', testListenerOpts, testListenerOpts)
window.addEventListener('testListener', testListenerOpts, testListenerOpts)
window.removeEventListener('testListener', testListenerOpts, testListenerOpts)
}
} catch (e) { console.warn(e) }
export { passiveSupported }

Expand Down

0 comments on commit 8f477e6

Please sign in to comment.