Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/zone.js/lib/common/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const OPTIMIZED_ZONE_EVENT_TASK_DATA: EventTaskData = {
export const zoneSymbolEventNames: any = {};
export const globalSources: any = {};

const EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$');
const EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '([\\s\\S]+)(true|false)$');
const IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped');

function prepareEventNames(eventName: string, eventNameToString?: (eventName: string) => string) {
Expand Down
20 changes: 20 additions & 0 deletions packages/zone.js/test/node/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,26 @@ describe('nodejs EventEmitter', () => {
expect(emitter.listeners('test1').length).toEqual(0);
});
});
it('should remove all listeners for non-word event names without a type parameter', () => {
zoneA.run(() => {
const eventNames = [
'tenant:notification',
'tenant.notification',
'tenant-notification',
'tenant\u2603notification',
];
for (const eventName of eventNames) {
emitter.on(eventName, shouldNotRun);
}

emitter.removeAllListeners();

for (const eventName of eventNames) {
expect(emitter.listeners(eventName).length).toEqual(0);
emitter.emit(eventName);
}
});
});
it('should remove once listener after emit', () => {
zoneA.run(() => {
emitter.once('test', expectZoneA);
Expand Down
Loading