-
-
Couldn't load subscription status.
- Fork 33.6k
console: allow Object.prototype fields as labels #563
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
Conversation
|
LGTM! |
test/parallel/test-console.js
Outdated
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.
did this actually throw?
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.
No. It returns NaN like I noted in the commit log :-/. Will update the test.
|
@vkurchatkin updated the test. PTAL |
|
LGTM |
lib/console.js
Outdated
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'm generally -0 on replacing var with let unless there's a distinct need for block-scoping.
Edit: This is a non-blocking nit. It would make me feel better if these remained vars, though.
|
@chrisdickinson changed the |
|
I'll just leave it here: http://www.reddit.com/r/javascript/comments/1sgsmj/let_var_die/ |
|
If we are going to switch, I think it most reasonable to only change lines that we are already editing. |
|
@vkurchatkin I'm in the camp of being as restrictive as possible, which I think |
|
The test should still fail for console._times = Object.create(null);
console.time('__proto__'); // => console._times.__proto__ = Date.now();
console.timeEnd('__proto__'); // throws
console._times.__proto__ === null; // true |
|
@pluma seems to work fine with the latest iojs code. |
|
@cjihrig Interesting. Is this related to the newer version of V8 being used? |
|
@pluma that would be my guess - I see the same behavior in the Chrome console. |
|
Hm, odd. I guess the semantics of |
|
Is anyone opposed to this landing? Another alternative would be to use a |
|
+1 for landing, and also +1 for experimenting with |
Console.prototype.timeEnd() returns NaN if the timer label corresponds to a property on Object.prototype. This commit uses a Map to construct the _times object.
|
@rvagg updated to use a |
|
love it! |
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.
It might be better (perf-wise) to just replace this with { __proto__: null } or Object.create(null)
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.
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.
fair enough, try it out
Console.prototype.timeEnd() returns NaN if the timer label corresponds to a property on Object.prototype. This commit uses a Map to construct the _times object. Fixes: nodejs/node-v0.x-archive#9069 PR-URL: #563 Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
|
Landed in 3cbb5cd |
Console.prototype.timeEnd()returnsNaNif the timer label corresponds to a property onObject.prototype. This commit usesObject.create(null)to construct the_timesobject. See nodejs/node-v0.x-archive#9069