GeezerVison is showing github.com — domain: pass opts to `EventEmitter.init` · nodejs/node@227dea8
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/domain.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -446,7 +446,7 @@ Domain.prototype.bind = function(cb) { |
446 | 446 | EventEmitter.usingDomains = true; |
447 | 447 |
|
448 | 448 | const eventInit = EventEmitter.init; |
449 | | -EventEmitter.init = function() { |
| 449 | +EventEmitter.init = function(opts) { |
450 | 450 | ObjectDefineProperty(this, 'domain', { |
451 | 451 | configurable: true, |
452 | 452 | enumerable: false, |
@@ -457,7 +457,7 @@ EventEmitter.init = function() { |
457 | 457 | this.domain = exports.active; |
458 | 458 | } |
459 | 459 |
|
460 | | - return FunctionPrototypeCall(eventInit, this); |
| 460 | + return FunctionPrototypeCall(eventInit, this, opts); |
461 | 461 | }; |
462 | 462 |
|
463 | 463 | const eventEmit = EventEmitter.prototype.emit; |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/events.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -321,6 +321,8 @@ EventEmitter.setMaxListeners = |
321 | 321 | } |
322 | 322 | }; |
323 | 323 |
|
| 324 | +// If you're updating this function definition, please also update any |
| 325 | +// re-definitions, such as the one in the Domain module (lib/domain.js). |
324 | 326 | EventEmitter.init = function(opts) { |
325 | 327 |
|
326 | 328 | if (this._events === undefined || |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-domain-ee.js +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,3 +18,11 @@ d.on('error', common.mustCall((err) => { |
18 | 18 |
|
19 | 19 | d.add(e); |
20 | 20 | e.emit('error', new Error('foobar')); |
| 21 | + |
| 22 | +{ |
| 23 | + // Ensure initial params pass to origin `EventEmitter.init` function |
| 24 | + const e = new EventEmitter({ captureRejections: true }); |
| 25 | + const kCapture = Object.getOwnPropertySymbols(e) |
| 26 | + .find((it) => it.description === 'kCapture'); |
| 27 | + assert.strictEqual(e[kCapture], true); |
| 28 | +} |