@@ -94,14 +94,16 @@ Zone.prototype = {
9494Zone . patchFn = function ( obj , fnNames ) {
9595 fnNames . forEach ( function ( name ) {
9696 var delegate = obj [ name ] ;
97- zone [ name ] = function ( ) {
98- arguments [ 0 ] = zone . bind ( arguments [ 0 ] ) ;
99- return delegate . apply ( obj , arguments ) ;
100- } ;
101-
102- obj [ name ] = function marker ( ) {
103- return zone [ name ] . apply ( this , arguments ) ;
104- } ;
97+ if ( delegate ) {
98+ zone [ name ] = function ( ) {
99+ arguments [ 0 ] = zone . bind ( arguments [ 0 ] ) ;
100+ return delegate . apply ( obj , arguments ) ;
101+ } ;
102+
103+ obj [ name ] = function marker ( ) {
104+ return zone [ name ] . apply ( this , arguments ) ;
105+ } ;
106+ }
105107 } ) ;
106108} ;
107109
@@ -182,12 +184,42 @@ Zone.patchEventTargetMethods = function (obj) {
182184} ;
183185
184186Zone . patch = function patch ( ) {
185- Zone . patchFn ( window , [ 'setTimeout' , 'setInterval' ] ) ;
187+ Zone . patchFn ( window , [
188+ 'setTimeout' ,
189+ 'setInterval' ,
190+ 'requestAnimationFrame' ,
191+ 'webkitRequestAnimationFrame'
192+ ] ) ;
186193 Zone . patchableFn ( window , [ 'alert' , 'prompt' ] ) ;
187194
188- // patched properties depend on addEventListener, so this comes first
189- // n.b. EventTarget is not available in all browsers so we patch Node here
190- Zone . patchEventTargetMethods ( Node . prototype ) ;
195+ // patched properties depend on addEventListener, so this needs to come first
196+ if ( EventTarget ) {
197+ Zone . patchEventTargetMethods ( EventTarget . prototype ) ;
198+
199+ // Note: EventTarget is not available in all browsers,
200+ // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget
201+ } else {
202+ [ ApplicationCache . prototype ,
203+ EventSource . prototype ,
204+ FileReader . prototype ,
205+ InputMethodContext . prototype ,
206+ MediaController . prototype ,
207+ MessagePort . prototype ,
208+ Node . prototype ,
209+ Performance . prototype ,
210+ SVGElementInstance . prototype ,
211+ SharedWorker . prototype ,
212+ TextTrack . prototype ,
213+ TextTrackCue . prototype ,
214+ TextTrackList . prototype ,
215+ WebKitNamedFlow . prototype ,
216+ Window . prototype ,
217+ Worker . prototype ,
218+ WorkerGlobalScope . prototype ,
219+ XMLHttpRequestEventTarget . prototype ,
220+ XMLHttpRequestUpload . prototype
221+ ] . forEach ( patchEventTargetMethods ) ;
222+ }
191223
192224 Zone . patchProperties ( HTMLElement . prototype ) ;
193225 Zone . patchProperties ( XMLHttpRequest . prototype ) ;
0 commit comments