UNPKG

zoro-cli

Version:

https://github.com/vuejs/vue-cli

39 lines (33 loc) 1.06 kB
let passiveSupported // Safely detecting option support // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support export function isPassiveSupported() { if (passiveSupported === undefined) { try { const options = { get passive() { // This function will be called when the browser // attempts to access the passive property. passiveSupported = true return true }, } // Note that handleEvent() is ignored on event listeners that aren't called. window.addEventListener('test', options, options) window.removeEventListener('test', options, options) } catch (err) { passiveSupported = false } } return passiveSupported } export function packAddEventListenerOptions(options) { isPassiveSupported() return passiveSupported ? { ...options } : false } export function packAddEventListenerOptionsNoPassive(options) { return packAddEventListenerOptions({ ...options, passive: false, }) }