events: _events should be an own property#2046
Closed
vkurchatkin wants to merge 1 commit intonodejs:masterfrom
Closed
events: _events should be an own property#2046vkurchatkin wants to merge 1 commit intonodejs:masterfrom
vkurchatkin wants to merge 1 commit intonodejs:masterfrom
Conversation
2c6b424 fixed this problem for the case where EventEmitter constructor is invoked. If is not, shared _events were still used. This commit ensures that listeners are added only to own _events. See: nodejs/node-v0.x-archive#7405
lib/events.js
Outdated
Member
There was a problem hiding this comment.
ensureXxx function should not have a side-effect (no modified state).
I feel initializeXxx is better or remove side-effects like:
function ensureEvents(emitter) {
if (!emitter._events ||
emitter._events === Object.getPrototypeOf(emitter)._events) {
return false;
}
return true;
}
Contributor
Author
There was a problem hiding this comment.
Disagree. ensure implies idempotency, nothing more
Member
|
LGTM but maybe you can add a regression test for the two-level inheritance I described here? |
Contributor
|
Not sure about this. If it is incorrect, why should we support it? It isn't supported in any other inheritable node class and just leads to lots of annoying legacy code. |
Member
|
@vkurchatkin ... is this still something you'd like to pursue? |
Contributor
Author
|
@jasnell actually, no, I don't think it's a good idea anymore |
Member
|
Thanks @vkurchatkin ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2044
R=@mscdex, @bnoordhuis