Commit Graph

67 Commits

Author SHA1 Message Date
Masashi Hirano
03fb789fb9
events: add null check for the signal of EventTarget
This will improve the Web compatibility.
Passing null as the signal should throw an error.
WPT says "Passing null as the signal should throw".
Please see https://github.com/web-platform-tests/wpt/blob/master/dom/events/AddEventListenerOptions-signal.any.js

PR-URL: https://github.com/nodejs/node/pull/43153
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-10-13 09:58:40 +00:00
legendecas
f529f73bd7
lib: brand check event handler property receivers
Event handler properties defined by `defineEventHandler` should check
if the receiver is a valid `EventTarget`.

PR-URL: https://github.com/nodejs/node/pull/44483
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-10-04 00:55:54 +08:00
Antoine du Hamel
a957f7bd37
lib: refactor to avoid prototype pollution
PR-URL: https://github.com/nodejs/node/pull/43474
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2022-08-17 18:36:33 +00:00
Basit Chonka
9b8ba25360
events: use bitset to save memory
PR-URL: https://github.com/nodejs/node/pull/43700
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-10 13:01:10 +02:00
Daeyeon Jeong
cbbd91d804
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 <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2022-07-17 12:27:49 +01:00
Daeyeon Jeong
3f7f62f6bc
events: improve Event compatibility
This fixes `Event` constructor to improve `Event Web API`
compatibility.

The test added was written by referring to
`wpt@dom/events/Event-constructors.any.js`.

Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com

PR-URL: https://github.com/nodejs/node/pull/43461
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-07-08 09:12:13 +01:00
Daeyeon Jeong
ed1e9ae402
events: improve EventListener validation
This fixes validating `EventListener` given to `add/removeEventListener`
to improve the Web API compatibility.

According to the WPT test failure with the current validation,
`addEventListener` should not require `handleEvent` to be defined on
an `EventListener`".  IIUC, the same can be applied to
`removeEventListener` also.

Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com

PR-URL: https://github.com/nodejs/node/pull/43491
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-06-29 12:26:18 +01:00
LiviaMedeiros
9220aca5b9
events: use kEmptyObject
PR-URL: https://github.com/nodejs/node/pull/43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-06-11 12:18:12 +02:00
Antoine du Hamel
06d8606960
lib: use null-prototype objects for property descriptors
Refs: https://github.com/nodejs/node/pull/42921

PR-URL: https://github.com/nodejs/node/pull/43270
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-06-03 09:23:58 +01:00
Joyee Cheung
ea0668a27e
lib: use class fields in Event and EventTarget
https://bugs.chromium.org/p/v8/issues/detail?id=10704 is already
fixed, so switch back to class fields instead of using symbol
properties.

PR-URL: https://github.com/nodejs/node/pull/42361
Refs: b1c3909bd7
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-03-23 20:07:55 +08:00
Benjamin Gruenbaum
0a722973cb
events: set default handler value
Event handler like BroadcastChannel.onmessage and AbortSignal.onabort
have a default value of `null` but we return `undefined`.

Return `null` and add a test.

PR-URL: https://github.com/nodejs/node/pull/41970
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2022-02-16 19:36:20 +00:00
Mestery
998e5acc69
lib: move kEnumerableProperty to internal/util
PR-URL: https://github.com/nodejs/node/pull/41877
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-02-11 17:30:47 +00:00
Rich Trott
43371dd5d2 events: clarify JSDoc entries
Split the JSDoc entries into separate blocks.

This is in preparation for enabling jsdoc/check-param-names lint rule.

PR-URL: https://github.com/nodejs/node/pull/41311
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-12-28 13:16:58 -08:00
James M Snell
9d6bd102ee
events: add jsdoc details for Event and EventTarget
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/41274
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Adrian Estrada <edsadr@gmail.com>
2021-12-24 07:08:57 -08:00
James M Snell
606f7213c4
events: propagate weak option for kNewListener
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/40899
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-12-01 16:26:23 -08:00
MrBBot
b381bed10c events: allow dispatch many times without listener
Fast path for EventTarget dispatch with no listeners didn't reset
kIsBeingDispatched flag, meaning same event couldn't be dispatched
multiple times.

PR-URL: https://github.com/nodejs/node/pull/39772
Refs: https://github.com/nodejs/node/pull/39395
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-09-26 21:09:06 +02:00
James M Snell
4ec64e320f
events: add brand checks for detached accessors
PR-URL: https://github.com/nodejs/node/pull/39773
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-08-25 08:20:50 -07:00
Luigi Pinca
5c4e673a96 events: allow an event to be dispatched multiple times
Use a different flag to prevent recursive dispatching.

