From 3ce75606fdfc94d4a1607b804b968ebfc14030d1 Mon Sep 17 00:00:00 2001 From: Daeyeon Jeong Date: Mon, 20 Jun 2022 20:08:52 +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 --- 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`