mirror of https://github.com/nodejs/node.git
domain: pass opts to `EventEmitter.init`
PR-URL: https://github.com/nodejs/node/pull/41414 Fixes: https://github.com/nodejs/node/issues/41391 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
parent
26398575dc
commit
22792c8632
|
@ -446,7 +446,7 @@ Domain.prototype.bind = function(cb) {
|
|||
EventEmitter.usingDomains = true;
|
||||
|
||||
const eventInit = EventEmitter.init;
|
||||
EventEmitter.init = function() {
|
||||
EventEmitter.init = function(opts) {
|
||||
ObjectDefineProperty(this, 'domain', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
|
@ -457,7 +457,7 @@ EventEmitter.init = function() {
|
|||
this.domain = exports.active;
|
||||
}
|
||||
|
||||
return FunctionPrototypeCall(eventInit, this);
|
||||
return FunctionPrototypeCall(eventInit, this, opts);
|
||||
};
|
||||
|
||||
const eventEmit = EventEmitter.prototype.emit;
|
||||
|
|
|
@ -321,6 +321,8 @@ EventEmitter.setMaxListeners =
|
|||
}
|
||||
};
|
||||
|
||||
// If you're updating this function definition, please also update any
|
||||
// re-definitions, such as the one in the Domain module (lib/domain.js).
|
||||
EventEmitter.init = function(opts) {
|
||||
|
||||
if (this._events === undefined ||
|
||||
|
|
|
@ -18,3 +18,11 @@ d.on('error', common.mustCall((err) => {
|
|||
|
||||
d.add(e);
|
||||
e.emit('error', new Error('foobar'));
|
||||
|
||||
{
|
||||
// Ensure initial params pass to origin `EventEmitter.init` function
|
||||
const e = new EventEmitter({ captureRejections: true });
|
||||
const kCapture = Object.getOwnPropertySymbols(e)
|
||||
.find((it) => it.description === 'kCapture');
|
||||
assert.strictEqual(e[kCapture], true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue