mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

Make sure that listeners are added properly if there has previously been one but currently are none for a given event type. PR-URL: https://github.com/nodejs/node/pull/34056 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
19 lines
431 B
JavaScript
19 lines
431 B
JavaScript
// Flags: --expose-internals --no-warnings
|
|
'use strict';
|
|
const common = require('../common');
|
|
const {
|
|
Event,
|
|
EventTarget,
|
|
} = require('internal/event_target');
|
|
const { once } = require('events');
|
|
|
|
const et = new EventTarget();
|
|
(async function() {
|
|
await once(et, 'foo');
|
|
await once(et, 'foo');
|
|
})().then(common.mustCall());
|
|
|
|
et.dispatchEvent(new Event('foo'));
|
|
setImmediate(() => {
|
|
et.dispatchEvent(new Event('foo'));
|
|
});
|