Skip to content

events: deal with no argument case#33611

Closed
benjamingr wants to merge 5 commits into
nodejs:masterfrom
benjamingr:event-controller-compat
Closed

events: deal with no argument case#33611
benjamingr wants to merge 5 commits into
nodejs:masterfrom
benjamingr:event-controller-compat

Conversation

@benjamingr
Copy link
Copy Markdown
Member

Fix new Event() to throw an error rather than behave like new Event(undefined) to align with browser behavior.

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

cc @jasnell

I'll be making a few of these (compatibility) PRs to align with Chrome's behavior as I run into issues and eventually port the WPTs (as suggested by @targos).

I'm keeping these small so it's easier to bikeshed things like error codes.

@nodejs-github-bot nodejs-github-bot added the errors Issues and PRs related to JavaScript errors originated in Node.js core. label May 28, 2020
@benjamingr benjamingr added the events Issues and PRs related to the events subsystem / EventEmitter. label May 28, 2020
Comment thread lib/internal/event_target.js Outdated
@benjamingr benjamingr force-pushed the event-controller-compat branch from 48b30da to cea4961 Compare May 28, 2020 14:19
@benjamingr
Copy link
Copy Markdown
Member Author

@targos is this more of what you had in mind?

Comment thread lib/internal/event_target.js Outdated
Comment thread test/parallel/test-eventtarget.js Outdated
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 29, 2020
benjamingr added a commit that referenced this pull request May 31, 2020
PR-URL: #33611
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@benjamingr
Copy link
Copy Markdown
Member Author

benjamingr commented May 31, 2020

Landed in 8ae28ff

@BridgeAR thanks for the help landing things with ncu - please take a look and make sure I didn't dum-goofed :]

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@jasnell
Copy link
Copy Markdown
Member

jasnell commented Jun 3, 2020

@benjamingr ... the CI failure here can be fixed with the following change:

diff --git a/test/parallel/test-eventtarget.js b/test/parallel/test-eventtarget.js
index 82a89caae1..783ca5eeab 100644
--- a/test/parallel/test-eventtarget.js
+++ b/test/parallel/test-eventtarget.js
@@ -408,6 +408,6 @@ ok(EventTarget);
 {
   const target = new EventTarget();
   strictEqual(target.toString(), '[object EventTarget]');
-  const event = new Event();
+  const event = new Event('');
   strictEqual(event.toString(), '[object Event]');
 }

@benjamingr
Copy link
Copy Markdown
Member Author

@jasnell pushed a fix, feel free to push such fixed on my (ET) branches in the future and thanks for landing.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator