dom-events.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. 'use strict';
  2. const getVendorPrefixedName = eventName => [
  3. `webkit${eventName}`,
  4. `o${eventName.toLowerCase()}`,
  5. eventName.toLowerCase(),
  6. ];
  7. // https://github.com/google/closure-library/blob/8782d8ba16ef2dd4a508d2081a6938f054fc60e8/closure/goog/events/eventtype.js#L44
  8. module.exports = new Set([
  9. // Mouse events
  10. 'click',
  11. 'rightclick',
  12. 'dblclick',
  13. 'auxclick',
  14. 'mousedown',
  15. 'mouseup',
  16. 'mouseover',
  17. 'mouseout',
  18. 'mousemove',
  19. 'mouseenter',
  20. 'mouseleave',
  21. // Non-existent event; will never fire. This exists as a mouse counterpart to
  22. // POINTERCANCEL.
  23. 'mousecancel',
  24. // Selection events.
  25. // https://www.w3.org/TR/selection-api/
  26. 'selectionchange',
  27. 'selectstart', // IE, Safari, Chrome
  28. // Wheel events
  29. // http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
  30. 'wheel',
  31. // Key events
  32. 'keypress',
  33. 'keydown',
  34. 'keyup',
  35. // Focus
  36. 'blur',
  37. 'focus',
  38. 'deactivate', // IE only
  39. 'focusin',
  40. 'focusout',
  41. // Forms
  42. 'change',
  43. 'reset',
  44. 'select',
  45. 'submit',
  46. 'input',
  47. 'propertychange', // IE only
  48. // Drag and drop
  49. 'dragstart',
  50. 'drag',
  51. 'dragenter',
  52. 'dragover',
  53. 'dragleave',
  54. 'drop',
  55. 'dragend',
  56. // Touch events
  57. // Note that other touch events exist, but we should follow the W3C list here.
  58. // http://www.w3.org/TR/touch-events/#list-of-touchevent-types
  59. 'touchstart',
  60. 'touchmove',
  61. 'touchend',
  62. 'touchcancel',
  63. // Misc
  64. 'beforeunload',
  65. 'consolemessage',
  66. 'contextmenu',
  67. 'devicechange',
  68. 'devicemotion',
  69. 'deviceorientation',
  70. 'DOMContentLoaded',
  71. 'error',
  72. 'help',
  73. 'load',
  74. 'losecapture',
  75. 'orientationchange',
  76. 'readystatechange',
  77. 'resize',
  78. 'scroll',
  79. 'unload',
  80. // Media events
  81. 'canplay',
  82. 'canplaythrough',
  83. 'durationchange',
  84. 'emptied',
  85. 'ended',
  86. 'loadeddata',
  87. 'loadedmetadata',
  88. 'pause',
  89. 'play',
  90. 'playing',
  91. 'progress',
  92. 'ratechange',
  93. 'seeked',
  94. 'seeking',
  95. 'stalled',
  96. 'suspend',
  97. 'timeupdate',
  98. 'volumechange',
  99. 'waiting',
  100. // Media Source Extensions events
  101. // https://www.w3.org/TR/media-source/#mediasource-events
  102. 'sourceopen',
  103. 'sourceended',
  104. 'sourceclosed',
  105. // https://www.w3.org/TR/media-source/#sourcebuffer-events
  106. 'abort',
  107. 'update',
  108. 'updatestart',
  109. 'updateend',
  110. // HTML 5 History events
  111. // See http://www.w3.org/TR/html5/browsers.html#event-definitions-0
  112. 'hashchange',
  113. 'pagehide',
  114. 'pageshow',
  115. 'popstate',
  116. // Copy and Paste
  117. // Support is limited. Make sure it works on your favorite browser
  118. // before using.
  119. // http://www.quirksmode.org/dom/events/cutcopypaste.html
  120. 'copy',
  121. 'paste',
  122. 'cut',
  123. 'beforecopy',
  124. 'beforecut',
  125. 'beforepaste',
  126. // HTML5 online/offline events.
  127. // http://www.w3.org/TR/offline-webapps/#related
  128. 'online',
  129. 'offline',
  130. // HTML 5 worker events
  131. 'message',
  132. 'connect',
  133. // Service Worker Events - ServiceWorkerGlobalScope context
  134. // See https://w3c.github.io/ServiceWorker/#execution-context-events
  135. // message event defined in worker events section
  136. 'install',
  137. 'activate',
  138. 'fetch',
  139. 'foreignfetch',
  140. 'messageerror',
  141. // Service Worker Events - Document context
  142. // See https://w3c.github.io/ServiceWorker/#document-context-events
  143. 'statechange',
  144. 'updatefound',
  145. 'controllerchange',
  146. // CSS animation events.
  147. ...getVendorPrefixedName('AnimationStart'),
  148. ...getVendorPrefixedName('AnimationEnd'),
  149. ...getVendorPrefixedName('AnimationIteration'),
  150. // CSS transition events. Based on the browser support described at:
  151. // https://developer.mozilla.org/en/css/css_transitions#Browser_compatibility
  152. ...getVendorPrefixedName('TransitionEnd'),
  153. // W3C Pointer Events
  154. // http://www.w3.org/TR/pointerevents/
  155. 'pointerdown',
  156. 'pointerup',
  157. 'pointercancel',
  158. 'pointermove',
  159. 'pointerover',
  160. 'pointerout',
  161. 'pointerenter',
  162. 'pointerleave',
  163. 'gotpointercapture',
  164. 'lostpointercapture',
  165. // IE specific events.
  166. // See http://msdn.microsoft.com/en-us/library/ie/hh772103(v=vs.85).aspx
  167. // these events will be supplanted in IE11.
  168. 'MSGestureChange',
  169. 'MSGestureEnd',
  170. 'MSGestureHold',
  171. 'MSGestureStart',
  172. 'MSGestureTap',
  173. 'MSGotPointerCapture',
  174. 'MSInertiaStart',
  175. 'MSLostPointerCapture',
  176. 'MSPointerCancel',
  177. 'MSPointerDown',
  178. 'MSPointerEnter',
  179. 'MSPointerHover',
  180. 'MSPointerLeave',
  181. 'MSPointerMove',
  182. 'MSPointerOut',
  183. 'MSPointerOver',
  184. 'MSPointerUp',
  185. // Native IMEs/input tools events.
  186. 'text',
  187. // The textInput event is supported in IE9+, but only in lower case. All other
  188. // browsers use the camel-case event name.
  189. 'textinput',
  190. 'textInput',
  191. 'compositionstart',
  192. 'compositionupdate',
  193. 'compositionend',
  194. // The beforeinput event is initially only supported in Safari. See
  195. // https://bugs.chromium.org/p/chromium/issues/detail?id=342670 for Chrome
  196. // implementation tracking.
  197. 'beforeinput',
  198. // Webview tag events
  199. // See https://developer.chrome.com/apps/tags/webview
  200. 'exit',
  201. 'loadabort',
  202. 'loadcommit',
  203. 'loadredirect',
  204. 'loadstart',
  205. 'loadstop',
  206. 'responsive',
  207. 'sizechanged',
  208. 'unresponsive',
  209. // HTML5 Page Visibility API. See details at
  210. // `goog.labs.dom.PageVisibilityMonitor`.
  211. 'visibilitychange',
  212. // LocalStorage event.
  213. 'storage',
  214. // DOM Level 2 mutation events (deprecated).
  215. 'DOMSubtreeModified',
  216. 'DOMNodeInserted',
  217. 'DOMNodeRemoved',
  218. 'DOMNodeRemovedFromDocument',
  219. 'DOMNodeInsertedIntoDocument',
  220. 'DOMAttrModified',
  221. 'DOMCharacterDataModified',
  222. // Print events.
  223. 'beforeprint',
  224. 'afterprint',
  225. // Web app manifest events.
  226. 'beforeinstallprompt',
  227. 'appinstalled',
  228. // https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/events/DOMEventNames.js#L12
  229. 'afterblur',
  230. 'beforeblur',
  231. 'cancel',
  232. 'close',
  233. 'dragexit',
  234. 'encrypted',
  235. 'fullscreenchange',
  236. 'invalid',
  237. 'toggle',
  238. // https://github.com/sindresorhus/eslint-plugin-unicorn/pull/147
  239. 'search',
  240. 'open',
  241. 'show',
  242. ]);