console: allow Object.prototype fields as labels#563
console: allow Object.prototype fields as labels#563cjihrig wants to merge 1 commit intonodejs:v1.xfrom cjihrig:time.labels
Conversation
|
LGTM! |
test/parallel/test-console.js
Outdated
There was a problem hiding this comment.
did this actually throw?
There was a problem hiding this comment.
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.
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.
It might be better (perf-wise) to just replace this with { __proto__: null } or Object.create(null)
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