Skip to content

Commit cd6a441

Browse files
addaleaxBethGriggs
authored andcommitted
doc: update MessagePort documentation for EventTarget inheritance
Refs: #34057 Refs: #35835 PR-URL: #35839 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 6aa1df9 commit cd6a441

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

doc/api/worker_threads.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ inherit from its global `Object` class. Objects passed to the
140140
and inherit from its global `Object` class.
141141

142142
However, the created `MessagePort` will no longer inherit from
143-
[`EventEmitter`][], and only [`port.onmessage()`][] can be used to receive
143+
[`EventTarget`][], and only [`port.onmessage()`][] can be used to receive
144144
events using it.
145145

146146
## `worker.parentPort`
@@ -295,17 +295,22 @@ port2.postMessage({ foo: 'bar' });
295295
## Class: `MessagePort`
296296
<!-- YAML
297297
added: v10.5.0
298+
changes:
299+
- version:
300+
- v14.7.0
301+
pr-url: https://github.com/nodejs/node/pull/34057
302+
description: This class now inherits from `EventTarget` rather than
303+
from `EventEmitter`.
298304
-->
299305

300-
* Extends: {EventEmitter}
306+
* Extends: {EventTarget}
301307

302308
Instances of the `worker.MessagePort` class represent one end of an
303309
asynchronous, two-way communications channel. It can be used to transfer
304310
structured data, memory regions and other `MessagePort`s between different
305311
[`Worker`][]s.
306312

307-
With the exception of `MessagePort`s being [`EventEmitter`][]s rather
308-
than [`EventTarget`][]s, this implementation matches [browser `MessagePort`][]s.
313+
This implementation matches [browser `MessagePort`][]s.
309314

310315
### Event: `'close'`
311316
<!-- YAML
@@ -909,7 +914,6 @@ active handle in the event system. If the worker is already `unref()`ed calling
909914
[`Buffer`]: buffer.md
910915
[`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`]: errors.md#errors_err_missing_message_port_in_transfer_list
911916
[`ERR_WORKER_NOT_RUNNING`]: errors.md#ERR_WORKER_NOT_RUNNING
912-
[`EventEmitter`]: events.md
913917
[`EventTarget`]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
914918
[`FileHandle`]: fs.md#fs_class_filehandle
915919
[`KeyObject`]: crypto.md#crypto_class_keyobject

0 commit comments

Comments
 (0)