PR-URL: https://github.com/nodejs/node/pull/39395
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-07-25 16:17:41 +02:00
Luigi Pinca
5b36b8bded events: allow the options argument to be null
Make `EventTarget.prototype.addEventListener()` accept `null` as a valid
value for the `options` argument.

PR-URL: https://github.com/nodejs/node/pull/39486
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2021-07-25 16:16:26 +02:00
Joyee Cheung
58cfca8a9b
bootstrap: load perf_hooks eagerly during bootstrap
PR-URL: https://github.com/nodejs/node/pull/38971
Refs: https://github.com/nodejs/node/issues/35711
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-06-28 16:20:17 +08:00
ExE Boss
78343bbdc5 lib: add WeakRef and FinalizationRegistry to primordials
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/37263
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-04-13 12:36:56 +02:00
James M Snell
ef459d86ee events: remove return value on addEventListener
The `addEventListener()` should not return a value.

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/37696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-03-13 17:56:48 +01:00
Nitzan Uziely
83d6e63aee events: change EventTarget handler exception behavior
Change the behavior of EventTarget, instead of emitting
'error' on handler exception, emit 'uncaughtException'.

Fixes: https://github.com/nodejs/node/issues/36770

PR-URL: https://github.com/nodejs/node/pull/37237
Fixes: https://github.com/nodejs/node/issues/36770
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-15 20:10:07 +02:00
ExE Boss
beee53884d lib: fix WebIDL object and dictionary type conversion
PR-URL: https://github.com/nodejs/node/pull/37047
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-08 17:02:16 -08:00
Benjamin Gruenbaum
5ef4c64e5b lib: add weak event handlers
PR-URL: https://github.com/nodejs/node/pull/36607
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2021-02-06 19:01:53 +02:00
ZiJian Liu
08dd4b1723
lib: refactor to use validateString
PR-URL: https://github.com/nodejs/node/pull/37006
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-22 19:56:34 -08:00
ZiJian Liu
eb8422c022 events: refactor to use optional chaining
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36763
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-01-11 11:38:54 +01:00
Antoine du Hamel
0b6d3070a1 lib: add primordials.SafeArrayIterator
PR-URL: https://github.com/nodejs/node/pull/36532
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-12-28 00:08:44 +01:00
Antoine du Hamel
997f2fcbbc events: refactor to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36304
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-12-25 18:10:56 +00:00
Momtchil Momtchev
0fd121e00c stream: add FileHandle support to Read/WriteStream
Support creating a Read/WriteStream from a
FileHandle instead of a raw file descriptor
Add an EventEmitter to FileHandle with a single
'close' event.

Fixes: https://github.com/nodejs/node/issues/35240

PR-URL: https://github.com/nodejs/node/pull/35922
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-12-05 00:50:06 +01:00
Benjamin Gruenbaum
ef8d0e9798 events: support signal in EventTarget
PR-URL: https://github.com/nodejs/node/pull/36258
Fixes: https://github.com/nodejs/node/issues/36073
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-12-02 14:55:08 +00:00
James M Snell
dc79f3f37c events: add max listener warning for EventTarget
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36001
Fixes: https://github.com/nodejs/node/issues/35990
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-16 09:48:18 +00:00
Benjamin Gruenbaum
1a6d4dce6d events: getEventListeners static
PR-URL: https://github.com/nodejs/node/pull/35991
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-11-09 07:39:31 +00:00
Benjamin Gruenbaum
d3969003b5 events: fire handlers in correct oder
PR-URL: https://github.com/nodejs/node/pull/35931
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-07 18:12:30 +02:00
Benjamin Gruenbaum
1c99cdebbc events: define abort on prototype
PR-URL: https://github.com/nodejs/node/pull/35931
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-07 18:12:28 +02:00
Benjamin Gruenbaum
b80d847608 events: support event handlers on prototypes
PR-URL: https://github.com/nodejs/node/pull/35931
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-07 18:12:27 +02:00
Benjamin Gruenbaum
8e87efb849 events: define event handler as enumerable
PR-URL: https://github.com/nodejs/node/pull/35931
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-07 18:12:24 +02:00
Leko
cef144421c tools: add new ESLint rule: prefer-primordials
I added a new custom ESLint rule to fix these problems.

