From 33e2ee58a79da134c0d4f26f96a70b084923247a Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Mon, 2 Nov 2020 22:40:00 +0200 Subject: [PATCH] events: define event handler as enumerable PR-URL: https://github.com/nodejs/node/pull/35931 Reviewed-By: Anna Henningsen Reviewed-By: Antoine du Hamel Reviewed-By: Daijiro Wachi Reviewed-By: Rich Trott --- lib/internal/event_target.js | 4 +++- test/parallel/test-eventtarget.js | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 5fb9f4c6d62aa7..1802cb833e38ca 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -592,7 +592,9 @@ function defineEventHandler(emitter, name) { emitter.addEventListener(name, value); } eventHandlerValue = value; - } + }, + configurable: true, + enumerable: true }); } module.exports = { diff --git a/test/parallel/test-eventtarget.js b/test/parallel/test-eventtarget.js index accacb8a328c03..96d755a8f32fe2 100644 --- a/test/parallel/test-eventtarget.js +++ b/test/parallel/test-eventtarget.js @@ -517,3 +517,10 @@ let asyncTest = Promise.resolve(); })); target.dispatchEvent(new Event('foo')); } +{ + const target = new EventTarget(); + defineEventHandler(target, 'foo'); + const descriptor = Object.getOwnPropertyDescriptor(target, 'onfoo'); + strictEqual(descriptor.configurable, true); + strictEqual(descriptor.enumerable, true); +}