This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -497,6 +497,9 @@ export function patchEventTarget(
497
497
target [ symbolEventName ] = null ;
498
498
}
499
499
existingTask . zone . cancelTask ( existingTask ) ;
500
+ if ( returnTarget ) {
501
+ return target ;
502
+ }
500
503
return ;
501
504
}
502
505
}
@@ -571,6 +574,10 @@ export function patchEventTarget(
571
574
}
572
575
}
573
576
}
577
+
578
+ if ( returnTarget ) {
579
+ return this ;
580
+ }
574
581
} ;
575
582
576
583
// for native toString patch
Original file line number Diff line number Diff line change @@ -66,6 +66,13 @@ describe('nodejs EventEmitter', () => {
66
66
emitter . emit ( 'test2' , 'test value' ) ;
67
67
} ) ;
68
68
} ) ;
69
+ it ( 'remove listener should return event emitter' , ( ) => {
70
+ zoneA . run ( ( ) => {
71
+ emitter . on ( 'test' , shouldNotRun ) ;
72
+ expect ( emitter . removeListener ( 'test' , shouldNotRun ) ) . toEqual ( emitter ) ;
73
+ emitter . emit ( 'test' , 'test value' ) ;
74
+ } ) ;
75
+ } ) ;
69
76
it ( 'should return all listeners for an event' , ( ) => {
70
77
zoneA . run ( ( ) => {
71
78
emitter . on ( 'test' , expectZoneA ) ;
@@ -106,6 +113,14 @@ describe('nodejs EventEmitter', () => {
106
113
expect ( emitter . listeners ( 'test' ) . length ) . toEqual ( 0 ) ;
107
114
} ) ;
108
115
} ) ;
116
+ it ( 'remove All listeners should return event emitter' , ( ) => {
117
+ zoneA . run ( ( ) => {
118
+ emitter . on ( 'test' , expectZoneA ) ;
119
+ emitter . on ( 'test' , expectZoneA ) ;
120
+ expect ( emitter . removeAllListeners ( 'test' ) ) . toEqual ( emitter ) ;
121
+ expect ( emitter . listeners ( 'test' ) . length ) . toEqual ( 0 ) ;
122
+ } ) ;
123
+ } ) ;
109
124
it ( 'should remove All listeners properly even without a type parameter' , ( ) => {
110
125
zoneA . run ( ( ) => {
111
126
emitter . on ( 'test' , shouldNotRun ) ;
You can’t perform that action at this time.
0 commit comments