We have a lot of replaceable codes with primordials.
Accessing built-in objects is restricted by existing rule
(no-restricted-globals), but accessing property in the built-in objects
is not restricted right now. We manually review codes that can be
replaced by primordials, but there's a lot of code that actually needs
to be fixed. We have often made pull requests to replace the primordials
with.

Restrict accessing global built-in objects such as `Promise`.
Restrict calling static methods such as `Array.from` or `Symbol.for`.
Don't restrict prototype methods to prevent false-positive.

PR-URL: https://github.com/nodejs/node/pull/35448
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
2020-11-07 18:28:14 +08:00
Benjamin Gruenbaum
c5477be8a1 events: support emit on nodeeventtarget
PR-URL: https://github.com/nodejs/node/pull/35851
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
2020-11-06 10:51:02 +00:00
Benjamin Gruenbaum
ee749ba2c6 events: add a few tests
PR-URL: https://github.com/nodejs/node/pull/35806
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2020-11-03 17:16:55 +00:00
Daijiro Wachi
44571d18e5 lib: let abort_controller target be EventTarget
The AbortController abort event should have EventTarget as a target
property of the argument event.

PR-URL: https://github.com/nodejs/node/pull/35869
Refs: https://github.com/web-platform-tests/wpt/blob/master/dom/abort/event.any.js
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2020-11-01 10:16:54 +09:00
Benjamin Gruenbaum
f20a783a31 events: make abort_controller event trusted
The AbortController abort event is trusted, currently we fire all
events with isTrusted: false. Allow dispatching events
internally with `isTrusted: true` and add a test for it.

Co-Authored-By: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
Fixes: https://github.com/nodejs/node/issues/35748

PR-URL: https://github.com/nodejs/node/pull/35811
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-10-28 18:33:03 +00:00
Luigi Pinca
81ba3ae699 events: make eventTarget.removeAllListeners() return this
Fixes: https://github.com/nodejs/node/issues/35762

PR-URL: https://github.com/nodejs/node/pull/35805
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-10-28 06:39:16 -07:00
Sebastien Ahkrin
b79829c5f5
lib: replace String global with primordials
PR-URL: https://github.com/nodejs/node/pull/35397
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
2020-10-04 09:40:56 +02:00
Michaël Zasso
a8806535d9
lib: use Object static properties from primordials
PR-URL: https://github.com/nodejs/node/pull/35380
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
2020-09-30 17:52:35 +02:00
Rich Trott
8a8416f841 lib: use full URL to GitHub issues in comments
Don't assume the reader of the code will know where to find the issue
tracker. Provide the full URL. This is especially important if the
issue tracker should move again.

PR-URL: https://github.com/nodejs/node/pull/34686
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Mary Marchini <oss@mmarchini.me>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-08-10 16:33:49 -07:00
Anna Henningsen
16b11cd2ad
events: expand NodeEventTarget functionality
Enable `NodeEventTarget` as a base class for `MessagePort`,
by enabling special processing of events for Node.js listeners,
and removing implicit constructors/private properties so that
classes can be made subclasses of `NodeEventTarget` after they
are created.

PR-URL: https://github.com/nodejs/node/pull/34057
Refs: https://twitter.com/addaleax/status/1276289101671608320
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-07-22 22:59:04 +02:00
Anna Henningsen
08b6335c9c events: re-use the same isTrusted getter
Creating a new function each time the property descriptor is set
comes with performance overhead, since these functions have different
identities, even if they contain the same code.

Refs: https://twitter.com/tverwaes/status/1285496612618473472

PR-URL: https://github.com/nodejs/node/pull/34459
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2020-07-21 16:09:27 -07:00
Joyee Cheung
b1c3909bd7
lib: initialize instance members in class constructors
Since V8 snapshot does not currently support instance member
initialization, initialize them in ordianry class constructors
for now so that these classes can be included in the snapshot.
This may be reverted once
https://bugs.chromium.org/p/v8/issues/detail?id=10704
is fixed and backported.

PR-URL: https://github.com/nodejs/node/pull/32984
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2020-07-18 11:23:20 +08:00
Anna Henningsen
e18afe45d2 events: fix add-remove-add case in EventTarget
Make sure that listeners are added properly if there has previously
been one but currently are none for a given event type.

PR-URL: https://github.com/nodejs/node/pull/34056
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-06-25 19:28:45 -07:00