From 3abc6d2ead028ebb1cfbbd2e28606e2e1274c7b7 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 8584789691c914..dfda036de18ea3 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -1978,6 +1978,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`