Skip to content

Instantly share code, notes, and snippets.

@tenthree
Created September 12, 2019 10:45
Show Gist options
  • Save tenthree/1d029e57b3fbdd121f221799b1272f0f to your computer and use it in GitHub Desktop.
Save tenthree/1d029e57b3fbdd121f221799b1272f0f to your computer and use it in GitHub Desktop.
detect passive event listener in browser
export let supportsPassive = false
if (typeof window !== 'undefined') {
supportsPassive = false
try {
var options = Object.defineProperty({}, 'passive', {
get () {
supportsPassive = true
},
})
window.addEventListener('test', null, options)
} catch (err) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment