let events = []
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
// eslint-disable-next-line
for (const key in document) {
const isEvent = document[key] == null || typeof document[key] === 'function'
if (key.startsWith('on') && isEvent) {
events.push(key)
}
}
} else {
events = [
'onreadystatechange',
'onpointerlockchange',
'onpointerlockerror',
'onbeforecopy',
'onbeforecut',
'onbeforepaste',
'oncopy',
'oncut',
'onpaste',
'onsearch',
'onselectionchange',
'onselectstart',
'onvisibilitychange',
'onabort',
'onblur',
'oncancel',
'oncanplay',
'oncanplaythrough',
'onchange',
'onclick',
'onclose',
'oncontextmenu',
'oncuechange',
'ondblclick',
'ondrag',
'ondragend',
'ondragenter',
'ondragleave',
'ondragover',
'ondragstart',
'ondrop',
'ondurationchange',
'onemptied',
'onended',
'onerror',
'onfocus',
'oninput',
'oninvalid',
'onkeydown',
'onkeypress',
'onkeyup',
'onload',
'onloadeddata',
'onloadedmetadata',
'onloadstart',
'onmousedown',
'onmouseenter',
'onmouseleave',
'onmousemove',
'onmouseout',
'onmouseover',
'onmouseup',
'onmousewheel',
'onpause',
'onplay',
'onplaying',
'onprogress',
'onratechange',
'onreset',
'onresize',
'onscroll',
'onseeked',
'onseeking',
'onselect',
'onstalled',
'onsubmit',
'onsuspend',
'ontimeupdate',
'ontoggle',
'onvolumechange',
'onwaiting',
'onwheel',
'onauxclick',
'ongotpointercapture',
'onlostpointercapture',
'onpointerdown',
'onpointermove',
'onpointerup',
'onpointercancel',
'onpointerover',
'onpointerout',
'onpointerenter',
'onpointerleave',
'onwebkitfullscreenchange',
'onwebkitfullscreenerror',
'onsecuritypolicyviolation',
'onformdata',
'onfullscreenchange',
'onfullscreenerror',
'onfreeze',
'onresume'
]
}
module.exports = events
Also, currently, there are only 45 event names, but as of today it seems they are 95. As, probably no so common or used, but why not. Also it will decrease the bundle sizes, and will use this list only on server.
Something like this
Also, currently, there are only 45 event names, but as of today it seems they are 95. As, probably no so common or used, but why not. Also it will decrease the bundle sizes, and will use this list only on server.