-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
events: EventTarget use validators and small fix #33663
Conversation
@@ -66,7 +67,7 @@ class Event { | |||
return name; | |||
|
|||
const opts = Object.assign({}, options, { | |||
dept: options.depth === null ? null : options.depth - 1 | |||
depth: NumberIsInteger(options.depth) ? options.depth - 1 : options.depth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assume this was a bug (dept
instead of depth
) but wanted to point out since I'm not sure how this interaction works (inspecting circular events I assume?).
Also, use NumberIsInteger instead of just null check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is both correct. The user should only ever pass through null
or and integer but it would be possible to pass through other types as well.
lib/internal/event_target.js
Outdated
Object, | ||
NumberIsInteger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object, | |
NumberIsInteger, | |
NumberIsInteger, | |
Object, |
Generally LGTM - can you add a test? |
Do you mean test for |
02a268e
to
c434ce6
Compare
@@ -73,7 +73,7 @@ class Event { | |||
return name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, @BridgeAR shouldn't this return this
? (as well as the other one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be ideal. this
will just let inspect()
to properly know what to do.
Yes. cc @jasnell wdyt? If this isn't too much work to test I think we should add a test - but if it's a lot of work I am fine with LGTMing without one. |
8ae28ff
to
2935f72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a rebase.
@@ -73,7 +73,7 @@ class Event { | |||
return name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be ideal. this
will just let inspect()
to properly know what to do.
@@ -66,7 +67,7 @@ class Event { | |||
return name; | |||
|
|||
const opts = Object.assign({}, options, { | |||
dept: options.depth === null ? null : options.depth - 1 | |||
depth: NumberIsInteger(options.depth) ? options.depth - 1 : options.depth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is both correct. The user should only ever pass through null
or and integer but it would be possible to pass through other types as well.
c434ce6
to
9a50794
Compare
@lundibundi I rebased your branch and everything should be in order again. The tests pass locally. Please have a look to verify that, thanks. |
@BridgeAR thanks :). |
This needs another rebase, unfortunately. |
9a50794
to
8713e07
Compare
Closing in favor of #34015 (which combines this and other |
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes/cc @jasnell @nodejs/events