@@ -10,9 +10,221 @@ import {isBrowser, isMix, isNode, patchClass, patchOnProperties, zoneSymbol} fro
10
10
11
11
import * as webSocketPatch from './websocket' ;
12
12
13
- const eventNames =
14
- 'copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror'
15
- . split ( ' ' ) ;
13
+ const globalEventHandlersEventNames = [
14
+ 'abort' ,
15
+ 'animationcancel' ,
16
+ 'animationend' ,
17
+ 'animationiteration' ,
18
+ 'auxclick' ,
19
+ 'beforeinput' ,
20
+ 'blur' ,
21
+ 'cancel' ,
22
+ 'canplay' ,
23
+ 'canplaythrough' ,
24
+ 'change' ,
25
+ 'compositionstart' ,
26
+ 'compositionupdate' ,
27
+ 'compositionend' ,
28
+ 'cuechange' ,
29
+ 'click' ,
30
+ 'close' ,
31
+ 'contextmenu' ,
32
+ 'curechange' ,
33
+ 'dblclick' ,
34
+ 'drag' ,
35
+ 'dragend' ,
36
+ 'dragenter' ,
37
+ 'dragexit' ,
38
+ 'dragleave' ,
39
+ 'dragover' ,
40
+ 'drop' ,
41
+ 'durationchange' ,
42
+ 'emptied' ,
43
+ 'ended' ,
44
+ 'error' ,
45
+ 'focus' ,
46
+ 'focusin' ,
47
+ 'focusout' ,
48
+ 'gotpointercapture' ,
49
+ 'input' ,
50
+ 'invalid' ,
51
+ 'keydown' ,
52
+ 'keypress' ,
53
+ 'keyup' ,
54
+ 'load' ,
55
+ 'loadstart' ,
56
+ 'loadeddata' ,
57
+ 'loadedmetadata' ,
58
+ 'lostpointercapture' ,
59
+ 'mousedown' ,
60
+ 'mouseenter' ,
61
+ 'mouseleave' ,
62
+ 'mousemove' ,
63
+ 'mouseout' ,
64
+ 'mouseover' ,
65
+ 'mouseup' ,
66
+ 'mousewheel' ,
67
+ 'pause' ,
68
+ 'play' ,
69
+ 'playing' ,
70
+ 'pointercancel' ,
71
+ 'pointerdown' ,
72
+ 'pointerenter' ,
73
+ 'pointerleave' ,
74
+ 'pointerlockchange' ,
75
+ 'mozpointerlockchange' ,
76
+ 'webkitpointerlockerchange' ,
77
+ 'pointerlockerror' ,
78
+ 'mozpointerlockerror' ,
79
+ 'webkitpointerlockerror' ,
80
+ 'pointermove' ,
81
+ 'pointout' ,
82
+ 'pointerover' ,
83
+ 'pointerup' ,
84
+ 'progress' ,
85
+ 'ratechange' ,
86
+ 'reset' ,
87
+ 'resize' ,
88
+ 'scroll' ,
89
+ 'seeked' ,
90
+ 'seeking' ,
91
+ 'select' ,
92
+ 'selectionchange' ,
93
+ 'selectstart' ,
94
+ 'show' ,
95
+ 'sort' ,
96
+ 'stalled' ,
97
+ 'submit' ,
98
+ 'suspend' ,
99
+ 'timeupdate' ,
100
+ 'volumechange' ,
101
+ 'touchcancel' ,
102
+ 'touchmove' ,
103
+ 'touchstart' ,
104
+ 'transitioncancel' ,
105
+ 'transitionend' ,
106
+ 'waiting' ,
107
+ 'wheel'
108
+ ] ;
109
+ const documentEventNames = [
110
+ 'afterscriptexecute' , 'beforescriptexecute' , 'DOMContentLoaded' , 'fullscreenchange' ,
111
+ 'mozfullscreenchange' , 'webkitfullscreenchange' , 'msfullscreenchange' , 'fullscreenerror' ,
112
+ 'mozfullscreenerror' , 'webkitfullscreenerror' , 'msfullscreenerror' , 'readystatechange'
113
+ ] ;
114
+ const windowEventNames = [
115
+ 'absolutedeviceorientation' ,
116
+ 'afterinput' ,
117
+ 'afterprint' ,
118
+ 'appinstalled' ,
119
+ 'beforeinstallprompt' ,
120
+ 'beforeprint' ,
121
+ 'beforeunload' ,
122
+ 'devicelight' ,
123
+ 'devicemotion' ,
124
+ 'deviceorientation' ,
125
+ 'deviceorientationabsolute' ,
126
+ 'deviceproximity' ,
127
+ 'hashchange' ,
128
+ 'languagechange' ,
129
+ 'message' ,
130
+ 'mozbeforepaint' ,
131
+ 'offline' ,
132
+ 'online' ,
133
+ 'paint' ,
134
+ 'pageshow' ,
135
+ 'pagehide' ,
136
+ 'popstate' ,
137
+ 'rejectionhandled' ,
138
+ 'storage' ,
139
+ 'unhandledrejection' ,
140
+ 'unload' ,
141
+ 'userproximity' ,
142
+ 'vrdisplyconnected' ,
143
+ 'vrdisplaydisconnected' ,
144
+ 'vrdisplaypresentchange'
145
+ ] ;
146
+ const htmlElementEventNames = [
147
+ 'beforecopy' , 'beforecut' , 'beforepaste' , 'copy' , 'cut' , 'paste' , 'dragstart' , 'loadend' ,
148
+ 'animationstart' , 'search' , 'transitionrun' , 'transitionstart' , 'webkitanimationend' ,
149
+ 'webkitanimationiteration' , 'webkitanimationstart' , 'webkittransitionend'
150
+ ] ;
151
+ const mediaElementEventNames =
152
+ [ 'encrypted' , 'waitingforkey' , 'msneedkey' , 'mozinterruptbegin' , 'mozinterruptend' ] ;
153
+ const ieElementEventNames = [
154
+ 'activate' ,
155
+ 'afterupdate' ,
156
+ 'ariarequest' ,
157
+ 'beforeactivate' ,
158
+ 'beforedeactivate' ,
159
+ 'beforeeditfocus' ,
160
+ 'beforeupdate' ,
161
+ 'cellchange' ,
162
+ 'controlselect' ,
163
+ 'dataavailable' ,
164
+ 'datasetchanged' ,
165
+ 'datasetcomplete' ,
166
+ 'errorupdate' ,
167
+ 'filterchange' ,
168
+ 'layoutcomplete' ,
169
+ 'losecapture' ,
170
+ 'move' ,
171
+ 'moveend' ,
172
+ 'movestart' ,
173
+ 'propertychange' ,
174
+ 'resizeend' ,
175
+ 'resizestart' ,
176
+ 'rowenter' ,
177
+ 'rowexit' ,
178
+ 'rowsdelete' ,
179
+ 'rowsinserted' ,
180
+ 'command' ,
181
+ 'compassneedscalibration' ,
182
+ 'deactivate' ,
183
+ 'help' ,
184
+ 'mscontentzoom' ,
185
+ 'msmanipulationstatechanged' ,
186
+ 'msgesturechange' ,
187
+ 'msgesturedoubletap' ,
188
+ 'msgestureend' ,
189
+ 'msgesturehold' ,
190
+ 'msgesturestart' ,
191
+ 'msgesturetap' ,
192
+ 'msgotpointercapture' ,
193
+ 'msinertiastart' ,
194
+ 'mslostpointercapture' ,
195
+ 'mspointercancel' ,
196
+ 'mspointerdown' ,
197
+ 'mspointerenter' ,
198
+ 'mspointerhover' ,
199
+ 'mspointerleave' ,
200
+ 'mspointermove' ,
201
+ 'mspointerout' ,
202
+ 'mspointerover' ,
203
+ 'mspointerup' ,
204
+ 'pointerout' ,
205
+ 'mssitemodejumplistitemremoved' ,
206
+ 'msthumbnailclick' ,
207
+ 'stop' ,
208
+ 'storagecommit'
209
+ ] ;
210
+ const webglEventNames = [ 'webglcontextrestored' , 'webglcontextlost' , 'webglcontextcreationerror' ] ;
211
+ const formEventNames = [ 'autocomplete' , 'autocompleteerror' ] ;
212
+ const detailEventNames = [ 'toggle' ] ;
213
+ const frameEventNames = [ 'load' ] ;
214
+ const frameSetEventNames = [ 'blur' , 'error' , 'focus' , 'load' , 'resize' , 'scroll' ] ;
215
+ const marqueeEventNames = [ 'bounce' , 'finish' , 'start' ] ;
216
+
217
+ const XMLHttpRequestEventNames = [
218
+ 'loadstart' , 'progress' , 'abort' , 'error' , 'load' , 'progress' , 'timeout' , 'loadend' ,
219
+ 'readystatechange'
220
+ ] ;
221
+ const IDBIndexEventNames =
222
+ [ 'upgradeneeded' , 'complete' , 'abort' , 'success' , 'error' , 'blocked' , 'versionchange' , 'close' ] ;
223
+ const websocketEventNames = [ 'close' , 'error' , 'open' , 'message' ] ;
224
+
225
+ const eventNames = globalEventHandlersEventNames . concat (
226
+ webglEventNames , formEventNames , detailEventNames , documentEventNames , windowEventNames ,
227
+ htmlElementEventNames , ieElementEventNames ) ;
16
228
17
229
export function propertyDescriptorPatch ( _global : any ) {
18
230
if ( isNode && ! isMix ) {
@@ -23,24 +235,44 @@ export function propertyDescriptorPatch(_global: any) {
23
235
if ( canPatchViaPropertyDescriptor ( ) ) {
24
236
// for browsers that we can patch the descriptor: Chrome & Firefox
25
237
if ( isBrowser ) {
26
- patchOnProperties ( window , eventNames . concat ( [ 'resize' ] ) ) ;
238
+ // in IE/Edge, onProp not exist in window object, but in WindowPrototype
239
+ // so we need to pass WindowPrototype to check onProp exist or not
240
+ patchOnProperties ( window , eventNames , Object . getPrototypeOf ( window ) ) ;
27
241
patchOnProperties ( Document . prototype , eventNames ) ;
242
+
28
243
if ( typeof ( < any > window ) [ 'SVGElement' ] !== 'undefined' ) {
29
244
patchOnProperties ( ( < any > window ) [ 'SVGElement' ] . prototype , eventNames ) ;
30
245
}
246
+ patchOnProperties ( Element . prototype , eventNames ) ;
31
247
patchOnProperties ( HTMLElement . prototype , eventNames ) ;
248
+ patchOnProperties ( HTMLMediaElement . prototype , mediaElementEventNames ) ;
249
+ patchOnProperties ( HTMLFrameSetElement . prototype , windowEventNames . concat ( frameSetEventNames ) ) ;
250
+ patchOnProperties ( HTMLBodyElement . prototype , windowEventNames . concat ( frameSetEventNames ) ) ;
251
+ patchOnProperties ( HTMLFrameElement . prototype , frameEventNames ) ;
252
+ patchOnProperties ( HTMLIFrameElement . prototype , frameEventNames ) ;
253
+
254
+ const HTMLMarqueeElement = ( window as any ) [ 'HTMLMarqueeElement' ] ;
255
+ if ( HTMLMarqueeElement ) {
256
+ patchOnProperties ( HTMLMarqueeElement . prototype , marqueeEventNames ) ;
257
+ }
258
+ }
259
+ patchOnProperties ( XMLHttpRequest . prototype , XMLHttpRequestEventNames ) ;
260
+ const XMLHttpRequestEventTarget = _global [ 'XMLHttpRequestEventTarget' ] ;
261
+ if ( XMLHttpRequestEventTarget ) {
262
+ patchOnProperties (
263
+ XMLHttpRequestEventTarget && XMLHttpRequestEventTarget . prototype ,
264
+ XMLHttpRequestEventNames ) ;
32
265
}
33
- patchOnProperties ( XMLHttpRequest . prototype , null ) ;
34
266
if ( typeof IDBIndex !== 'undefined' ) {
35
- patchOnProperties ( IDBIndex . prototype , null ) ;
36
- patchOnProperties ( IDBRequest . prototype , null ) ;
37
- patchOnProperties ( IDBOpenDBRequest . prototype , null ) ;
38
- patchOnProperties ( IDBDatabase . prototype , null ) ;
39
- patchOnProperties ( IDBTransaction . prototype , null ) ;
40
- patchOnProperties ( IDBCursor . prototype , null ) ;
267
+ patchOnProperties ( IDBIndex . prototype , IDBIndexEventNames ) ;
268
+ patchOnProperties ( IDBRequest . prototype , IDBIndexEventNames ) ;
269
+ patchOnProperties ( IDBOpenDBRequest . prototype , IDBIndexEventNames ) ;
270
+ patchOnProperties ( IDBDatabase . prototype , IDBIndexEventNames ) ;
271
+ patchOnProperties ( IDBTransaction . prototype , IDBIndexEventNames ) ;
272
+ patchOnProperties ( IDBCursor . prototype , IDBIndexEventNames ) ;
41
273
}
42
274
if ( supportsWebSocket ) {
43
- patchOnProperties ( WebSocket . prototype , null ) ;
275
+ patchOnProperties ( WebSocket . prototype , websocketEventNames ) ;
44
276
}
45
277
} else {
46
278
// Safari, Android browsers (Jelly Bean)
0 commit comments