From f69faac0dc9c302a974b71c8c77de04f3696b6de Mon Sep 17 00:00:00 2001 From: Daeyeon Jeong Date: Sun, 17 Jul 2022 20:27:49 +0900 Subject: [PATCH] events: add `CustomEvent` This implements the Web API `CustomEvent` in `internal/event_target`. Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com PR-URL: https://github.com/nodejs/node/pull/43514 Refs: https://github.com/nodejs/node/issues/40678 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum --- doc/api/events.md | 26 ++ lib/internal/event_target.js | 45 +++ test/parallel/test-events-customevent.js | 325 +++++++++++++++++++ test/parallel/test-eventtarget-brandcheck.js | 34 +- tools/doc/type-parser.mjs | 1 + 5 files changed, 428 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-events-customevent.js diff --git a/doc/api/events.md b/doc/api/events.md index d68f1759395610..873739ad57ecde 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -1987,6 +1987,31 @@ added: v14.5.0 Removes the `listener` from the list of handlers for event `type`. +### Class: `CustomEvent` + + + +> Stability: 1 - Experimental. + +* Extends: {Event} + +The `CustomEvent` object is an adaptation of the [`CustomEvent` Web API][]. +Instances are created internally by Node.js. + +#### `event.detail` + + + +> Stability: 1 - Experimental. + +* Type: {any} Returns custom data passed when initializing. + +Read-only. + ### Class: `NodeEventTarget`